Skip to content

[FEAT]: 전체 문서 제목 조회 API 추가#168

Open
poketopa wants to merge 3 commits into
developfrom
feat/167
Open

[FEAT]: 전체 문서 제목 조회 API 추가#168
poketopa wants to merge 3 commits into
developfrom
feat/167

Conversation

@poketopa
Copy link
Copy Markdown
Contributor

@poketopa poketopa commented Jun 6, 2026

관련 이슈

작업 내용

  • 전체 문서 제목 조회 API 추가
    • GET /document/titles
  • 전체 문서의 title, uuid만 반환하는 DocumentTitleListResponse 추가
  • 전체 문서 조회 쿼리 추가
    • title, uuid만 조회
  • 전체 문서 제목 조회 서비스 테스트 추가

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

본 PR은 위키 시스템에서 전체 문서의 제목과 UUID 목록을 효율적으로 가져오기 위한 API 기능을 구현합니다. 기존의 전체 문서 조회 방식과 달리 필요한 필드만 선택적으로 조회하도록 쿼리를 최적화하였으며, 관련 서비스 로직과 테스트 코드를 포함하여 안정성을 확보했습니다.

Highlights

  • API 추가: 모든 위키 문서의 제목과 UUID를 조회할 수 있는 GET /document/titles 엔드포인트를 추가했습니다.
  • 데이터 모델 및 쿼리 최적화: 응답을 위한 DocumentTitleListResponse DTO를 생성하고, 데이터베이스에서 필요한 필드만 조회하도록 JPQL 쿼리를 추가했습니다.
  • 테스트 코드 보강: DocumentService에 전체 문서 제목 조회 기능에 대한 단위 테스트를 추가하여 데이터 존재 여부에 따른 정상 동작을 검증했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new endpoint and service method to retrieve all wiki document titles and their UUIDs. The feedback suggests improving the JPQL query by avoiding hardcoded DTO projection paths, removing a redundant @Transactional(readOnly = true) annotation from the service method, and using the static import assertThat in the test class for consistency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +21 to +26
@Query("""
SELECT new com.wooteco.wiki.document.domain.dto.DocumentTitleListResponse(d.title, d.uuid)
FROM Document d
ORDER BY d.title
""")
List<DocumentTitleListResponse> findAllTitles();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

JPQL 쿼리 내에 DTO의 전체 패키지 경로(com.wooteco.wiki.document.domain.dto.DocumentTitleListResponse)를 하드코딩하는 DTO 프로젝션 방식은 리팩터링 시 패키지 경로가 변경되면 쿼리 문자열을 직접 수정해야 하므로 유지보수성이 떨어집니다.

N+1 쿼리 문제를 해결하기 위해 DTO 프로젝션 대신 fetch join을 사용하는 것을 권장합니다. fetch join은 DTO 패키지 경로를 하드코딩하지 않고도 타입 안정성을 제공하여 유지보수성을 높일 수 있습니다.

References
  1. To resolve N+1 query problems, prefer using a fetch join over DTO projection. DTO projection can introduce maintenance issues by hardcoding DTO package paths in JPQL queries, making refactoring difficult. Fetch join provides a type-safe alternative without this drawback.

Comment on lines +30 to +33
@Transactional(readOnly = true)
public List<DocumentTitleListResponse> findAllTitles() {
return documentRepository.findAllTitles();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

DocumentService 클래스 레벨에 이미 @Transactional(readOnly = true) 어노테이션이 적용되어 있으므로, findAllTitles() 메서드에 중복으로 선언된 @Transactional(readOnly = true)는 생략할 수 있습니다. 중복 코드를 제거하여 가독성을 높이는 것을 권장합니다.

    public List<DocumentTitleListResponse> findAllTitles() {
        return documentRepository.findAllTitles();
    }

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.

반영했습니다.

추가적으로 기존 전체 문서 조회(Pageable) API (GET {{BASE_URL}}/document) 메서드에서도 같은 문제가 존재합니다.

@RequiredArgsConstructor
@Transactional(readOnly = true)
@Service
public class DocumentService {

    private final DocumentRepository documentRepository;

    @Transactional(readOnly = true)
    public Page<Document> findAll(PagingRequest pagingRequest) {
        return documentRepository.findAll(pagingRequest.toPageable());
    }

    public List<DocumentTitleListResponse> findAllTitles() {
        return documentRepository.findAllTitles();
    }

List<DocumentTitleListResponse> result = documentService.findAllTitles();

// then
Assertions.assertThat(result).isEmpty();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

테스트 클래스 상단에 import static org.assertj.core.api.Assertions.assertThat;이 static import되어 있으므로, Assertions.assertThat 대신 assertThat을 직접 사용하여 다른 테스트 메서드들과 일관성을 유지하는 것이 좋습니다.

Suggested change
Assertions.assertThat(result).isEmpty();
assertThat(result).isEmpty();

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.

반영했습니다.

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.

1 participant