Skip to content

Commit 68bd357

Browse files
committed
Feat: 장소 사진 여러 장 수정 추가
1 parent 8f3a2b4 commit 68bd357

8 files changed

Lines changed: 156 additions & 136 deletions

File tree

src/main/java/devkor/com/teamcback/domain/place/controller/AdminPlaceController.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
import devkor.com.teamcback.domain.place.dto.request.CreatePlaceReq;
44
import devkor.com.teamcback.domain.place.dto.request.ModifyPlaceReq;
5-
import devkor.com.teamcback.domain.place.dto.response.CreatePlaceRes;
6-
import devkor.com.teamcback.domain.place.dto.response.DeletePlaceRes;
7-
import devkor.com.teamcback.domain.place.dto.response.GetPlaceListRes;
8-
import devkor.com.teamcback.domain.place.dto.response.ModifyPlaceRes;
5+
import devkor.com.teamcback.domain.place.dto.response.*;
96
import devkor.com.teamcback.domain.place.service.AdminPlaceService;
10-
import devkor.com.teamcback.domain.suggestion.dto.response.SavePlaceImageRes;
117
import devkor.com.teamcback.global.response.CommonResponse;
128
import io.swagger.v3.oas.annotations.Operation;
139
import io.swagger.v3.oas.annotations.Parameter;
@@ -18,9 +14,6 @@
1814
import jakarta.validation.Valid;
1915
import lombok.RequiredArgsConstructor;
2016
import org.springframework.web.bind.annotation.*;
21-
import org.springframework.web.multipart.MultipartFile;
22-
23-
import java.util.List;
2417

