Skip to content
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

[BSVR-254] 탈퇴 시 리뷰 삭제 구현 #190

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,6 +20,7 @@
@Slf4j
@Tag(name = "Jwt 생성용")
@RequestMapping("/api/v1/jwts")
@Profile("!prod")
public class JwtCreateController {

private final JwtTokenUtil jwtTokenUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
public interface DeleteReviewUsecase {

Long deleteReview(Long reviewId, Long memberId);

void deleteAllReviewOwnedByMemberId(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ List<Review> findAllByUserId(

Long softDeleteByIdAndMemberId(Long reviewId, Long memberId);

void softDeleteAllReviewOwnedByMemberId(Long memberId);

LocationInfo findLocationInfoByStadiumIdAndBlockCode(Long stadiumId, String blockCode);

Review findLastReviewByMemberId(Long memberId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading