Skip to content

Commit

Permalink
[feat] #17 관리자 공지사항 삭제 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jj0526 authored and seokjun01 committed Jan 16, 2025
1 parent 81bc760 commit 3f3fa4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -47,4 +48,13 @@ public ResponseEntity<GlobalResponseDto<Void>> update(@PathVariable Long noticeI
.body(GlobalResponseDto.success());
}

@DeleteMapping("/{noticeId}")
@Operation(summary = "관리자 공지사항 삭제", description = "관리자가 공지사항을 삭제합니다.")
public ResponseEntity<GlobalResponseDto<Void>> delete(@PathVariable Long noticeId) {
noticeService.deleteNotice(noticeId);

return ResponseEntity.status(HttpStatus.OK)
.body(GlobalResponseDto.success());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ public void updateNotice(Long noticeId, NoticeAdminRequestDto noticeAdminRequest

noticeRepository.save(notice);
}

public void deleteNotice(Long noticeId) {

Notice notice = noticeRepository.findById(noticeId)
.orElseThrow(() -> new CommonException(ErrorCode.NOTICE_NOT_FOUND));

noticeRepository.delete(notice);
}
}

0 comments on commit 3f3fa4c

Please sign in to comment.