1+ package dmu .dasom .api .domain .activity .controller ;
2+
3+ import dmu .dasom .api .domain .activity .dto .ActivityHistoryRequestDto ;
4+ import dmu .dasom .api .domain .activity .dto .ActivityHistoryResponseDto ;
5+ import dmu .dasom .api .domain .activity .service .ActivityHistoryService ;
6+ import dmu .dasom .api .domain .common .exception .ErrorResponse ;
7+ import io .swagger .v3 .oas .annotations .Operation ;
8+ import io .swagger .v3 .oas .annotations .media .Content ;
9+ import io .swagger .v3 .oas .annotations .media .ExampleObject ;
10+ import io .swagger .v3 .oas .annotations .media .Schema ;
11+ import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
12+ import io .swagger .v3 .oas .annotations .responses .ApiResponses ;
13+ import io .swagger .v3 .oas .annotations .tags .Tag ;
14+ import jakarta .validation .Valid ;
15+ import jakarta .validation .constraints .Min ;
16+ import lombok .RequiredArgsConstructor ;
17+ import org .springframework .http .ResponseEntity ;
18+ import org .springframework .web .bind .annotation .*;
19+
20+ @ RestController
21+ @ RequestMapping ("/api/admin/activity/histories" )
22+ @ RequiredArgsConstructor
23+ @ Tag (name = "ADMIN - Activity History API" , description = "어드민 활동 연혁 관리 API" )
24+ public class AdminActivityHistoryController {
25+
26+ private final ActivityHistoryService historyService ;
27+
28+ @ Operation (summary = "활동 연혁 생성" )
29+ @ ApiResponses (value = {
30+ @ ApiResponse (responseCode = "201" , description = "활동 연혁 생성 성공" ),
31+ @ ApiResponse (responseCode = "400" , description = "요청 값 유효성 검사 실패" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "유효성 검사 실패" , value = "{ \" code\" : \" C007\" , \" message\" : \" 요청한 값이 올바르지 않습니다.\" }" ))),
32+ @ ApiResponse (responseCode = "401" , description = "인증되지 않은 사용자" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "인증 실패" , value = "{ \" code\" : \" C001\" , \" message\" : \" 인증되지 않은 사용자입니다.\" }" ))),
33+ @ ApiResponse (responseCode = "403" , description = "접근 권한 없음 (ADMIN이 아님)" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "권한 없음" , value = "{ \" code\" : \" C002\" , \" message\" : \" 접근 권한이 없습니다.\" }" ))),
34+ @ ApiResponse (responseCode = "500" , description = "서버 내부 오류" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "서버 문제 발생" , value = "{ \" code\" : \" C009\" , \" message\" : \" 서버에 문제가 발생하였습니다.\" }" )))
35+ })
36+ @ PostMapping
37+ public ResponseEntity <ActivityHistoryResponseDto > createHistory (@ Valid @ RequestBody ActivityHistoryRequestDto requestDto ) {
38+ return ResponseEntity .status (201 ).body (historyService .createHistory (requestDto ));
39+ }
40+
41+ @ Operation (summary = "활동 연혁 수정" )
42+ @ ApiResponses (value = {
43+ @ ApiResponse (responseCode = "200" , description = "활동 연혁 수정 성공" ),
44+ @ ApiResponse (responseCode = "400" , description = "요청 값 유효성 검사 실패" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "유효성 검사 실패" , value = "{ \" code\" : \" C007\" , \" message\" : \" 요청한 값이 올바르지 않습니다.\" }" ))),
45+ @ ApiResponse (responseCode = "401" , description = "인증되지 않은 사용자" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "인증 실패" , value = "{ \" code\" : \" C001\" , \" message\" : \" 인증되지 않은 사용자입니다.\" }" ))),
46+ @ ApiResponse (responseCode = "403" , description = "접근 권한 없음 (ADMIN이 아님)" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "권한 없음" , value = "{ \" code\" : \" C002\" , \" message\" : \" 접근 권한이 없습니다.\" }" ))),
47+ @ ApiResponse (responseCode = "404" , description = "수정할 리소스를 찾을 수 없음" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "조회 결과 없음" , value = "{ \" code\" : \" C010\" , \" message\" : \" 해당 리소스를 찾을 수 없습니다.\" }" ))),
48+ @ ApiResponse (responseCode = "500" , description = "서버 내부 오류" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "서버 문제 발생" , value = "{ \" code\" : \" C009\" , \" message\" : \" 서버에 문제가 발생하였습니다.\" }" )))
49+ })
50+ @ PutMapping ("/{id}" )
51+ public ResponseEntity <ActivityHistoryResponseDto > updateHistory (
52+ @ PathVariable @ Min (1 ) Long id ,
53+ @ Valid @ RequestBody ActivityHistoryRequestDto requestDto
54+ ) {
55+ return ResponseEntity .ok (historyService .updateHistory (id , requestDto ));
56+ }
57+
58+ @ Operation (summary = "활동 연혁 삭제" )
59+ @ ApiResponses (value = {
60+ @ ApiResponse (responseCode = "200" , description = "활동 연혁 삭제 성공" ),
61+ @ ApiResponse (responseCode = "401" , description = "인증되지 않은 사용자" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "인증 실패" , value = "{ \" code\" : \" C001\" , \" message\" : \" 인증되지 않은 사용자입니다.\" }" ))),
62+ @ ApiResponse (responseCode = "403" , description = "접근 권한 없음 (ADMIN이 아님)" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "권한 없음" , value = "{ \" code\" : \" C002\" , \" message\" : \" 접근 권한이 없습니다.\" }" ))),
63+ @ ApiResponse (responseCode = "404" , description = "삭제할 리소스를 찾을 수 없음" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "조회 결과 없음" , value = "{ \" code\" : \" C010\" , \" message\" : \" 해당 리소스를 찾을 수 없습니다.\" }" ))),
64+ @ ApiResponse (responseCode = "500" , description = "서버 내부 오류" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ErrorResponse .class ), examples = @ ExampleObject (name = "서버 문제 발생" , value = "{ \" code\" : \" C009\" , \" message\" : \" 서버에 문제가 발생하였습니다.\" }" )))
65+ })
66+ @ DeleteMapping ("/{id}" )
67+ public ResponseEntity <Void > deleteHistory (@ PathVariable Long id ) {
68+ historyService .deleteHistory (id );
69+ return ResponseEntity .noContent ().build (); // 삭제 성공 시에는 204 No Content가 더 명확합니다.
70+ }
71+ }
0 commit comments