From abe1d8b401ae900fda4eec98458f4fc873b2e8ba Mon Sep 17 00:00:00 2001 From: qlido Date: Wed, 10 Apr 2024 11:27:19 +0900 Subject: [PATCH 1/2] refactor(docs): delete ThumbsUp when Docs delete --- .../docs/service/DocsDeleteService.java | 3 +++ .../domain/repository/ThumbsUpRepository.java | 4 ++++ .../implementation/ThumbsUpDeleter.java | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/main/java/com/project/bumawiki/domain/thumbsup/implementation/ThumbsUpDeleter.java diff --git a/src/main/java/com/project/bumawiki/domain/docs/service/DocsDeleteService.java b/src/main/java/com/project/bumawiki/domain/docs/service/DocsDeleteService.java index 7178cd6..b0b616c 100644 --- a/src/main/java/com/project/bumawiki/domain/docs/service/DocsDeleteService.java +++ b/src/main/java/com/project/bumawiki/domain/docs/service/DocsDeleteService.java @@ -4,6 +4,7 @@ import org.springframework.transaction.annotation.Transactional; import com.project.bumawiki.domain.docs.implementation.DocsDeleter; +import com.project.bumawiki.domain.thumbsup.implementation.ThumbsUpDeleter; import lombok.RequiredArgsConstructor; @@ -12,8 +13,10 @@ @RequiredArgsConstructor public class DocsDeleteService { private final DocsDeleter docsDeleter; + private final ThumbsUpDeleter thumbsUpDeleter; public void execute(Long id) { docsDeleter.delete(id); + thumbsUpDeleter.deleteAllByDocsId(id); } } diff --git a/src/main/java/com/project/bumawiki/domain/thumbsup/domain/repository/ThumbsUpRepository.java b/src/main/java/com/project/bumawiki/domain/thumbsup/domain/repository/ThumbsUpRepository.java index e5276c2..2633157 100644 --- a/src/main/java/com/project/bumawiki/domain/thumbsup/domain/repository/ThumbsUpRepository.java +++ b/src/main/java/com/project/bumawiki/domain/thumbsup/domain/repository/ThumbsUpRepository.java @@ -1,5 +1,7 @@ package com.project.bumawiki.domain.thumbsup.domain.repository; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; import com.project.bumawiki.domain.docs.domain.Docs; @@ -11,4 +13,6 @@ public interface ThumbsUpRepository extends JpaRepository { Boolean existsByDocs_IdAndUser(Long docsId, User user); void deleteByDocsAndUser(Docs docs, User user); + + List findByDocs_Id(Long docsId); } diff --git a/src/main/java/com/project/bumawiki/domain/thumbsup/implementation/ThumbsUpDeleter.java b/src/main/java/com/project/bumawiki/domain/thumbsup/implementation/ThumbsUpDeleter.java new file mode 100644 index 0000000..0e1213d --- /dev/null +++ b/src/main/java/com/project/bumawiki/domain/thumbsup/implementation/ThumbsUpDeleter.java @@ -0,0 +1,20 @@ +package com.project.bumawiki.domain.thumbsup.implementation; + +import java.util.List; + +import com.project.bumawiki.domain.thumbsup.domain.ThumbsUp; +import com.project.bumawiki.domain.thumbsup.domain.repository.ThumbsUpRepository; +import com.project.bumawiki.global.annotation.Implementation; + +import lombok.RequiredArgsConstructor; + +@Implementation +@RequiredArgsConstructor +public class ThumbsUpDeleter { + private final ThumbsUpRepository thumbsUpRepository; + + public void deleteAllByDocsId(Long docsId) { + List thumbsUps = thumbsUpRepository.findByDocs_Id(docsId); + thumbsUpRepository.deleteAllInBatch(thumbsUps); + } +} From 3537e38a081f7c624ab51708504b02d98e039775 Mon Sep 17 00:00:00 2001 From: qlido Date: Wed, 10 Apr 2024 11:35:37 +0900 Subject: [PATCH 2/2] chore(convention): allowed merge commit message --- setting/convention.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setting/convention.gradle b/setting/convention.gradle index ec77ae2..9de0980 100644 --- a/setting/convention.gradle +++ b/setting/convention.gradle @@ -29,4 +29,8 @@ githook { // task = "check" } } +} + +conventionalCommits { + ignoreCommitMessage = ".*(merge|Merge).*" } \ No newline at end of file