diff --git a/application/src/main/java/org/depromeet/spot/application/member/controller/JwtCreateController.java b/application/src/main/java/org/depromeet/spot/application/member/controller/JwtCreateController.java index 6f06404f..e326fc94 100644 --- a/application/src/main/java/org/depromeet/spot/application/member/controller/JwtCreateController.java +++ b/application/src/main/java/org/depromeet/spot/application/member/controller/JwtCreateController.java @@ -4,6 +4,7 @@ import org.depromeet.spot.application.member.dto.response.JwtTokenResponse; import org.depromeet.spot.domain.member.Member; import org.depromeet.spot.domain.member.enums.MemberRole; +import org.springframework.context.annotation.Profile; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,6 +20,7 @@ @Slf4j @Tag(name = "Jwt 생성용") @RequestMapping("/api/v1/jwts") +@Profile("!prod") public class JwtCreateController { private final JwtTokenUtil jwtTokenUtil; diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewJpaRepository.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewJpaRepository.java index fbfe8c21..d1bc03f9 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewJpaRepository.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewJpaRepository.java @@ -42,6 +42,12 @@ int softDeleteByIdAndMemberId( @Param("memberId") Long memberId, @Param("deletedAt") LocalDateTime deletedAt); + @Modifying + @Query( + "UPDATE ReviewEntity r SET r.deletedAt = :deletedAt WHERE r.member.id = :memberId AND r.deletedAt IS NULL") + void softDeleteAllReviewOwnedByMemberId( + @Param("memberId") Long memberId, @Param("deletedAt") LocalDateTime deletedAt); + @Query( "SELECT r FROM ReviewEntity r WHERE r.member.id = :memberId " + "AND r.deletedAt IS NULL " diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewRepositoryImpl.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewRepositoryImpl.java index f3d6ac3d..0b5ca275 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewRepositoryImpl.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/review/repository/ReviewRepositoryImpl.java @@ -118,6 +118,11 @@ public Long softDeleteByIdAndMemberId(Long reviewId, Long memberId) { return reviewId; } + @Override + public void softDeleteAllReviewOwnedByMemberId(Long memberId) { + reviewJpaRepository.softDeleteAllReviewOwnedByMemberId(memberId, LocalDateTime.now()); + } + @Override public LocationInfo findLocationInfoByStadiumIdAndBlockCode(Long stadiumId, String blockCode) { return reviewCustomRepository.findLocationInfoByStadiumIdAndBlockCode(stadiumId, blockCode); diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/DeleteReviewUsecase.java b/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/DeleteReviewUsecase.java index 72f62c00..3e26d056 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/DeleteReviewUsecase.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/port/in/review/DeleteReviewUsecase.java @@ -3,4 +3,6 @@ public interface DeleteReviewUsecase { Long deleteReview(Long reviewId, Long memberId); + + void deleteAllReviewOwnedByMemberId(Long memberId); } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/port/out/review/ReviewRepository.java b/usecase/src/main/java/org/depromeet/spot/usecase/port/out/review/ReviewRepository.java index 306a9b19..c3c2e177 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/port/out/review/ReviewRepository.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/port/out/review/ReviewRepository.java @@ -46,6 +46,8 @@ List findAllByUserId( Long softDeleteByIdAndMemberId(Long reviewId, Long memberId); + void softDeleteAllReviewOwnedByMemberId(Long memberId); + LocationInfo findLocationInfoByStadiumIdAndBlockCode(Long stadiumId, String blockCode); Review findLastReviewByMemberId(Long memberId); diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/member/MemberService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/member/MemberService.java index 92804f1a..28b49bf1 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/member/MemberService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/member/MemberService.java @@ -13,6 +13,7 @@ import org.depromeet.spot.usecase.port.in.member.MemberUsecase; import org.depromeet.spot.usecase.port.in.member.ReadMemberUsecase; import org.depromeet.spot.usecase.port.in.member.level.ReadLevelUsecase; +import org.depromeet.spot.usecase.port.in.review.DeleteReviewUsecase; import org.depromeet.spot.usecase.port.in.review.ReadReviewUsecase; import org.depromeet.spot.usecase.port.in.team.ReadBaseballTeamUsecase; import org.depromeet.spot.usecase.port.out.member.MemberRepository; @@ -32,6 +33,7 @@ public class MemberService implements MemberUsecase { private final ReadMemberUsecase readMemberUsecase; private final ReadLevelUsecase readLevelUsecase; private final ReadBaseballTeamUsecase readBaseballTeamUsecase; + private final DeleteReviewUsecase deleteReviewUsecase; private final ReadReviewUsecase readReviewUsecase; @@ -106,8 +108,13 @@ public MemberInfo findMemberInfo(Long memberId) { return MemberInfo.of(member, baseballTeam, reviewCntToLevelUp); } + @Transactional @Override public void softDelete(Long memberId) { + + // 멤버 삭제 전 리뷰 삭제가 우선이 되어야함! + deleteReviewUsecase.deleteAllReviewOwnedByMemberId(memberId); + memberRepository.updateDeletedAt(memberId, LocalDateTime.now()); } } 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 60b796f7..08e06fb4 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 @@ -28,6 +28,11 @@ public Long deleteReview(Long reviewId, Long memberId) { return deletedReviewId; } + @Override + public void deleteAllReviewOwnedByMemberId(Long memberId) { + reviewRepository.softDeleteAllReviewOwnedByMemberId(memberId); + } + public void updateMemberLevel(Long memberId) { Member member = readMemberUsecase.findById(memberId); long reviewCnt = readReviewUsecase.countByMember(memberId);