From 815f6970fbc09b365ecd3497cb71b15cb0ba45e0 Mon Sep 17 00:00:00 2001 From: junwon Date: Thu, 5 Sep 2024 23:04:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20:=20=ED=9A=8C=EC=9B=90=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=8B=9C=20=EB=A6=AC=EB=B7=B0=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jpa/review/repository/ReviewJpaRepository.java | 6 ++++++ .../jpa/review/repository/ReviewRepositoryImpl.java | 5 +++++ .../spot/usecase/port/in/review/DeleteReviewUsecase.java | 2 ++ .../spot/usecase/port/out/review/ReviewRepository.java | 2 ++ .../spot/usecase/service/member/MemberService.java | 7 +++++++ .../spot/usecase/service/review/DeleteReviewService.java | 5 +++++ 6 files changed, 27 insertions(+) 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); From b2d0ec44cbef6b690b52e6c12d83843d2afdb86b Mon Sep 17 00:00:00 2001 From: junwon Date: Sun, 8 Sep 2024 15:40:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor=20:=20jwtToken=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20prod=EC=97=90=EC=84=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spot/application/member/controller/JwtCreateController.java | 2 ++ 1 file changed, 2 insertions(+) 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;