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