-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 제휴 지도 & 신고 기능 수정 사항 (20250930) #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
7f3e134
3c69397
dbc6a3b
038e015
9e01f01
42ca468
237efea
379c3cf
547eaf1
5c5752a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,21 @@ | ||
| package ssu.eatssu.domain.report.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
| import ssu.eatssu.domain.review.entity.Report; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public interface ReportRepository extends JpaRepository<Report, Long> { | ||
|
|
||
| @Query(""" | ||
| SELECT CASE WHEN COUNT(r) > 0 THEN true ELSE false END | ||
| FROM Report r | ||
| WHERE r.user.id = :userId | ||
| AND r.review.id = :reviewId | ||
| AND r.createdDate >= CURRENT_TIMESTAMP - 1 | ||
| """) | ||
| boolean existsRecentReport(@Param("userId") Long userId, | ||
| @Param("reviewId") Long reviewId); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,8 +17,7 @@ | |||||||||||||
| import ssu.eatssu.global.handler.response.BaseException; | ||||||||||||||
| import ssu.eatssu.global.log.event.LogEvent; | ||||||||||||||
|
|
||||||||||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_REVIEW; | ||||||||||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_USER; | ||||||||||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.*; | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 스타일 가이드 3번 규칙에 따라 와일드카드(
Suggested change
Style Guide ReferencesFootnotes
|
||||||||||||||
|
|
||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||
| @Service | ||||||||||||||
|
|
@@ -37,6 +36,10 @@ public Report reportReview(CustomUserDetails userDetails, ReportCreateRequest re | |||||||||||||
| Review review = reviewRepository.findById(request.reviewId()) | ||||||||||||||
| .orElseThrow(() -> new BaseException(NOT_FOUND_REVIEW)); | ||||||||||||||
|
|
||||||||||||||
| if(reportRepository.existsRecentReport(user.getId(),review.getId())){ | ||||||||||||||
| throw new BaseException(RECENT_REPORT_ON_REVIEW); | ||||||||||||||
| } | ||||||||||||||
|
||||||||||||||
| if(reportRepository.existsRecentReport(user.getId(),review.getId())){ | |
| throw new BaseException(RECENT_REPORT_ON_REVIEW); | |
| } | |
| if(reportRepository.existsRecentReport(user.getId(), review.getId(), java.time.LocalDateTime.now().minusHours(24))){ | |
| throw new BaseException(RECENT_REPORT_ON_REVIEW); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JPQL 쿼리에 두 가지 개선점을 제안합니다.
SELECT CASE WHEN COUNT(r) > 0 THEN true ELSE false END구문은SELECT COUNT(r) > 0으로 단순화할 수 있습니다. Spring Data JPA가 이 결과를boolean으로 올바르게 처리합니다.r.createdDate >= CURRENT_TIMESTAMP - 1과 같은 날짜/시간 연산은 JPQL 표준이 아니며, 사용하는 데이터베이스(H2, MySQL, PostgreSQL 등)에 따라 다르게 동작할 수 있어 이식성을 해칠 수 있습니다. 서비스 레이어에서 시간 임계값(예: 24시간 전)을 계산하여 파라미터로 전달하는 것이 더 안정적이고 명확한 방법입니다.아래와 같이 메서드 시그니처와 쿼리를 수정하는 것을 권장합니다. 이 변경은
ReportService에서의 호출 방식 수정도 필요합니다.