|
| 1 | +package devkor.com.teamcback.domain.place.controller; |
| 2 | + |
| 3 | +import devkor.com.teamcback.domain.place.dto.response.*; |
| 4 | +import devkor.com.teamcback.domain.place.service.AdminPlaceImageService; |
| 5 | +import devkor.com.teamcback.global.response.CommonResponse; |
| 6 | +import io.swagger.v3.oas.annotations.Operation; |
| 7 | +import io.swagger.v3.oas.annotations.Parameter; |
| 8 | +import io.swagger.v3.oas.annotations.media.Content; |
| 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 lombok.RequiredArgsConstructor; |
| 13 | +import org.springframework.http.MediaType; |
| 14 | +import org.springframework.web.bind.annotation.DeleteMapping; |
| 15 | +import org.springframework.web.bind.annotation.GetMapping; |
| 16 | +import org.springframework.web.bind.annotation.PathVariable; |
| 17 | +import org.springframework.web.bind.annotation.PostMapping; |
| 18 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 19 | +import org.springframework.web.bind.annotation.RequestPart; |
| 20 | +import org.springframework.web.bind.annotation.RestController; |
| 21 | +import org.springframework.web.multipart.MultipartFile; |
| 22 | + |
| 23 | +import java.util.List; |
| 24 | + |
| 25 | +@RestController |
| 26 | +@RequiredArgsConstructor |
| 27 | +@RequestMapping("/api/admin/places") |
| 28 | +public class AdminPlaceImageController { |
| 29 | + private final AdminPlaceImageService adminPlaceImageService; |
| 30 | + |
| 31 | + @PostMapping(value = "/{placeId}/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| 32 | + @Operation(summary = "장소 사진 1장 추가", |
| 33 | + description = "장소 사진 1장 추가 저장") |
| 34 | + @ApiResponses(value = { |
| 35 | + @ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."), |
| 36 | + @ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.", |
| 37 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 38 | + @ApiResponse(responseCode = "401", description = "권한이 없습니다.", |
| 39 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 40 | + }) |
| 41 | + public CommonResponse<SavePlaceImageRes> savePlaceImage( |
| 42 | + @Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId, |
| 43 | + @Parameter(description = "저장할 사진 파일") @RequestPart("image") MultipartFile image |
| 44 | + ) { |
| 45 | + return CommonResponse.success(adminPlaceImageService.savePlaceImage(placeId, image)); |
| 46 | + } |
| 47 | + |
| 48 | + @PostMapping(value = "/{placeId}/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| 49 | + @Operation(summary = "장소 사진 여러장 새로 저장", |
| 50 | + description = "기존 장소 사진 전체 삭제 후 사진 여러장 새로 저장") |
| 51 | + @ApiResponses(value = { |
| 52 | + @ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."), |
| 53 | + @ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.", |
| 54 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 55 | + @ApiResponse(responseCode = "401", description = "권한이 없습니다.", |
| 56 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 57 | + }) |
| 58 | + public CommonResponse<SavePlaceImageRes> savePlaceImageList( |
| 59 | + @Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId, |
| 60 | + @Parameter(description = "저장할 사진 파일 목록") @RequestPart("image") List<MultipartFile> images |
| 61 | + ) { |
| 62 | + return CommonResponse.success(adminPlaceImageService.savePlaceImageList(placeId, images)); |
| 63 | + } |
| 64 | + |
| 65 | + @DeleteMapping(value = "/{placeId}/images") |
| 66 | + @Operation(summary = "장소 사진 전체 삭제", |
| 67 | + description = "장소 사진 전체 삭제") |
| 68 | + @ApiResponses(value = { |
| 69 | + @ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."), |
| 70 | + @ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.", |
| 71 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 72 | + @ApiResponse(responseCode = "401", description = "권한이 없습니다.", |
| 73 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 74 | + }) |
| 75 | + public CommonResponse<DeletePlaceImageRes> deletePlaceImage( |
| 76 | + @Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId |
| 77 | + ) { |
| 78 | + return CommonResponse.success(adminPlaceImageService.deletePlaceImage(placeId)); |
| 79 | + } |
| 80 | + |
| 81 | + @GetMapping("/{placeId}/image") |
| 82 | + @Operation(summary = "장소 사진 1장 검색", |
| 83 | + description = "장소 사진 1장 검색") |
| 84 | + @ApiResponses(value = { |
| 85 | + @ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."), |
| 86 | + @ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.", |
| 87 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 88 | + @ApiResponse(responseCode = "401", description = "권한이 없습니다.", |
| 89 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 90 | + }) |
| 91 | + public CommonResponse<GetPlaceImageRes> getPlaceImage( |
| 92 | + @Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId |
| 93 | + ) { |
| 94 | + return CommonResponse.success(adminPlaceImageService.searchPlaceImage(placeId)); |
| 95 | + } |
| 96 | + |
| 97 | + @GetMapping("/{placeId}/images") |
| 98 | + @Operation(summary = "장소 사진 여러 장 검색", |
| 99 | + description = "장소 사진 여러 장 검색") |
| 100 | + @ApiResponses(value = { |
| 101 | + @ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."), |
| 102 | + @ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.", |
| 103 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 104 | + @ApiResponse(responseCode = "401", description = "권한이 없습니다.", |
| 105 | + content = @Content(schema = @Schema(implementation = CommonResponse.class))), |
| 106 | + }) |
| 107 | + public CommonResponse<SearchPlaceImageListRes> getPlaceImageList( |
| 108 | + @Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId |
| 109 | + ) { |
| 110 | + return CommonResponse.success(adminPlaceImageService.searchPlaceImageList(placeId)); |
| 111 | + } |
| 112 | +} |
0 commit comments