From c0109da6d2c6e563d92bddfea7648677b069c905 Mon Sep 17 00:00:00 2001 From: sangeun Date: Thu, 22 Aug 2024 20:18:35 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=A6=AC=EB=B7=B0=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20controller=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../locavel/web/controller/ReviewRestController.java | 7 +++---- .../locavel/web/dto/ReviewDTO/ReviewRequestDTO.java | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/locavel/web/controller/ReviewRestController.java b/src/main/java/com/example/locavel/web/controller/ReviewRestController.java index c281540..861f69a 100644 --- a/src/main/java/com/example/locavel/web/controller/ReviewRestController.java +++ b/src/main/java/com/example/locavel/web/controller/ReviewRestController.java @@ -36,9 +36,8 @@ public class ReviewRestController { @PostMapping(value = "/{placeId}", consumes = "multipart/form-data") public ApiResponse createReview( HttpServletRequest httpServletRequest, - @Valid @RequestPart(value = "request") ReviewRequestDTO.ReviewDTO request, - @PathVariable(name="placeId") Long placeId, - @RequestPart(value = "img", required = false) List img) { + @ModelAttribute ReviewRequestDTO.ReviewDTO request, + @PathVariable(name="placeId") Long placeId) { if(request.getRating() == null) { throw new ReviewsHandler(ErrorStatus.RATING_NOT_EXIST); } @@ -49,7 +48,7 @@ public ApiResponse createReview( User user = userCommandService.getUser(httpServletRequest); Long userId = user.getId(); userCommandService.calculateTravelerGradeScore(userId ,request); //여행객 점수를 증가시키는 로직 - ReviewResponseDTO.ReviewResultDTO response = reviewService.createReview(user, placeId, request, img); + ReviewResponseDTO.ReviewResultDTO response = reviewService.createReview(user, placeId, request, request.getImg()); return ApiResponse.of(SuccessStatus.REVIEW_CREATE_OK,response); } diff --git a/src/main/java/com/example/locavel/web/dto/ReviewDTO/ReviewRequestDTO.java b/src/main/java/com/example/locavel/web/dto/ReviewDTO/ReviewRequestDTO.java index 5488dbd..83275e3 100644 --- a/src/main/java/com/example/locavel/web/dto/ReviewDTO/ReviewRequestDTO.java +++ b/src/main/java/com/example/locavel/web/dto/ReviewDTO/ReviewRequestDTO.java @@ -3,6 +3,9 @@ import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; public class ReviewRequestDTO { @Getter @@ -11,5 +14,6 @@ public static class ReviewDTO { String comment; @NotNull Float rating; + List img; } }