-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-246] 카드셋 삭제 API #58
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/project/flipnote/bookmark/service/BookmarkWriter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package project.flipnote.bookmark.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import project.flipnote.bookmark.entity.BookmarkTargetType; | ||
| import project.flipnote.bookmark.repository.BookmarkRepository; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class BookmarkWriter { | ||
| private final BookmarkRepository bookmarkRepository; | ||
|
|
||
| /** | ||
| * 즐겨찾기를 삭제합니다. | ||
| * | ||
| * @param targetType 즐겨찾기 삭제할 대상의 타입 | ||
| * @param targetId 즐겨찾기 삭제할 대상의 ID | ||
| * @author 윤정환 | ||
| */ | ||
| public void delete(BookmarkTargetType targetType, Long targetId) { | ||
| bookmarkRepository.deleteByTargetTypeAndTargetId(targetType, targetId); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/project/flipnote/cardset/entity/CardSetContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package project.flipnote.cardset.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Lob; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import project.flipnote.common.entity.BaseEntity; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Table(name = "cardset_contents") | ||
| @Entity | ||
| public class CardSetContent extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "cardset_id", nullable = false) | ||
| private Long cardSetId; | ||
|
|
||
| @Lob | ||
| @Column(nullable = false) | ||
| private String content; | ||
|
|
||
| @Builder | ||
| private CardSetContent(Long cardSetId, String content) { | ||
| this.cardSetId = cardSetId; | ||
| this.content = content; | ||
| } | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
src/main/java/project/flipnote/cardset/entity/CardSetIncremental.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package project.flipnote.cardset.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Lob; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import project.flipnote.common.entity.BaseEntity; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Table(name = "cardset_incrementals") | ||
| @Entity | ||
| public class CardSetIncremental extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "cardset_id", nullable = false) | ||
| private Long cardSetId; | ||
|
|
||
| @Lob | ||
| @Column(name = "incremental_value", nullable = false) | ||
| private byte[] incrementalValue; | ||
|
|
||
| @Column(name = "is_flushed") | ||
| private boolean flushed; | ||
|
|
||
| @Builder | ||
| private CardSetIncremental(Long cardSetId, byte[] incrementalValue, boolean flushed) { | ||
| this.cardSetId = cardSetId; | ||
| this.incrementalValue = incrementalValue; | ||
| this.flushed = flushed; | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/project/flipnote/cardset/repository/CardSetContentRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package project.flipnote.cardset.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import project.flipnote.cardset.entity.CardSetContent; | ||
|
|
||
| public interface CardSetContentRepository extends JpaRepository<CardSetContent, Long> { | ||
| void deleteByCardSetId(Long cardSetId); | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/project/flipnote/cardset/repository/CardSetIncrementalRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package project.flipnote.cardset.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import project.flipnote.cardset.entity.CardSetIncremental; | ||
|
|
||
| public interface CardSetIncrementalRepository extends JpaRepository<CardSetIncremental, Long> { | ||
| void deleteByCardSetId(Long cardSetId); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.bookmark.entity.BookmarkTargetType; | ||
| import project.flipnote.bookmark.service.BookmarkReader; | ||
| import project.flipnote.bookmark.service.BookmarkService; | ||
| import project.flipnote.bookmark.service.BookmarkWriter; | ||
| import project.flipnote.cardset.entity.CardSet; | ||
| import project.flipnote.cardset.entity.CardSetManager; | ||
| import project.flipnote.cardset.entity.CardSetMetadata; | ||
|
|
@@ -25,10 +25,13 @@ | |
| import project.flipnote.cardset.model.CardSetUpdateRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetResponse; | ||
| import project.flipnote.cardset.repository.CardSetContentRepository; | ||
| import project.flipnote.cardset.repository.CardSetIncrementalRepository; | ||
| import project.flipnote.cardset.repository.CardSetManagerRepository; | ||
| import project.flipnote.cardset.repository.CardSetMetadataRepository; | ||
| import project.flipnote.cardset.repository.CardSetRepository; | ||
| import project.flipnote.common.exception.BizException; | ||
| import project.flipnote.common.model.response.IdResponse; | ||
| import project.flipnote.common.model.response.PagingResponse; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
| import project.flipnote.group.entity.Category; | ||
|
|
@@ -44,6 +47,7 @@ | |
| import project.flipnote.image.service.ImageService; | ||
| import project.flipnote.like.entity.LikeTargetType; | ||
| import project.flipnote.like.service.LikeReader; | ||
| import project.flipnote.like.service.LikeWriter; | ||
| import project.flipnote.user.entity.UserProfile; | ||
| import project.flipnote.user.entity.UserStatus; | ||
| import project.flipnote.user.exception.UserErrorCode; | ||
|
|
@@ -67,6 +71,10 @@ public class CardSetService { | |
| private final GroupService groupService; | ||
| private final LikeReader likeReader; | ||
| private final BookmarkReader bookmarkReader; | ||
| private final LikeWriter likeWriter; | ||
| private final BookmarkWriter bookmarkWriter; | ||
| private final CardSetContentRepository cardSetContentRepository; | ||
| private final CardSetIncrementalRepository cardSetIncrementalRepository; | ||
|
|
||
| @Value("${image.default.cardSet}") | ||
| private String defaultCardSetImage; | ||
|
|
@@ -357,4 +365,40 @@ public PagingResponse<CardSetSummaryResponse> getCardSets(long groupId, CardSetS | |
|
|
||
| return PagingResponse.from(res); | ||
| } | ||
|
|
||
| @Transactional | ||
| public IdResponse deleteCardSet(Long userId, Long groupId, Long cardSetId) { | ||
| CardSet cardSet = cardSetPolicyService.findByIdAndGroupIdOrThrow(groupId, cardSetId); | ||
|
|
||
| cardSetPolicyService.validateCardSetEditable(userId, cardSetId); | ||
|
|
||
| // 카드셋 관리자 | ||
| cardSetManagerRepository.deleteByCardSet_Id(cardSetId); | ||
|
|
||
| // 카드셋 내용 | ||
| cardSetContentRepository.deleteByCardSetId(cardSetId); | ||
|
|
||
| // 카드셋 증분값 | ||
| cardSetIncrementalRepository.deleteByCardSetId(cardSetId); | ||
|
|
||
| // 카드셋 스냅샷 | ||
|
|
||
|
Comment on lines
+384
to
+385
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CardSetSnapshot 삭제 로직을 구현하거나 TODO로 명확히 표시하세요. 카드셋 스냅샷 삭제가 주석 처리되어 있어 해당 데이터가 고아 데이터로 남을 수 있습니다. 스냅샷 기능이 아직 구현되지 않았다면 TODO 주석을 추가하고, 구현되었다면 삭제 로직을 추가해야 합니다. 스냅샷 삭제 구현이 필요하다면 코드를 생성해드릴 수 있습니다. 필요하신가요? 🤖 Prompt for AI Agents |
||
| // 카드셋 메타데이터 | ||
| cardSetMetadataRepository.deleteById(cardSetId); | ||
|
|
||
| // 이미지 | ||
| imageRefService.findByTypeAndReferenceId(REFERENCE_TYPE, cardSetId) | ||
| .ifPresent(imageRef -> imageRefService.deleteByReferenceAndId(REFERENCE_TYPE, imageRef.getId())); | ||
|
|
||
| // 카드셋 | ||
| cardSetRepository.delete(cardSet); | ||
|
|
||
| // 좋아요 | ||
| likeWriter.delete(LikeTargetType.CARD_SET, cardSetId); | ||
|
|
||
| // 즐겨찾기 | ||
| bookmarkWriter.delete(BookmarkTargetType.CARD_SET, cardSetId); | ||
|
|
||
| return IdResponse.from(cardSetId); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/project/flipnote/like/service/LikeWriter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package project.flipnote.like.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import project.flipnote.like.entity.LikeTargetType; | ||
| import project.flipnote.like.repository.LikeRepository; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class LikeWriter { | ||
| private final LikeRepository likeRepository; | ||
|
|
||
| /** | ||
| * 좋아요를 삭제합니다. | ||
| * | ||
| * @param targetType 좋아요 삭제 대상의 타입 | ||
| * @param targetId 좋아요 삭제 대상의 ID | ||
| * @author 윤정환 | ||
| */ | ||
| public void delete(LikeTargetType targetType, Long targetId) { | ||
| likeRepository.deleteByTargetTypeAndTargetId(targetType, targetId); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.