Skip to content

[Refactor] 카테고리 계층별 조회 구현#203

Merged
Bal1oon merged 5 commits into
developfrom
refactor/#202-category-get
Oct 25, 2025
Merged

[Refactor] 카테고리 계층별 조회 구현#203
Bal1oon merged 5 commits into
developfrom
refactor/#202-category-get

Conversation

@Bal1oon

@Bal1oon Bal1oon commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

🛠️ Issue Number

closes #202

📌 작업 내용 및 특이사항

기존 카테고리 조회는 "카테고리 전체 목록 조회", "카테고리 트리형 전체 조회" 뿐이라서 불필요하게 많은 데이터를 조회하는 문제점이 있어 리팩토링 진행하게 되었습니다. 다른 eCommerce의 카테고리 조회 형식을 참고하여 계층형 조회 구조로 변환했습니다.

변경 전: 1, 2, 3 depth 전부 조회
변경 후: 1 -> 2 -> 3 depth를 하나씩 펼치는 식으로 조회

Controller

  • /categoris API가 parentId 기반 조건으로 동작하도록 수정
    • GET /categories : 루트 카테고리 조회
    • GET /categories?parentId={id} : 특정 카테고리의 하위 카테고리 조회

Service

  • findAllCategories() 메서드 제거 및 메서드 분리
    • findRootCategories() : 루트 카테고리 조회
    • findByParentId(UUID parentId) : 특정 카테고리 하위 조회

Repository

  • findChildrenByParentId(UUID parentId) 쿼리 메서드 재사용
@Query("SELECT c FROM Category c WHERE c.parent.categoryId = :parentId")
List<Category> findChildrenByParentId(@Param("parentId") UUID parentId);

📚 참고사항

  • /categories/tree는 그대로 유지 (관리자용 전체 트리 조회) — @BatchSize 설정 기반으로 Lazy 로딩 시 효율적 작동 확인

@Bal1oon Bal1oon added this to the Sprint 3 milestone Oct 25, 2025
@Bal1oon Bal1oon self-assigned this Oct 25, 2025
@Bal1oon Bal1oon added the ♻️ refactor 보다 효율적이고 깔끔한 코드를 위해 리팩토링을 진행합니다. label Oct 25, 2025
@Bal1oon
Bal1oon requested review from Moses249 and growingpsy and removed request for willjsw October 25, 2025 13:00

@willjsw willjsw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM🫡

@Bal1oon
Bal1oon merged commit e518d68 into develop Oct 25, 2025
1 check passed
growingpsy pushed a commit that referenced this pull request Oct 26, 2025
* refactor #202: 카테고리 단계별 조회 구현

* refactor #202: 카테고리 BaseEntity 상속

* refactor #202: 주석 제거 및 Request 검증 추가

* refactor #202: 카테고리 조회 응답 구조 단순화

* refactor #202: Spotless 적용
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ refactor 보다 효율적이고 깔끔한 코드를 위해 리팩토링을 진행합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] 카테고리 조회 API를 parentId 기반 계층형 구조로 리팩토링

2 participants