Skip to content

Conversation

@joyewon0705
Copy link
Collaborator

@joyewon0705 joyewon0705 commented Oct 11, 2025

📌 개요

  • DTO 주석을 통일하고, 댓글 및 게시글 Repository 전반의 쿼리 구조와 검색 조건을 개선했습니다.
  • 특히 QueryDSL 기반으로 불필요한 집계 및 N+1 문제를 제거하고, 정렬·필터 조건을 안전하게 처리하도록 최적화했습니다.

🔨 작업 내용

1. DTO 주석 통일

  • 모든 DTO의 필드 주석을 일관된 형태로 수정 (idID, “작성 및 수정 요청” 통합 등)
  • 문서화 및 Swagger 표시 가독성 개선

2. 댓글 Repository 개선 (CommentRepositoryImpl)

  • 기존 likeCount 별도 쿼리 제거 → comment.likeCount 직접 조회
  • 불필요한 메모리 정렬(sortInMemoryIfNeeded) 제거, DB 정렬로 통합
  • 정렬 화이트리스트(createdAt, updatedAt, likeCount) 적용
  • 부모-자식 댓글 조회 및 매핑 로직 개선
  • 총 쿼리 수 4회 → 3회로 축소
    1. 부모 댓글 조회 (페이징 + 정렬)
    2. 자식 댓글 전체 조회 (IN 조건)
    3. 부모 댓글 count 조회

3. 댓글 좋아요 Repository 개선 (CommentLikeRepositoryImpl)

  • findLikedCommentIdsIn 메서드 주석 추가

4. 게시글 Repository 개선 (PostRepositoryImpl)

  • 기존 집계 쿼리 제거 -> post.likeCount 등으로 직접 조회
  • 카테고리 다중 선택 및 타입별 OR/AND 조합 필터링 로직 추가
    • 같은 CategoryType 내에서는 OR
    • 서로 다른 CategoryType 간에는 AND 결합
  • 정렬 필드 화이트리스트 적용 (createdAt, updatedAt, title, likeCount, bookmarkCount, commentCount)
  • 불필요한 메모리 정렬 제거
  • 총 쿼리 수 3~4회로 고정
    1. 게시글 목록 조회 (User, UserProfile join)
    2. 카테고리 목록 조회 (IN 쿼리 1회)
    3. 게시글 총 count 조회
    4. (선택) categoryIds 필터 시 CategoryType 매핑 쿼리 추가

5. 서비스 및 컨트롤러 변경

  • 게시글 다건 조회 시 여러 개의 카테고리를 검색 조건으로 포함할 수 있게 개선
  • PostService#getPosts()
    • categoryIdList<Long> categoryIds 변경
  • PostController, PostControllerDocs
    • @RequestParam Long categoryIdList<Long> categoryId 수정

6. 테스트 추가

  • CommentLikeRepositoryImplTest
  • CommentRepositoryImplTest
  • PostRepositoryImplTest

🔗 관련 이슈

Closes #{이슈 번호}

📝 참고 사항

✅ 체크리스트

  • 기능 동작 확인
  • 테스트 코드 작성
  • 문서/주석 추가 및 최신화

@github-actions github-actions bot changed the title Refactor: board 도메인 DTO 및 Repository 개선 Refactor: board 도메인 DTO 및 Repository 개선 (#212) Oct 11, 2025
@joyewon0705 joyewon0705 merged commit 76134fa into dev Oct 11, 2025
3 checks passed
@github-actions github-actions bot deleted the Refactor/212 branch October 11, 2025 14:19
@joyewon0705 joyewon0705 restored the Refactor/212 branch October 11, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants