Skip to content

Commit 2f5c555

Browse files
committed
refactor: 삭제 메서드로 사용자 연관 데이터를 삭제하도록
1 parent 46df0f3 commit 2f5c555

File tree

18 files changed

+113
-90
lines changed

18 files changed

+113
-90
lines changed

src/main/java/com/example/solidconnection/application/repository/ApplicationRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ default Application getApplicationBySiteUserIdAndTermId(long siteUserId, long te
4040
return findBySiteUserIdAndTermId(siteUserId, termId)
4141
.orElseThrow(() -> new CustomException(APPLICATION_NOT_FOUND));
4242
}
43+
44+
void deleteAllBySiteUserId(long siteUserId);
4345
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
package com.example.solidconnection.chat.repository;
22

33
import com.example.solidconnection.chat.domain.ChatParticipant;
4+
import java.util.List;
45
import java.util.Optional;
56
import org.springframework.data.jpa.repository.JpaRepository;
7+
import org.springframework.data.jpa.repository.Query;
8+
import org.springframework.data.repository.query.Param;
69

710
public interface ChatParticipantRepository extends JpaRepository<ChatParticipant, Long> {
811

912
boolean existsByChatRoomIdAndSiteUserId(long chatRoomId, long siteUserId);
1013

1114
Optional<ChatParticipant> findByChatRoomIdAndSiteUserId(long chatRoomId, long siteUserId);
15+
16+
void deleteAllBySiteUserId(long siteUserId);
17+
18+
@Query("SELECT cp.id FROM ChatParticipant cp WHERE cp.siteUserId = :siteUserId")
19+
List<Long> findAllIdsBySiteUserId(@Param("siteUserId") long siteUserId);
1220
}

src/main/java/com/example/solidconnection/chat/repository/ChatReadStatusRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.solidconnection.chat.repository;
22

33
import com.example.solidconnection.chat.domain.ChatReadStatus;
4+
import java.util.List;
45
import org.springframework.data.jpa.repository.JpaRepository;
56
import org.springframework.data.jpa.repository.Modifying;
67
import org.springframework.data.jpa.repository.Query;
@@ -15,4 +16,6 @@ INSERT INTO chat_read_status (chat_room_id, chat_participant_id, created_at, upd
1516
ON DUPLICATE KEY UPDATE updated_at = NOW(6)
1617
""", nativeQuery = true)
1718
void upsertReadStatus(@Param("chatRoomId") long chatRoomId, @Param("chatParticipantId") long chatParticipantId);
19+
20+
void deleteAllByChatParticipantIdIn(List<Long> chatParticipantIds);
1821
}

src/main/java/com/example/solidconnection/community/comment/repository/CommentRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ default Comment getById(Long id) {
4242
return findById(id)
4343
.orElseThrow(() -> new CustomException(INVALID_COMMENT_ID));
4444
}
45+
46+
void deleteAllBySiteUserId(long siteUserId);
4547
}

src/main/java/com/example/solidconnection/community/post/repository/PostLikeRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ default PostLike getByPostAndSiteUserId(Post post, long siteUserId) {
1616
return findPostLikeByPostAndSiteUserId(post, siteUserId)
1717
.orElseThrow(() -> new CustomException(INVALID_POST_LIKE));
1818
}
19+
20+
void deleteAllBySiteUserId(long siteUserId);
1921
}

src/main/java/com/example/solidconnection/community/post/repository/PostRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ default Post getById(Long id) {
5959
return findById(id)
6060
.orElseThrow(() -> new CustomException(INVALID_POST_ID));
6161
}
62+
63+
void deleteAllBySiteUserId(long siteUserId);
6264
}

src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
public interface MentorApplicationRepository extends JpaRepository<MentorApplication, Long> {
99

1010
boolean existsBySiteUserIdAndMentorApplicationStatusIn(long siteUserId, List<MentorApplicationStatus> mentorApplicationStatuses);
11+
12+
void deleteAllBySiteUserId(long siteUserId);
1113
}

src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ public interface MentorRepository extends JpaRepository<Mentor, Long> {
2727
Slice<Mentor> findAllByRegion(@Param("region") Region region, Pageable pageable);
2828

2929
List<Mentor> findAllBySiteUserIdIn(Set<Long> siteUserIds);
30+
31+
void deleteAllBySiteUserId(long siteUserId);
3032
}

src/main/java/com/example/solidconnection/mentor/repository/MentoringRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ public interface MentoringRepository extends JpaRepository<Mentoring, Long> {
3939

4040
@Query("SELECT m FROM Mentoring m WHERE m.menteeId = :menteeId AND m.verifyStatus = :verifyStatus")
4141
Slice<Mentoring> findApprovedMentoringsByMenteeId(long menteeId, @Param("verifyStatus") VerifyStatus verifyStatus, Pageable pageable);
42+
43+
void deleteAllByMenteeId(long menteeId);
4244
}

src/main/java/com/example/solidconnection/news/repository/LikedNewsRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ public interface LikedNewsRepository extends JpaRepository<LikedNews, Long> {
99
boolean existsByNewsIdAndSiteUserId(long newsId, long siteUserId);
1010

1111
Optional<LikedNews> findByNewsIdAndSiteUserId(long newsId, long siteUserId);
12+
13+
void deleteAllBySiteUserId(long siteUserId);
1214
}

0 commit comments

Comments
 (0)