Skip to content

Commit

Permalink
fix: BearEats에 대한 리뷰 작성 가능 조건 추가 및 리뷰 작성 서비스 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Jan 5, 2024
1 parent f26c999 commit 88c6642
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ public interface WithDankookRepository<T extends WithDankook> extends JpaReposit
@Query(value = "select COUNT(*) from with_dankook w " +
"where w.with_dankook_id = :withDankookId and " +
"((w.with_dankook_status in ('FULL', 'CLOSED')) or (w.with_dankook_status = 'ACTIVE' and w.end_time <= CURRENT_TIMESTAMP())) ", nativeQuery = true)
int findWithClosedOrFullOrActiveByIdToCreateReview(@Param("withDankookId") Long withDankookId);
int findWithClosedOrFullOrActiveEndTimeByIdToCreateReview(@Param("withDankookId") Long withDankookId);

@Query(value = "select COUNT(*) from with_dankook w " +
"where w.with_dankook_id = :withDankookId and " +
"((w.with_dankook_status in ('FULL', 'CLOSED')) or (w.with_dankook_status = 'ACTIVE' and w.delivery_time <= CURRENT_TIMESTAMP())) ", nativeQuery = true)
int findWithClosedOrFullOrActiveDeliveryTimeByIdToCreateReview(@Param("withDankookId") Long withDankookId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,28 @@ public interface PostResultMapper<T, D, E extends WithDankook> {
public void isPossibleCreateReview(Long withDankookId) {
String withDankookType = withDankookRepository.findWithDankookType(withDankookId);

if (withDankookType.equals("Trade")) {
if (withDankookRepository.findWithClosedByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
// } else if (withDankookType.equals("Study") || withDankookType.equals("Dormitory")) {
// if (withDankookRepository.findWithClosedOrFullOrActiveByIdToCreateReview(withDankookId) != 1) {
// throw new InvalidStatusException();
// }
} else if (withDankookType.equals("BearEats") || withDankookType.equals("EatingAlong")) {
if (withDankookRepository.findWithClosedOrFullByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
switch (withDankookType) {
case "Trade":
case "Roommate":
if (withDankookRepository.findWithClosedByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
break;
case "Study":
if (withDankookRepository.findWithClosedOrFullOrActiveEndTimeByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
break;
case "EatingAlong":
if (withDankookRepository.findWithClosedOrFullByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
break;
case "BearEats":
if (withDankookRepository.findWithClosedOrFullOrActiveDeliveryTimeByIdToCreateReview(withDankookId) != 1) {
throw new InvalidStatusException();
}
break;
}
}
}

0 comments on commit 88c6642

Please sign in to comment.