Fix: review 충돌 에러 해결

This commit is contained in:
UNGGU0704 2025-06-18 13:06:05 +09:00
parent 7deb2ce39d
commit 0d8b4d177c
2 changed files with 7 additions and 9 deletions

View File

@ -185,16 +185,14 @@ public class ExternalReviewEventHubAdapter {
*/ */
private Review saveExternalReview(Long storeId, String platform, Map<String, Object> reviewData) { private Review saveExternalReview(Long storeId, String platform, Map<String, Object> reviewData) {
try { try {
// 1. 중복 체크용 고유 식별자 생성
String externalNickname = createMemberNickname(platform, reviewData);
String content = extractContent(reviewData); String content = extractContent(reviewData);
// 2. 중복 체크 (storeId + 닉네임 + 내용으로 중복 판단) boolean isDuplicate = reviewJpaRepository.existsByStoreIdAndContent(
boolean isDuplicate = reviewJpaRepository.existsByStoreIdAndMemberNicknameAndContent( storeId, content);
storeId, externalNickname, content);
if (isDuplicate) { if (isDuplicate) {
log.debug("중복 리뷰 스킵: storeId={}, nickname={}", storeId, externalNickname); log.debug("중복 리뷰 스킵: storeId={}, nickname={}", storeId);
return null; return null;
} }

View File

@ -35,12 +35,12 @@ public interface ReviewJpaRepository extends JpaRepository<ReviewEntity, Long> {
/** /**
* 중복 리뷰 체크 (매장ID + 닉네임 + 내용으로 판단) * 수정: 매장ID + 내용으로 중복 리뷰 체크
*/ */
boolean existsByStoreIdAndMemberNicknameAndContent(Long storeId, String memberNickname, String content); boolean existsByStoreIdAndContent(Long storeId, String content);
/** /**
* 대안: 외부 닉네임으로만 중복 체크 ( 간단한 방법) * 대안: 외부 닉네임으로만 중복 체크 ( 간단한 방법)
*/ */
boolean existsByStoreIdAndExternalNickname(Long storeId, String externalNickname); // boolean existsByStoreIdAndExternalNickname(Long storeId, String externalNickname);
} }