Skip to content

Conversation

@dungbik
Copy link
Contributor

@dungbik dungbik commented Jan 23, 2026

📝 변경 내용


✅ 체크리스트

  • 코드가 정상적으로 동작함
  • 테스트 코드 통과함
  • 문서(README 등)를 최신화함
  • 코드 스타일 가이드 준수

💬 기타 참고 사항

Summary by CodeRabbit

  • New Features
    • 그룹 내 카드셋 목록 조회 및 카드셋 삭제 API 추가
    • 카드셋 생성/수정 시 관리자 지정 기능 도입(최소 1명 필수)
    • 카드셋 작성자 정보 저장 기능 추가
    • 관리자 일괄 할당·갱신 및 관리 연산 개선으로 관리자 관리 흐름 개선

✏️ Tip: You can customize this high-level summary in your review settings.

@dungbik dungbik self-assigned this Jan 23, 2026
@dungbik dungbik added the enhancement New feature or request label Jan 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

CardSet에 작성자(author) 필드를 추가하고, 매니저 할당/업데이트 로직을 CardSetManagerWriter 서비스로 옮기며 관련 요청 모델(Create/Update)에 managers 필드를 도입하고 저장소에 매니저 조회/삭제 메서드를 추가했습니다. 또한 API 문서화 인터페이스에 getCardSets 및 deleteCardSet 시그니처가 추가되었습니다.

Changes

Cohort / File(s) 변경 요약
API 문서화
src/main/java/project/flipnote/cardset/controller/docs/GroupCardSetControllerDocs.java
getCardSets(Long, CardSetSearchRequest)deleteCardSet(Long, Long, AuthPrinciple) 공개 메서드 추가; 관련 응답/요청 타입 임포트 추가
엔티티
src/main/java/project/flipnote/cardset/entity/CardSet.java
author 필드(Long, @Column(nullable = false)) 추가; 생성자 시그니처에 author 인자 추가 및 초기화 반영
요청 모델
src/main/java/project/flipnote/cardset/model/CreateCardSetRequest.java, src/main/java/project/flipnote/cardset/model/CardSetUpdateRequest.java
managers 필드 추가(Set<Long>, @NotEmpty @SiZe(min = 1)) 및 관련 import 변경
저장소
src/main/java/project/flipnote/cardset/repository/CardSetManagerRepository.java
Set<Long> findUserIdsByCardSetId(Long) 쿼리 메서드 추가; int deleteByCardSet_IdAndUser_IdIn(Long, Set<Long>) 삭제 메서드 추가
서비스
src/main/java/project/flipnote/cardset/service/CardSetManagerWriter.java, src/main/java/project/flipnote/cardset/service/CardSetService.java
새 서비스 CardSetManagerWriter 추가(관리자 할당/업데이트 로직 캡슐화). CardSetService에서 직접 생성/삭제하던 매니저 로직을 해당 서비스 호출로 대체 및 author 설정 반영

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant CardSetService
    participant CardSetManagerWriter
    participant CardSetManagerRepository
    participant Database

    Client->>CardSetService: createCardSet(CreateCardSetRequest)
    CardSetService->>CardSetService: build CardSet entity (includes author)
    CardSetService->>CardSetManagerWriter: assignManagers(cardSet, managerIds)
    CardSetManagerWriter->>CardSetManagerWriter: includeAuthor(authorId) (ensure author in set)
    CardSetManagerWriter->>CardSetManagerRepository: saveAll(CardSetManager entities)
    CardSetManagerRepository->>Database: INSERT manager associations
    Database-->>CardSetManagerRepository: OK
    CardSetManagerRepository-->>CardSetManagerWriter: persisted entities
    CardSetManagerWriter-->>CardSetService: done
    CardSetService-->>Client: return created CardSet
Loading
sequenceDiagram
    participant Client
    participant CardSetService
    participant CardSetManagerWriter
    participant CardSetManagerRepository
    participant Database

    Client->>CardSetService: updateCardSet(cardSetId, UpdateRequest)
    CardSetService->>CardSetManagerWriter: updateManagers(cardSet, newManagerIds)
    CardSetManagerWriter->>CardSetManagerRepository: findUserIdsByCardSetId(cardSetId)
    CardSetManagerRepository->>Database: SELECT existing manager IDs
    Database-->>CardSetManagerRepository: existing IDs
    CardSetManagerRepository-->>CardSetManagerWriter: returns existing IDs
    CardSetManagerWriter->>CardSetManagerWriter: compute toDelete = existing - new, toAdd = new - existing
    CardSetManagerWriter->>CardSetManagerRepository: deleteByCardSet_IdAndUser_IdIn(cardSetId, toDelete)
    CardSetManagerRepository->>Database: DELETE old associations
    CardSetManagerWriter->>CardSetManagerRepository: saveAll(new CardSetManager entities)
    CardSetManagerRepository->>Database: INSERT new associations
    Database-->>CardSetManagerRepository: OK
    CardSetManagerRepository-->>CardSetManagerWriter: persisted
    CardSetManagerWriter-->>CardSetService: done
    CardSetService-->>Client: return updated CardSet
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • stoneTiger0912

Poem

