Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/example/prdoit/controller/ProjectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public ResponseEntity<Object> getBurndownList(@PathVariable String projectId, @P
}
}

@DeleteMapping("/{projectId}")
public ResponseEntity<Object> deleteProject(@PathVariable String projectId) {
log.info("[deleteProject] 프로젝트 삭제 요청");
try{
projectService.deleteProject(projectId);
return ResponseEntity.ok("프로젝트 삭제에 성공했습니다.");
} catch (RuntimeException e){
log.error("[deleteProject] {}", e.getMessage());
return ResponseEntity.badRequest().body("프로젝트 삭제에 실패했습니다.");
}
}

/*
@PutMapping("/product")
public ResponseEntity<Object> putBacklog(@RequestBody BacklogPutDto backlogPutDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ public class ProjectLevelContentTable {
@ManyToOne
@JoinColumn(name = "projectId")
private ProjectTable projectId;


@OneToMany(mappedBy = "levelContentId", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
@JsonIgnore
private List<BacklogTable> backlogList;
}
4 changes: 3 additions & 1 deletion src/main/java/com/example/prdoit/model/ProjectTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ public class ProjectTable {
@JoinColumn(name = "id")
private IdTable id;


@OneToMany(mappedBy = "projectId", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
@JsonIgnore
private List<ProjectLevelContentTable> projectLevelContentList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public interface ProjectService {
void deleteProjectContent(ContentDeleteDto contentDeleteDto);

BacklogAddDto getBacklog(String projectId, String backlogTaskId);

void deleteProject(String projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ public BacklogAddDto getBacklog(String projectId, String backlogTaskId) {

}

@Override
public void deleteProject(String projectId) {
log.info("[deleteProject] 프로젝트 삭제 시작");
ProjectTable projectTable = projectTableRepository.findById(projectId).orElseThrow(() -> new CustomException("존재하지 않는 프로젝트입니다."));
try {
projectTableRepository.delete(projectTable);
} catch (CustomException e) {
log.error(e.getMessage());
throw new CustomException(e.getMessage());
} catch (RuntimeException e) {
log.error(e.getMessage());
throw e;
}
}

// internal method
//ContentDto를 받아서 ProjectLevelContentTable을 생성
public ProjectLevelContentTable createContent(String projectId, int projectLevel, String projectContent) {
Expand Down