Skip to content

[FEATURE] 폴더 api 개발#32

Merged
sunm2n merged 6 commits into
devfrom
feat/#27-folder-api
May 19, 2026
Merged

[FEATURE] 폴더 api 개발#32
sunm2n merged 6 commits into
devfrom
feat/#27-folder-api

Conversation

@sunm2n
Copy link
Copy Markdown
Contributor

@sunm2n sunm2n commented May 18, 2026

요약

Category(폴더) CRUD API를 구현합니다.

  • POST /api/v1/categories : 폴더 생성 (링크 일괄 배치 포함)
  • GET /api/v1/categories : 폴더 목록 조회 (linkCount 포함)
  • PATCH /api/v1/categories/{id} : 폴더 이름 변경
  • DELETE /api/v1/categories/{id} : 폴더 삭제 (연결된 링크 category null 처리)
  • createCategory 동시 중복 요청 시 DataIntegrityViolationException catch → 500 방지
  • renameCategory 동일 이름 재전송 시 불필요한 409 방지 (idempotent)
  • linkIds 중복 ID 입력 시 linkCount 과대계산 방지 (distinct 처리)

카테고리를 별도의 도메인으로 분리하지 않은 이유

카테고리가 독립적인 개념처럼 보여도, 이 프로젝트에서는 SavedLink를 분류하기 위한 수단에 불과하기 때문입니다.

Category는 SavedLink 없이 존재할 이유가 없습니다.
링크를 저장하지 않는 사용자에게 카테고리 관리 기능만 따로 쓸 일이 없고, 생명주기도 SavedLink에 종속적입니다.
따라서 다음과 같이 link라는 도메인 폴더에 함께 두었습니다.

테스트

1. 폴더 생성

image

2. 폴더 이름 변경

image

위의 폴더 이름으로 변경 후 동일한 이름으로 폴더 생성

image

3. 폴더 목록 조회

image

4. 폴더 삭제

image

삭제용 폴더 생성

image

삭제용 폴더 생성 확인

image

폴더 삭제

image

삭제 확인

연관 이슈 및 Close 할 이슈 작성

close #27

Pull Request 체크리스트

TODO

  • 최종 결과물을 확인했는가?
  • 의미 있는 커밋 메시지를 작성했는가?

sunm2n added 5 commits May 19, 2026 04:32
- CATEGORY_FORBIDDEN, CATEGORY_DUPLICATE_NAME 에러코드 추가
- CategoryException 클래스 생성
- GlobalExceptionHandler에 CategoryException 핸들러 등록

IssueNum #27
- CategoryCreateRequest, CategoryRenameRequest 요청 DTO 추가
- CategoryResponse, CategoryRenameResponse, CategoryListResponse 응답 DTO 추가

IssueNum #27
- createCategory: 이름 중복 검사, displayOrder 자동 부여, 링크 배치
- getCategories: 배치 쿼리로 linkCount 조회
- renameCategory: 소유권 검사 및 이름 중복 검사
- deleteCategory: SavedLink category null 처리 후 삭제

IssueNum #27
- POST /api/v1/categories: 폴더 생성
- GET /api/v1/categories: 폴더 목록 조회
- PATCH /api/v1/categories/{id}: 폴더 이름 변경
- DELETE /api/v1/categories/{id}: 폴더 삭제

IssueNum #27
@sunm2n sunm2n self-assigned this May 18, 2026
@sunm2n sunm2n requested review from kbh0218 and minsoo0506 May 18, 2026 19:59
@sunm2n sunm2n added the feature 새로운 기능/특징 label May 18, 2026
@sunm2n sunm2n changed the title [Feat] Category(폴더) CRUD API 구현 [FEATURE] 폴더 api 개발 May 18, 2026
categoryRepository.existsByMember_IdAndName(memberId, request.name())) {
throw new CategoryException(ErrorCode.CATEGORY_DUPLICATE_NAME);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

renameCategory가 중복 이름을 사전 조회로만 막고, 실제 flush/commit 시점의 DataIntegrityViolationException을 CATEGORY_DUPLICATE_NAME으로 변환하지 않는 것 같습니다.

같은 회원의 두 카테고리를 동시에 같은 이름으로 변경하면 둘 다 existsByMember_IdAndName을 통과한 뒤 DB의 (member_id, name) 유니크 제약에서 하나가 터질 수 있는데, 이 예외는 현재 글로벌 핸들러에서 도메인 에러로 매핑되지 않아 409 대신 500이 됩니다. category.rename(...) 이후 saveAndFlush/flush를 try-catch로 감싸거나, 해당 제약 예외를 CATEGORY_DUPLICATE_NAME으로 변환하는 처리가 필요해보입니다!

정상적인 유저의 동작 케이스는 아니지만 고려 해보시면 좋겠습니다...!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

리뷰 감사합니다
createCategory에 이미 같은 try-catch 패턴이 적용되어 있어서 일관성 문제도 있어서 동일하게 적용하는게 좋다고 판단 하여 수정했습니다!
325b2c4

@sunm2n sunm2n merged commit 0e98e4a into dev May 19, 2026
@sunm2n sunm2n deleted the feat/#27-folder-api branch May 19, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 새로운 기능/특징

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 폴더 api 개발

2 participants