🐰 새롭게 심어진 author, 조용히 깡충깡충,
managers 모여 춤추니 데이터도 빛나네,
Writer가 손잡고 차이를 맞추면,
CardSet은 더 단단히 함께 달리네. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 카드셋 생성 및 수정 시 매니저 설정 기능 구현이라는 핵심 변경 사항을 명확하게 요약하고 있으며, 변경 사항과 직접적으로 관련이 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dungbik dungbik changed the title Feat: 카드셋 생성 및 수정시 매니저 설정 기능 구현 Feat: [FN-264] 카드셋 생성 및 수정시 매니저 설정 기능 구현 Jan 23, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@src/main/java/project/flipnote/cardset/entity/CardSet.java`:
- Around line 35-36: CardSet.author was changed to `@Column`(nullable = false)
which will break existing DB rows; create a DB migration that (1) adds the new
author column as nullable (or with a sensible DEFAULT), (2) backfills existing
rows with a valid user id (e.g., system user id) via an UPDATE, and only then
(3) alters the column to NOT NULL; alternatively, temporarily change the entity
CardSet.author to `@Column`(nullable = true) until the migration/backfill runs,
then switch it to nullable = false and deploy the final migration. Ensure the
migration references the CardSet table/author column and that the chosen
backfill value corresponds to a real user or a documented system user id.

In `@src/main/java/project/flipnote/cardset/model/CardSetUpdateRequest.java`:
- Around line 27-28: The managers field in CardSetUpdateRequest currently only
has `@Size`(min = 1) which doesn't prevent null, so update the validation on the
managers field (in class CardSetUpdateRequest) to require non-null by adding
`@NotNull` or use `@NotEmpty` alongside `@Size`(min = 1); also add the corresponding
import (e.g., javax.validation.constraints.NotNull or
org.hibernate.validator.constraints.NotEmpty) so null values can't bypass the
"at least one manager" rule.

In `@src/main/java/project/flipnote/cardset/model/CreateCardSetRequest.java`:
- Around line 26-27: The managers Set in CreateCardSetRequest is annotated with
`@Size`(min = 1) but that allows null, so add a null-check annotation (e.g.,
`@NotNull` or `@NotEmpty`) to the managers field in the CreateCardSetRequest class
to enforce presence; update imports to include the chosen constraint
(javax.validation.constraints.NotNull or
org.hibernate.validator.constraints.NotEmpty) and keep `@Size`(min = 1) to enforce
at least one element.

In `@src/main/java/project/flipnote/cardset/service/CardSetManagerWriter.java`:
- Around line 51-56: updateManagers currently computes diffs directly from
newManagerIds which can remove the card author as a manager; ensure the author
is always included by adding the card's author id to the set used for diffing
before computing toDelete/toAdd. Concretely, obtain the author id from cardSet
(e.g., cardSet.getAuthorId() or cardSet.getAuthor().getId()), create a copy of
newManagerIds that adds that author id (if missing), and then compute
difference(currentManagerIds, adjustedNewManagerIds) and
difference(adjustedNewManagerIds, currentManagerIds) for toDelete and toAdd
respectively in updateManagers.

Comment on lines +51 to +56
public void updateManagers(CardSet cardSet, Set<Long> newManagerIds) {
Set<Long> currentManagerIds = cardSetManagerRepository.findUserIdsByCardSetId(cardSet.getId());

Set<Long> toDelete = difference(currentManagerIds, newManagerIds);
Set<Long> toAdd = difference(newManagerIds, currentManagerIds);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

업데이트에서도 작성자 강제 포함 필요

현재 updateManagersnewManagerIds에 작성자가 없으면 작성자 매니저가 삭제될 수 있습니다. “작성자는 항상 매니저”라는 규칙을 유지하려면 업데이트에서도 작성자를 포함한 집합으로 diff를 계산해야 합니다.

✅ 수정 제안
 public void updateManagers(CardSet cardSet, Set<Long> newManagerIds) {
-    Set<Long> currentManagerIds = cardSetManagerRepository.findUserIdsByCardSetId(cardSet.getId());
-
-    Set<Long> toDelete = difference(currentManagerIds, newManagerIds);
-    Set<Long> toAdd = difference(newManagerIds, currentManagerIds);
+    Set<Long> finalManagerIds = includeAuthor(cardSet.getAuthor(), newManagerIds);
+    Set<Long> currentManagerIds = cardSetManagerRepository.findUserIdsByCardSetId(cardSet.getId());
+
+    Set<Long> toDelete = difference(currentManagerIds, finalManagerIds);
+    Set<Long> toAdd = difference(finalManagerIds, currentManagerIds);
🤖 Prompt for AI Agents
In `@src/main/java/project/flipnote/cardset/service/CardSetManagerWriter.java`
around lines 51 - 56, updateManagers currently computes diffs directly from
newManagerIds which can remove the card author as a manager; ensure the author
is always included by adding the card's author id to the set used for diffing
before computing toDelete/toAdd. Concretely, obtain the author id from cardSet
(e.g., cardSet.getAuthorId() or cardSet.getAuthor().getId()), create a copy of
newManagerIds that adds that author id (if missing), and then compute
difference(currentManagerIds, adjustedNewManagerIds) and
difference(adjustedNewManagerIds, currentManagerIds) for toDelete and toAdd
respectively in updateManagers.

@dungbik dungbik merged commit c83932c into develop Jan 23, 2026
2 of 3 checks passed
@dungbik dungbik deleted the feat/cardset-manager branch January 23, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants