-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: 안쓰는 코드 정리 * fix: review 도메인 내의 member가 아닌 result의 member 객체를 사용하도록 변경 * refactor: usecase 반환형 레코드 ReviewResult->ReadReviewResult 네이밍 변경 * feat: update 로직을 위해 from 메서드에 id 세팅하는 부분 추가 * feat: 키워드가 수정됐을 때 blockTopKeyword 테이블의 데이터도 수정되도록 메서드 구현 * feat: 리뷰 업데이트 로직 구현 * feat: 필수 필드에 @NotNull 어노테이션 추가 * feat: ReviewResult->CreateReviewResult로 네이밍 롤백.. * feat: UpdateReviewResult 다시 부활 * feat: reviewId에 @NotNull 추가 * feat: list에 @NotNull 대신 @SiZe(minn1, max=3)추가 * feat: max값 10에서 3으로 변경 * feat: blocktopkeyword 를 업데이트하는 부분을 foreach가 아닌 batch 업데이트로 수정 * fix: 새로 들어온 keyword들에 대해서 blocktopkeyword 테이블에 새로운 레코드를 생성하도록 수정
- Loading branch information
1 parent
16105c2
commit 8108efb
Showing
18 changed files
with
354 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
application/src/main/java/org/depromeet/spot/application/review/UpdateReviewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.depromeet.spot.application.review; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import org.depromeet.spot.application.common.annotation.CurrentMember; | ||
import org.depromeet.spot.application.review.dto.request.UpdateReviewRequest; | ||
import org.depromeet.spot.application.review.dto.response.BaseReviewResponse; | ||
import org.depromeet.spot.usecase.port.in.review.UpdateReviewUsecase; | ||
import org.depromeet.spot.usecase.port.in.review.UpdateReviewUsecase.UpdateReviewResult; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "리뷰") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class UpdateReviewController { | ||
|
||
private final UpdateReviewUsecase updateReviewUsecase; | ||
|
||
@CurrentMember | ||
@ResponseStatus(HttpStatus.OK) | ||
@PutMapping("/reviews/{reviewId}") | ||
@Operation(summary = "특정 리뷰를 수정한다.") | ||
public BaseReviewResponse updateReview( | ||
@Parameter(hidden = true) Long memberId, | ||
@PathVariable("reviewId") @NotNull @Parameter(description = "리뷰 PK", required = true) | ||
Long reviewId, | ||
@RequestBody @Valid UpdateReviewRequest request) { | ||
|
||
UpdateReviewResult result = | ||
updateReviewUsecase.updateReview(memberId, reviewId, request.toCommand()); | ||
|
||
return BaseReviewResponse.from(result.review()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../src/main/java/org/depromeet/spot/application/review/dto/request/UpdateReviewRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.depromeet.spot.application.review.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
import java.util.List; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
|
||
import org.depromeet.spot.common.exception.review.ReviewException.InvalidReviewDateTimeFormatException; | ||
import org.depromeet.spot.common.exception.review.ReviewException.InvalidReviewKeywordsException; | ||
import org.depromeet.spot.usecase.port.in.review.UpdateReviewUsecase.UpdateReviewCommand; | ||
|
||
public record UpdateReviewRequest( | ||
@NotNull Long blockId, | ||
@NotNull Integer seatNumber, | ||
@Size(min = 1, max = 3) List<String> images, | ||
List<String> good, | ||
List<String> bad, | ||
String content, | ||
@NotNull String dateTime) { | ||
|
||
public UpdateReviewCommand toCommand() { | ||
validateGoodAndBad(); | ||
return UpdateReviewCommand.builder() | ||
.blockId(blockId) | ||
.seatNumber(seatNumber) | ||
.images(images) | ||
.good(good) | ||
.bad(bad) | ||
.content(content) | ||
.dateTime(toLocalDateTime(dateTime)) | ||
.build(); | ||
} | ||
|
||
private void validateGoodAndBad() { | ||
if ((good == null || good.isEmpty()) && (bad == null || bad.isEmpty())) { | ||
throw new InvalidReviewKeywordsException(); | ||
} | ||
} | ||
|
||
private LocalDateTime toLocalDateTime(String dateTimeStr) { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
try { | ||
return LocalDateTime.parse(dateTimeStr, formatter); | ||
} catch (DateTimeParseException e) { | ||
throw new InvalidReviewDateTimeFormatException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
...ava/org/depromeet/spot/jpa/review/repository/keyword/BlockTopKeywordCustomRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...c/main/java/org/depromeet/spot/jpa/review/repository/keyword/KeywordCustomRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/UpdateReviewUsecase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.depromeet.spot.usecase.port.in.review; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import org.depromeet.spot.domain.review.Review; | ||
|
||
import lombok.Builder; | ||
|
||
public interface UpdateReviewUsecase { | ||
UpdateReviewResult updateReview(Long memberId, Long reviewId, UpdateReviewCommand command); | ||
|
||
@Builder | ||
record UpdateReviewCommand( | ||
Long blockId, | ||
Integer seatNumber, | ||
List<String> images, | ||
List<String> good, | ||
List<String> bad, | ||
String content, | ||
LocalDateTime dateTime) {} | ||
|
||
record UpdateReviewResult(Review review) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.