2518
@RestController
2619
@RequiredArgsConstructor
@@ -89,25 +82,4 @@ public CommonResponse<DeletePlaceRes> deletePlace(
8982
@Parameter(description = "삭제할 편의시설 ID") @PathVariable Long placeId) {
9083
return CommonResponse.success(adminPlaceService.deletePlace(placeId));
9184
}
92-
93-
// @PostMapping(value = "/{placeId}/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
94-
@Operation(summary = "장소 사진 저장", description = "장소 사진 저장(첫 사진이 대표 사진)")
95-
@ApiResponses(value = {
96-
@ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."),
97-
@ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.",
98-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
99-
@ApiResponse(responseCode = "401", description = "권한이 없습니다.",
100-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
101-
@ApiResponse(responseCode = "403", description = "잘못된 입력입니다.",
102-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
103-
})
104-
public CommonResponse<SavePlaceImageRes> savePlaceImages(
105-
@Parameter(name = "placeId", description = "장소 ID")
106-
@PathVariable Long placeId,
107-
@Parameter(description = "저장할 사진 파일")
108-
@RequestPart("images") List<MultipartFile> images
109-
) {
110-
return CommonResponse.success(
111-
adminPlaceService.savePlaceImage(placeId, images));
112-
}
11385
}
Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package devkor.com.teamcback.domain.place.controller;
22

3-
import devkor.com.teamcback.domain.place.dto.response.DeletePlaceImageRes;
4-
import devkor.com.teamcback.domain.place.dto.response.ModifyPlaceImageRes;
5-
import devkor.com.teamcback.domain.place.dto.response.SavePlaceImageRes;
6-
import devkor.com.teamcback.domain.place.dto.response.SearchPlaceImageRes;
3+
import devkor.com.teamcback.domain.place.dto.response.*;
74
import devkor.com.teamcback.domain.place.service.AdminPlaceImageService;
85
import devkor.com.teamcback.global.response.CommonResponse;
96
import io.swagger.v3.oas.annotations.Operation;
@@ -18,27 +15,26 @@
1815
import org.springframework.web.bind.annotation.GetMapping;
1916
import org.springframework.web.bind.annotation.PathVariable;
2017
import org.springframework.web.bind.annotation.PostMapping;
21-
import org.springframework.web.bind.annotation.PutMapping;
2218
import org.springframework.web.bind.annotation.RequestMapping;
2319
import org.springframework.web.bind.annotation.RequestPart;
2420
import org.springframework.web.bind.annotation.RestController;
2521
import org.springframework.web.multipart.MultipartFile;
2622

23+
import java.util.List;
24+
2725
@RestController
2826
@RequiredArgsConstructor
2927
@RequestMapping("/api/admin/places")
3028
public class AdminPlaceImageController {
3129
private final AdminPlaceImageService adminPlaceImageService;
3230

3331
@PostMapping(value = "/{placeId}/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
34-
@Operation(summary = "장소 사진 저장",
35-
description = "장소 사진 저장")
32+
@Operation(summary = "장소 사진 1장 추가",
33+
description = "장소 사진 1장 추가 저장")
3634
@ApiResponses(value = {
3735
@ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."),
3836
@ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.",
3937
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
40-
@ApiResponse(responseCode = "409", description = "해당 장소의 이미지가 이미 존재합니다.",
41-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
4238
@ApiResponse(responseCode = "401", description = "권한이 없습니다.",
4339
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
4440
})
@@ -49,26 +45,26 @@ public CommonResponse<SavePlaceImageRes> savePlaceImage(
4945
return CommonResponse.success(adminPlaceImageService.savePlaceImage(placeId, image));
5046
}
5147

52-
@PutMapping(value = "/{placeId}/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
53-
@Operation(summary = "장소 사진 수정",
54-
description = "장소 사진 수정")
48+
@PostMapping(value = "/{placeId}/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
49+
@Operation(summary = "장소 사진 여러장 새로 저장",
50+
description = "기존 장소 사진 전체 삭제 후 사진 여러장 새로 저장")
5551
@ApiResponses(value = {
56-
@ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."),
57-
@ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.",
58-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
59-
@ApiResponse(responseCode = "401", description = "권한이 없습니다.",
60-
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
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))),
6157
})
62-
public CommonResponse<ModifyPlaceImageRes> modifyPlaceImage(
63-
@Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId,
64-
@Parameter(description = "수정할 사진 파일") @RequestPart("image") MultipartFile image
58+
public CommonResponse<SavePlaceImageRes> savePlaceImageList(
59+
@Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId,
60+
@Parameter(description = "저장할 사진 파일 목록") @RequestPart("image") List<MultipartFile> images
6561
) {
66-
return CommonResponse.success(adminPlaceImageService.modifyPlaceImage(placeId, image));
62+
return CommonResponse.success(adminPlaceImageService.savePlaceImageList(placeId, images));
6763
}
6864

69-
@DeleteMapping(value = "/{placeId}/image")
70-
@Operation(summary = "장소 사진 삭제",
71-
description = "장소 사진 삭제")
65+
@DeleteMapping(value = "/{placeId}/images")
66+
@Operation(summary = "장소 사진 전체 삭제",
67+
description = "장소 사진 전체 삭제")
7268
@ApiResponses(value = {
7369
@ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."),
7470
@ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.",
@@ -83,18 +79,34 @@ public CommonResponse<DeletePlaceImageRes> deletePlaceImage(
8379
}
8480

8581
@GetMapping("/{placeId}/image")
86-
@Operation(summary = "장소 사진 검색",
87-
description = "장소 사진 검색")
82+
@Operation(summary = "장소 사진 1장 검색",
83+
description = "장소 사진 1장 검색")
8884
@ApiResponses(value = {
8985
@ApiResponse(responseCode = "200", description = "정상 처리 되었습니다."),
9086
@ApiResponse(responseCode = "404", description = "장소를 찾을 수 없습니다.",
9187
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
9288
@ApiResponse(responseCode = "401", description = "권한이 없습니다.",
9389
content = @Content(schema = @Schema(implementation = CommonResponse.class))),
9490
})
95-
public CommonResponse<SearchPlaceImageRes> getPlaceImage(
91+
public CommonResponse<GetPlaceImageRes> getPlaceImage(
9692
@Parameter(name = "placeId", description = "장소 ID") @PathVariable Long placeId
9793
) {
9894
return CommonResponse.success(adminPlaceImageService.searchPlaceImage(placeId));
9995
}
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+
}
100112
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package devkor.com.teamcback.domain.place.dto.response;
2+
3+
import devkor.com.teamcback.domain.place.entity.Place;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
import lombok.Getter;
6+
7+
@Schema(description = "장소 사진 검색 응답 dto")
8+
@Getter
9+
public class GetPlaceImageRes {
10+
private Long placeId;
11+
private String placeName;
12+
private String image;
13+
14+
public GetPlaceImageRes(Place place) {
15+
this.placeId = place.getId();
16+
this.placeName = place.getName();
17+
this.image = place.getImageUrl();
18+
}
19+
20+
public GetPlaceImageRes(Place place, String image) {
21+
this.placeId = place.getId();
22+
this.placeName = place.getName();
23+
this.image = image;
24+
}
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package devkor.com.teamcback.domain.place.dto.response;
2+
3+
import devkor.com.teamcback.domain.place.entity.Place;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
import lombok.Getter;
6+
7+
import java.util.List;
8+
9+
@Schema(description = "장소 사진 리스트 응답 dto")
10+
@Getter
11+
public class SearchPlaceImageListRes {
12+
private Long placeId;
13+
private String placeName;
14+
private List<SearchPlaceImageRes> imageList;
15+
16+
public SearchPlaceImageListRes(Place place, List<SearchPlaceImageRes> imageList) {
17+
this.placeId = place.getId();
18+
this.placeName = place.getName();
19+
this.imageList = imageList;
20+
}
21+
}

src/main/java/devkor/com/teamcback/domain/place/dto/response/SearchPlaceImageRes.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@
77
@Schema(description = "장소 사진 검색 응답 dto")
88
@Getter
99
public class SearchPlaceImageRes {
10-
private Long placeId;
11-
private String placeName;
1210
private String image;
11+
private Long sortNum;
1312

1413
public SearchPlaceImageRes(Place place) {
15-
this.placeId = place.getId();
16-
this.placeName = place.getName();
1714
this.image = place.getImageUrl();
15+
this.sortNum = 1L;
1816
}
1917

20-
public SearchPlaceImageRes(Place place, String image) {
21-
this.placeId = place.getId();
22-
this.placeName = place.getName();
18+
public SearchPlaceImageRes(String image, Long sortNum) {
2319
this.image = image;
20+
this.sortNum = sortNum;
2421
}
2522
}

0 commit comments

Comments
 (0)