diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/ReadReviewUsecase.java b/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/ReadReviewUsecase.java index f95a84d4..74bcbec2 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/ReadReviewUsecase.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/ReadReviewUsecase.java @@ -32,6 +32,8 @@ MyReviewListResult findMyReviewsByUserId( long countByIdByMemberId(Long memberId); + long countByMember(Long memberId); + @Builder record BlockReviewListResult( LocationInfo location, diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/CreateReviewService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/CreateReviewService.java index d3a7947a..6ac97c9f 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/CreateReviewService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/CreateReviewService.java @@ -12,6 +12,7 @@ import org.depromeet.spot.domain.seat.Seat; import org.depromeet.spot.usecase.port.in.member.UpdateMemberUsecase; import org.depromeet.spot.usecase.port.in.review.CreateReviewUsecase; +import org.depromeet.spot.usecase.port.in.review.ReadReviewUsecase; import org.depromeet.spot.usecase.port.out.member.MemberRepository; import org.depromeet.spot.usecase.port.out.review.BlockTopKeywordRepository; import org.depromeet.spot.usecase.port.out.review.KeywordRepository; @@ -34,6 +35,7 @@ public class CreateReviewService implements CreateReviewUsecase { private final KeywordRepository keywordRepository; private final BlockTopKeywordRepository blockTopKeywordRepository; private final UpdateMemberUsecase updateMemberUsecase; + private final ReadReviewUsecase readReviewUsecase; @Override @Transactional @@ -78,7 +80,7 @@ private Review convertToDomain(Seat seat, Member member, CreateReviewCommand com } public Member calculateMemberLevel(final Member member) { - final long memberReviewCnt = reviewRepository.countByUserId(member.getId()); + final long memberReviewCnt = readReviewUsecase.countByMember(member.getId()); return updateMemberUsecase.updateLevel(member, memberReviewCnt); } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/DeleteReviewService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/DeleteReviewService.java index 9ff15a7a..60b796f7 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/DeleteReviewService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/DeleteReviewService.java @@ -1,6 +1,10 @@ package org.depromeet.spot.usecase.service.review; +import org.depromeet.spot.domain.member.Member; +import org.depromeet.spot.usecase.port.in.member.ReadMemberUsecase; +import org.depromeet.spot.usecase.port.in.member.UpdateMemberUsecase; import org.depromeet.spot.usecase.port.in.review.DeleteReviewUsecase; +import org.depromeet.spot.usecase.port.in.review.ReadReviewUsecase; import org.depromeet.spot.usecase.port.out.review.ReviewRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,10 +16,21 @@ public class DeleteReviewService implements DeleteReviewUsecase { private final ReviewRepository reviewRepository; + private final ReadReviewUsecase readReviewUsecase; + private final UpdateMemberUsecase updateMemberUsecase; + private final ReadMemberUsecase readMemberUsecase; @Override @Transactional public Long deleteReview(Long reviewId, Long memberId) { - return reviewRepository.softDeleteByIdAndMemberId(reviewId, memberId); + Long deletedReviewId = reviewRepository.softDeleteByIdAndMemberId(reviewId, memberId); + updateMemberLevel(memberId); + return deletedReviewId; + } + + public void updateMemberLevel(Long memberId) { + Member member = readMemberUsecase.findById(memberId); + long reviewCnt = readReviewUsecase.countByMember(memberId); + updateMemberUsecase.updateLevel(member, reviewCnt); } } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java index fe0ac441..0c7eb462 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java @@ -139,6 +139,11 @@ public long countByIdByMemberId(Long memberId) { return reviewRepository.countByIdByMemberId(memberId); } + @Override + public long countByMember(Long memberId) { + return reviewRepository.countByUserId(memberId); + } + @Override public MyRecentReviewResult findLastReviewByMemberId(Long memberId) { Review review = reviewRepository.findLastReviewByMemberId(memberId);