Skip to content

Commit 6c7113f

Browse files
committed
feat: 임원진 멤버 삭제 기능 추가
1 parent 98ab4ca commit 6c7113f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/java/dmu/dasom/api/domain/executive/controller/ExecutiveContorller.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public ResponseEntity<ExecutiveCreationResponseDto> createExecutive(@Valid @Requ
3434
return ResponseEntity.status(201).body(executiveService.createExecutive(requestDto));
3535
}
3636

37+
@Operation(summary = "임원진 삭제")
38+
@DeleteMapping("/{id}")
39+
// Void 사용 이유?
40+
// DELETE 요청 같이 성공/실패만 확인하면 되는 경우 사용
41+
public ResponseEntity<Void> deleteExecutive(@PathVariable @Min(1) Long id) {
42+
executiveService.deleteExective(id);
43+
return ResponseEntity.ok().build();
44+
}
45+
3746
@Operation(summary = "임원진 수정")
3847
@PutMapping("/{id}")
3948
public ResponseEntity<ExecutiveResponseDto> updateExecutive(@PathVariable @Min(1) Long id,

src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestD
3131
return new ExecutiveCreationResponseDto(executiveRepository.save(requestDto.toEntity()).getId());
3232
}
3333

34+
// 임원진 멤버 삭제
35+
@Transactional
36+
public void deleteExective(Long id) {
37+
ExecutiveEntity executive = executiveRepository.findById(id)
38+
.orElseThrow(() -> new IllegalArgumentException("Executive not found")); // 일단 에러 코드 출력 나중에 커스텀 에러코드 수정
39+
40+
executiveRepository.delete(executive);
41+
}
42+
3443
// 임원진 멤버 수정
3544
@Transactional
3645
public ExecutiveResponseDto updateExecutive(Long id, ExecutiveUpdateRequestDto requestDto) {

0 commit comments

Comments
 (0)