[FEATURE] 폴더 api 개발#32
Merged
Merged
Conversation
- 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
minsoo0506
reviewed
May 19, 2026
| categoryRepository.existsByMember_IdAndName(memberId, request.name())) { | ||
| throw new CategoryException(ErrorCode.CATEGORY_DUPLICATE_NAME); | ||
| } | ||
|
|
There was a problem hiding this comment.
renameCategory가 중복 이름을 사전 조회로만 막고, 실제 flush/commit 시점의 DataIntegrityViolationException을 CATEGORY_DUPLICATE_NAME으로 변환하지 않는 것 같습니다.
같은 회원의 두 카테고리를 동시에 같은 이름으로 변경하면 둘 다 existsByMember_IdAndName을 통과한 뒤 DB의 (member_id, name) 유니크 제약에서 하나가 터질 수 있는데, 이 예외는 현재 글로벌 핸들러에서 도메인 에러로 매핑되지 않아 409 대신 500이 됩니다. category.rename(...) 이후 saveAndFlush/flush를 try-catch로 감싸거나, 해당 제약 예외를 CATEGORY_DUPLICATE_NAME으로 변환하는 처리가 필요해보입니다!
정상적인 유저의 동작 케이스는 아니지만 고려 해보시면 좋겠습니다...!
Contributor
Author
There was a problem hiding this comment.
리뷰 감사합니다
createCategory에 이미 같은 try-catch 패턴이 적용되어 있어서 일관성 문제도 있어서 동일하게 적용하는게 좋다고 판단 하여 수정했습니다!
325b2c4
minsoo0506
approved these changes
May 19, 2026
…TE_NAME 변환 추가 IssueNum #27
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
요약
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동시 중복 요청 시DataIntegrityViolationExceptioncatch → 500 방지renameCategory동일 이름 재전송 시 불필요한 409 방지 (idempotent)linkIds중복 ID 입력 시linkCount과대계산 방지 (distinct 처리)카테고리를 별도의 도메인으로 분리하지 않은 이유
카테고리가 독립적인 개념처럼 보여도, 이 프로젝트에서는 SavedLink를 분류하기 위한 수단에 불과하기 때문입니다.
Category는 SavedLink 없이 존재할 이유가 없습니다.
링크를 저장하지 않는 사용자에게 카테고리 관리 기능만 따로 쓸 일이 없고, 생명주기도 SavedLink에 종속적입니다.
따라서 다음과 같이 link라는 도메인 폴더에 함께 두었습니다.
테스트
1. 폴더 생성
2. 폴더 이름 변경
위의 폴더 이름으로 변경 후 동일한 이름으로 폴더 생성
3. 폴더 목록 조회
4. 폴더 삭제
삭제용 폴더 생성
삭제용 폴더 생성 확인
폴더 삭제
삭제 확인
연관 이슈 및 Close 할 이슈 작성
close #27
Pull Request 체크리스트
TODO