Skip to content

Commit c870456

Browse files
refactor: @Modifying repository 메서드명에 bulk prefix 추가
1 parent 42367fb commit c870456

35 files changed

Lines changed: 72 additions & 75 deletions

backend/bom-bom-server/src/main/java/me/bombom/api/v1/article/repository/ArticleRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public interface ArticleRepository extends JpaRepository<Article, Long>, CustomA
1616

1717
@Modifying(clearAutomatically = true, flushAutomatically = true)
1818
@Query("DELETE FROM Article a WHERE a.memberId = :memberId")
19-
void deleteAllByMemberId(Long memberId);
19+
void bulkDeleteAllByMemberId(Long memberId);
2020

2121
long countByIdInAndMemberId(List<Long> ids, Long memberId);
2222

2323
@Modifying(clearAutomatically = true)
2424
@Query("DELETE FROM Article a WHERE a.id IN :ids AND a.memberId = :memberId")
25-
void deleteAllByIdsAndMemberId(@Param("ids") List<Long> ids, @Param("memberId") Long memberId);
25+
void bulkDeleteAllByIdsAndMemberId(@Param("ids") List<Long> ids, @Param("memberId") Long memberId);
2626

2727
/**
2828
* 관리자의 모든 article을 previous_article로 복사
@@ -52,7 +52,7 @@ AND NOT EXISTS (
5252
AND pa.arrived_date_time = a.arrived_date_time
5353
)
5454
""", nativeQuery = true)
55-
int safeCopyToArchive(@Param("adminId") Long adminId);
55+
int bulkSafeCopyToArchive(@Param("adminId") Long adminId);
5656

5757
/**
5858
* 뉴스레터별로 최신 N개만 남기고 나머지 삭제
@@ -80,7 +80,7 @@ AND EXISTS (
8080
AND pa.arrived_date_time = a.arrived_date_time
8181
)
8282
""", nativeQuery = true)
83-
int safeDeleteArchived(
83+
int bulkSafeDeleteArchived(
8484
@Param("adminId") Long adminId,
8585
@Param("keepCount") int keepCount
8686
);
@@ -114,7 +114,7 @@ AND r.authority IN ('ADMIN', 'USER')
114114
WHERE ranked.row_num > ranked.keep_limit
115115
) target ON target.id = a.id
116116
""", nativeQuery = true)
117-
int deleteExcessUnbookmarkedArticles(@Param("adminLimit") int adminLimit, @Param("userLimit") int userLimit);
117+
int bulkDeleteExcessUnbookmarkedArticles(@Param("adminLimit") int adminLimit, @Param("userLimit") int userLimit);
118118

119119
@Query("""
120120
SELECT new me.bombom.api.v1.challenge.dto.response.ChallengeCommentCandidateArticleResponse(

backend/bom-bom-server/src/main/java/me/bombom/api/v1/article/repository/PreviousArticleRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ WHERE id IN (
107107
WHERE keep_order > :keepCount
108108
)
109109
""", nativeQuery = true)
110-
int cleanupOldPreviousArticles(@Param("keepCount") int keepCount);
110+
int bulkCleanupOldPreviousArticles(@Param("keepCount") int keepCount);
111111
}

backend/bom-bom-server/src/main/java/me/bombom/api/v1/article/repository/RecentArticleRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ public interface RecentArticleRepository extends JpaRepository<RecentArticle, Lo
1111

1212
@Modifying(clearAutomatically = true)
1313
@Query("DELETE FROM RecentArticle ra WHERE ra.arrivedDateTime < :cutoffDateTime")
14-
int deleteAllByArrivedDateTimeBefore(@Param("cutoffDateTime") LocalDateTime cutoffDateTime);
14+
int bulkDeleteAllByArrivedDateTimeBefore(@Param("cutoffDateTime") LocalDateTime cutoffDateTime);
1515
}
16-

backend/bom-bom-server/src/main/java/me/bombom/api/v1/article/service/ArticleService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ public List<ArticleHighlightResponse> getHighlights(Member member, Long articleI
139139

140140
@Transactional(propagation = Propagation.REQUIRES_NEW)
141141
public void deleteAllByMemberId(Long memberId) {
142-
articleRepository.deleteAllByMemberId(memberId);
142+
articleRepository.bulkDeleteAllByMemberId(memberId);
143143
}
144144

145145
@Transactional
146146
public int cleanupOldRecentArticles() {
147147
LocalDateTime fiveDaysAgo = LocalDateTime.now().minusDays(5);
148-
return recentArticleRepository.deleteAllByArrivedDateTimeBefore(fiveDaysAgo);
148+
return recentArticleRepository.bulkDeleteAllByArrivedDateTimeBefore(fiveDaysAgo);
149149
}
150150

151151
@Transactional
@@ -159,14 +159,14 @@ public void delete(Member member, DeleteArticlesRequest request) {
159159
.addContext(ErrorContextKeys.OPERATION, "deleteArticles")
160160
.addContext(ErrorContextKeys.ARTICLE_ID, request.articleIds());
161161
}
162-
bookmarkRepository.deleteAllByArticleIds(target);
163-
highlightRepository.updateArticleDeleted(target);
164-
articleRepository.deleteAllByIdsAndMemberId(target, member.getId());
162+
bookmarkRepository.bulkDeleteAllByArticleIds(target);
163+
highlightRepository.bulkUpdateArticleDeleted(target);
164+
articleRepository.bulkDeleteAllByIdsAndMemberId(target, member.getId());
165165
}
166166

167167
@Transactional
168168
public int cleanupExcessArticles(int adminRetainLimit, int userRetainLimit) {
169-
return articleRepository.deleteExcessUnbookmarkedArticles(adminRetainLimit, userRetainLimit);
169+
return articleRepository.bulkDeleteExcessUnbookmarkedArticles(adminRetainLimit, userRetainLimit);
170170
}
171171

172172
private Article findArticleById(Long articleId, Long memberId) {

backend/bom-bom-server/src/main/java/me/bombom/api/v1/article/service/PreviousArticleService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public PreviousArticleDetailResponse getPreviousArticleDetail(Long id, Member me
7171

7272
@Transactional
7373
public int cleanupOldPreviousArticles() {
74-
int deleted = previousArticleRepository.cleanupOldPreviousArticles(PREVIOUS_ARTICLE_KEEP_COUNT);
74+
int deleted = previousArticleRepository.bulkCleanupOldPreviousArticles(PREVIOUS_ARTICLE_KEEP_COUNT);
7575
log.info("previous_article 정리 완료: {}건 삭제 (isFixed=false)", deleted);
7676
return deleted;
7777
}
@@ -83,8 +83,8 @@ public void moveAdminArticles() {
8383
.addContext(ErrorContextKeys.ENTITY_TYPE, "member")
8484
.addContext(ErrorContextKeys.OPERATION, "moveAdminArticles"));
8585

86-
int copied = articleRepository.safeCopyToArchive(archiveAdminId);
87-
int deleted = articleRepository.safeDeleteArchived(archiveAdminId, PREVIOUS_ARTICLE_KEEP_COUNT);
86+
int copied = articleRepository.bulkSafeCopyToArchive(archiveAdminId);
87+
int deleted = articleRepository.bulkSafeDeleteArchived(archiveAdminId, PREVIOUS_ARTICLE_KEEP_COUNT);
8888
log.info("아티클 이동 완료: {}건 복사, {}건 삭제 (adminId: {})", copied, deleted, archiveAdminId);
8989
}
9090

backend/bom-bom-server/src/main/java/me/bombom/api/v1/bookmark/repository/BookmarkRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public interface BookmarkRepository extends JpaRepository<Bookmark, Long>, Custo
1616

1717
@Modifying(clearAutomatically = true, flushAutomatically = true)
1818
@Query("DELETE FROM Bookmark b WHERE b.memberId = :memberId")
19-
void deleteAllByMemberId(Long memberId);
19+
void bulkDeleteAllByMemberId(Long memberId);
2020

2121
@Modifying(clearAutomatically = true)
2222
@Query("DELETE FROM Bookmark b WHERE b.articleId IN (:articleIds)")
23-
void deleteAllByArticleIds(List<Long> articleIds);
23+
void bulkDeleteAllByArticleIds(List<Long> articleIds);
2424
}

backend/bom-bom-server/src/main/java/me/bombom/api/v1/bookmark/service/BookmarkService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import me.bombom.api.v1.article.domain.Article;
77
import me.bombom.api.v1.article.repository.ArticleRepository;
88
import me.bombom.api.v1.bookmark.domain.Bookmark;
9-
import me.bombom.api.v1.bookmark.dto.response.BookmarkResponse;
10-
import me.bombom.api.v1.bookmark.dto.response.BookmarkStatusResponse;
119
import me.bombom.api.v1.bookmark.dto.response.BookmarkCountPerNewsletterResponse;
1210
import me.bombom.api.v1.bookmark.dto.response.BookmarkNewsletterStatisticsResponse;
11+
import me.bombom.api.v1.bookmark.dto.response.BookmarkResponse;
12+
import me.bombom.api.v1.bookmark.dto.response.BookmarkStatusResponse;
1313
import me.bombom.api.v1.bookmark.repository.BookmarkRepository;
1414
import me.bombom.api.v1.common.exception.CIllegalArgumentException;
1515
import me.bombom.api.v1.common.exception.ErrorContextKeys;
@@ -88,7 +88,7 @@ public BookmarkNewsletterStatisticsResponse getBookmarkNewsletterStatistics(Memb
8888

8989
@Transactional(propagation = Propagation.REQUIRES_NEW)
9090
public void deleteAllByMemberId(Long memberId) {
91-
bookmarkRepository.deleteAllByMemberId(memberId);
91+
bookmarkRepository.bulkDeleteAllByMemberId(memberId);
9292
}
9393

9494
private void validateArticleOwner(Long memberId, Article article) {

backend/bom-bom-server/src/main/java/me/bombom/api/v1/challenge/repository/ChallengeCommentLikeRepository.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public interface ChallengeCommentLikeRepository extends JpaRepository<ChallengeC
99

1010
@Modifying
1111
@Query(value = """
12-
INSERT IGNORE INTO challenge_comment_like (participant_id, comment_id)
13-
VALUES (:participantId, :commentId)
14-
""", nativeQuery = true)
15-
int insertIgnoreByParticipantIdAndCommentId(Long participantId, Long commentId);
12+
INSERT IGNORE INTO challenge_comment_like (participant_id, comment_id)
13+
VALUES (:participantId, :commentId)
14+
""", nativeQuery = true)
15+
int bulkInsertIgnoreByParticipantIdAndCommentId(Long participantId, Long commentId);
1616

1717
boolean existsByParticipantIdAndCommentId(Long participantId, Long commentId);
1818

backend/bom-bom-server/src/main/java/me/bombom/api/v1/challenge/repository/ChallengeCommentRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ Page<ChallengeCommentResponse> findAllInDuration(
7878
WHERE c.id = :commentId
7979
AND ( :amount >= 0 OR c.likeCount > 0 )
8080
""")
81-
void incrementLikeCountNotBelowZero(Long commentId, int amount);
81+
void bulkIncrementLikeCountNotBelowZero(Long commentId, int amount);
8282

8383
@Modifying(flushAutomatically = true)
8484
@Query("""
8585
UPDATE ChallengeComment c
8686
SET c.replyCount = c.replyCount + 1
8787
WHERE c.id = :commentId
8888
""")
89-
void updateReplyCount(Long commentId);
89+
void bulkUpdateReplyCount(Long commentId);
9090
}

backend/bom-bom-server/src/main/java/me/bombom/api/v1/challenge/repository/ChallengeDailyTodoRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ OR EXISTS (
3434
)
3535
)
3636
""", nativeQuery = true)
37-
int insertTodayReadTodoIfMissing(
37+
int bulkInsertTodayReadTodoIfMissing(
3838
@Param("memberId") Long memberId,
3939
@Param("articleId") Long articleId,
4040
@Param("today") LocalDate today,

0 commit comments

Comments
 (0)