-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor/#105 게시글 생성, 조회 시 카테고리 컬럼 설정 추가 #106
refactor/#105 게시글 생성, 조회 시 카테고리 컬럼 설정 추가 #106
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough이 변경 사항은 Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (7)
aics-domain/src/main/java/kgu/developers/domain/post/domain/PostRepository.java (1)
12-13
: 메서드 파라미터 문서화 추가 권장메서드의 각 매개변수(
keyword
,category
,pageable
)에 대한 설명을 JavaDoc으로 추가하면 메서드의 사용 방법을 더 명확하게 이해할 수 있습니다.다음과 같이 문서화를 추가하는 것을 제안합니다:
+ /** + * 제목과 카테고리로 게시글을 검색하고 생성일 기준 내림차순으로 정렬합니다. + * + * @param keyword 검색할 제목 키워드 + * @param category 필터링할 게시글 카테고리 + * @param pageable 페이지네이션 정보 + * @return 페이지네이션된 게시글 목록 + */ PaginatedListResponse<Post> findAllByTitleContainingAndCategoryOrderByCreatedAtDesc(String keyword, Category category, Pageable pageable);aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostSummaryResponse.java (2)
18-19
: 카테고리 필드가 적절히 추가되었습니다.Schema 어노테이션을 통해 API 문서화가 잘 되어있습니다. 다만, 카테고리 값의 유효성 검증을 위해 가능한 값들을 문서에 명시하는 것이 좋을 것 같습니다.
예시:
-@Schema(description = "게시글 카테고리", example = "학과공지", requiredMode = REQUIRED) +@Schema(description = "게시글 카테고리", example = "학과공지", allowableValues = {"학과공지", "취업공지", "일반공지"}, requiredMode = REQUIRED)
Line range hint
48-48
: 첨부파일 확인 로직 구현 필요현재 첨부파일 여부가 항상
false
로 하드코딩되어 있습니다. 이 부분에 대한 구현이 필요합니다.첨부파일 확인 로직 구현을 위한 이슈를 생성하거나 구현 방안을 제안드릴까요?
aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostDetailResponse.java (1)
5-8
: 관련된 날짜/시간 import문을 그룹화하는 것이 좋습니다.시간 관련 import문들을 하나의 그룹으로 묶어 가독성을 향상시키는 것이 좋습니다.
-import java.time.format.DateTimeFormatter; - -import org.springframework.format.annotation.DateTimeFormat; +import java.time.format.DateTimeFormatter; +import org.springframework.format.annotation.DateTimeFormat;aics-domain/src/main/java/kgu/developers/domain/post/domain/Post.java (1)
68-74
: 빌더 패턴의 가독성 개선을 제안합니다.카테고리 필드 추가는 적절하게 구현되었습니다. 하지만 빌더 패턴의 가독성을 높이기 위해 관련 필드들을 그룹화하여 정렬하는 것을 제안드립니다.
다음과 같이 수정하는 것을 고려해보세요:
public static Post create(String title, String content, Category category, User author) { return Post.builder() - .title(title) - .content(content) - .views(0) - .isPinned(false) - .category(category) - .author(author) // NOTE: User Setter 주입 방지 위해 생성자 주입 + // 필수 컨텐츠 필드 + .title(title) + .content(content) + .category(category) + .author(author) // NOTE: User Setter 주입 방지 위해 생성자 주입 + // 초기값 설정 + .views(0) + .isPinned(false) .build(); }aics-api/src/main/java/kgu/developers/api/post/presentation/PostController.java (1)
Line range hint
1-124
: API 버저닝 전략을 검토해 주세요.현재 "/api/v1/" 경로를 사용하고 있는데, 카테고리 기능 추가로 인한 Breaking Change가 발생할 수 있습니다. 다음 사항들을 고려해 보시기 바랍니다:
- 기존 클라이언트와의 호환성 유지 방안
- API 버전 업그레이드가 필요한지 여부
- 점진적인 마이그레이션 전략
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java (1)
28-31
: 동적 쿼리 조건 생성을 위해 BooleanBuilder 사용 고려현재
whereClause
를 구성할 때 조건별로null
체크를 하고 있습니다. QueryDSL의BooleanBuilder
를 사용하면 조건을 보다 명확하고 관리하기 쉽게 구성할 수 있습니다.적용 가능한 수정 사항:
- var whereClause = post.deletedAt.isNull() - .and(keyword != null ? post.title.contains(keyword) : null) - .and(category != null ? post.category.eq(category) : null); + BooleanBuilder whereClause = new BooleanBuilder(); + whereClause.and(post.deletedAt.isNull()); + if (keyword != null) { + whereClause.and(post.title.contains(keyword)); + } + if (category != null) { + whereClause.and(post.category.eq(category)); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
aics-api/src/main/java/kgu/developers/api/post/application/PostService.java
(2 hunks)aics-api/src/main/java/kgu/developers/api/post/presentation/PostController.java
(4 hunks)aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostDetailResponse.java
(2 hunks)aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostSummaryResponse.java
(2 hunks)aics-domain/src/main/java/kgu/developers/domain/post/domain/Post.java
(1 hunks)aics-domain/src/main/java/kgu/developers/domain/post/domain/PostRepository.java
(1 hunks)aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/PostRepositoryImpl.java
(2 hunks)aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java
(2 hunks)
🔇 Additional comments (14)
aics-domain/src/main/java/kgu/developers/domain/post/domain/PostRepository.java (1)
12-13
: 인터페이스 변경 구현 확인 필요
인터페이스 메서드 시그니처 변경이 적절하게 이루어졌습니다. 하지만 이는 breaking change이므로 모든 구현 클래스가 올바르게 업데이트되었는지 확인이 필요합니다.
구현 클래스 확인을 위한 스크립트:
✅ Verification successful
Let me check the implementation details of these classes to ensure they are properly synchronized.
구현 클래스 검증 완료 - 모든 변경사항이 올바르게 적용됨
PostRepository 인터페이스의 변경사항이 PostRepositoryImpl과 QueryPostRepository에 정확하게 구현되어 있습니다. 특히:
- PostRepositoryImpl이 유일한 구현체이며 인터페이스를 완전히 구현하고 있습니다
- QueryPostRepository에서 카테고리 필터링 로직이 적절하게 구현되어 있습니다
- 반환 타입과 메서드 시그니처가 일치합니다
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: PostRepository 구현 클래스 검색
# PostRepository 구현 클래스 찾기
ast-grep --pattern 'class $_ implements PostRepository {
$$$
}'
# 새로운 메서드 구현 확인
ast-grep --pattern 'findAllByTitleContainingAndCategoryOrderByCreatedAtDesc'
Length of output: 1138
Script:
#!/bin/bash
# Check implementation details of QueryPostRepository and PostRepositoryImpl
rg -A 5 "class QueryPostRepository" aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java
rg -A 5 "class PostRepositoryImpl" aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/PostRepositoryImpl.java
# Check if both implementations have proper method signatures and return types
ast-grep --pattern 'public PaginatedListResponse$_ findAllByTitleContainingAndCategoryOrderByCreatedAtDesc(String keyword, Category category, Pageable pageable) {
$$$
}'
Length of output: 870
Script:
#!/bin/bash
# Check the complete implementation of both classes
cat aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java
cat aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/PostRepositoryImpl.java
# Check if there are any other repository implementations
rg -l "implements PostRepository"
Length of output: 3534
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/PostRepositoryImpl.java (2)
9-9
: 필요한 import 문이 적절히 추가되었습니다.
Category 클래스의 import가 메서드 파라미터 추가에 맞춰 올바르게 추가되었습니다.
31-33
: 카테고리 필터링 기능이 적절히 구현되었습니다.
메서드 시그니처와 구현이 카테고리 필터링 요구사항에 맞게 잘 수정되었습니다. QueryPostRepository에 위임하는 방식도 적절합니다.
하지만 이 변경으로 인한 영향도를 확인해 보시기 바랍니다.
다음 스크립트로 변경된 메서드를 사용하는 다른 코드들을 확인하겠습니다:
✅ Verification successful
Let me generate additional scripts to verify if there are any other potential impacts:
This will help us verify if there are any test cases or API endpoints that need to be updated due to the method signature change.
Based on the results from our verification scripts, I can now provide the final response:
카테고리 필터링 기능의 영향도 검증이 완료되었습니다
이전 검색 결과와 추가 검증을 통해 다음과 같은 사항들이 확인되었습니다:
- PostService에서 새로운 메서드를 올바르게 사용하고 있습니다
- PostRepository 인터페이스와 구현체들이 일관되게 수정되었습니다
- 다른 코드베이스에 영향을 주는 부분이 발견되지 않았습니다
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: 변경된 메서드를 사용하는 코드 검색
# 이전 메서드명을 사용하는 코드가 있는지 확인
rg "findAllByTitleContainingOrderByCreatedAtDesc" -A 3
# 새로운 메서드명을 사용하는 코드 확인
rg "findAllByTitleContainingAndCategoryOrderByCreatedAtDesc" -A 3
Length of output: 2588
Script:
#!/bin/bash
# Check for any test files or configurations that might be affected
rg -t java "PostRepository.*find.*Title.*Category" -A 3
# Check for any controller or API endpoints that might be using this
rg -t java "class.*Controller.*Post" -A 10
Length of output: 600
aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostSummaryResponse.java (2)
5-8
: import 구문이 잘 정리되었습니다.
표준 Java 컨벤션에 따라 import 문이 잘 구성되어 있습니다.
44-44
: 카테고리 null 체크 추가 검토
post.getCategory()
가 null을 반환할 가능성에 대비하여 안전한 처리가 필요할 것 같습니다.
aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostDetailResponse.java (2)
19-20
: 카테고리 필드가 적절하게 추가되었습니다.
Schema 어노테이션의 description과 example이 명확하게 작성되어 있으며, requiredMode 설정도 적절합니다.
60-60
: Category enum의 구현을 확인해주세요.
getDescription() 메소드 호출은 Category가 enum 타입임을 암시합니다. Category enum에 모든 필요한 카테고리 값이 정의되어 있는지 확인이 필요합니다.
✅ Verification successful
Category enum이 적절하게 구현되어 있음을 확인했습니다.
Category enum은 aics-domain/src/main/java/kgu/developers/domain/post/domain/Category.java
에 정의되어 있으며, 다음과 같은 카테고리들이 포함되어 있습니다:
- 학과공지 (DEPT_INFO)
- 수업공지 (LESSON_INFO)
- 취업공지 (EMPLOY_INFO)
- 학과 소식 (DEPT_NEWS)
- 우수 작품전 (GOOD_WORKS)
- 수상 소식 (AWARDED)
각 enum 값에 대한 description이 적절히 정의되어 있어 getDescription()
메소드 호출이 정상적으로 동작할 것입니다.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Category enum 구현 확인
ast-grep --pattern 'enum Category {
$$$
}'
Length of output: 46
Script:
#!/bin/bash
# Category 관련 파일 및 구현 검색
fd -e java | xargs rg -l "Category"
# Category 클래스/enum 정의 검색
rg "class Category|enum Category" -A 10
Length of output: 3353
aics-domain/src/main/java/kgu/developers/domain/post/domain/Post.java (1)
68-74
: Category 열거형 사용에 대한 검증이 필요합니다.
카테고리 기능 추가와 관련하여 다음 사항들을 확인해주세요:
- Category 열거형이 올바르게 정의되어 있는지
- 데이터베이스 스키마 변경이 적절히 처리되었는지
- 게시물 조회 쿼리가 카테고리 필터링을 지원하는지
✅ Verification successful
Let me gather more information about the Category enum definition and database schema.
Let me check the actual Category enum definition and any repository methods for post filtering.
Category 열거형이 적절히 구현되어 있습니다
검증 결과:
- Category 열거형이 6개의 카테고리 값과 description을 포함하여 올바르게 정의되어 있습니다
- @Enumerated(STRING) 어노테이션으로 데이터베이스 매핑이 적절히 처리되어 있습니다
- PostRepository에서 findAllByTitleContainingAndCategoryOrderByCreatedAtDesc 메서드를 통해 카테고리 기반 필터링을 지원합니다
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Category 열거형 정의 및 사용 검증
echo "Category 열거형 정의 확인:"
ast-grep --pattern 'enum Category {
$$$
}'
echo "\n게시물 조회 쿼리에서 카테고리 사용 확인:"
rg -t java "category.*[Cc]ategory" --glob "Post*.java"
echo "\nRepository에서 카테고리 필터링 확인:"
rg -t java "findBy.*[Cc]ategory" --glob "*Repository*.java"
Length of output: 2211
Script:
#!/bin/bash
# Category 열거형 정의 찾기
echo "Category 열거형 파일 찾기:"
fd -e java Category
echo "\nCategory 열거형 사용 확인:"
rg -t java "Category\." -A 2
echo "\nEntity 매핑 확인:"
rg -t java "@Enumerated|@Column.*category" --glob "Post.java"
Length of output: 2934
Script:
#!/bin/bash
# Category 열거형 내용 확인
echo "Post Category 열거형 정의:"
cat aics-domain/src/main/java/kgu/developers/domain/post/domain/Category.java
echo "\nPost 리포지토리 메서드 확인:"
rg -t java "interface.*PostRepository|findBy.*Category" --glob "*PostRepository.java" -A 5
Length of output: 1569
aics-api/src/main/java/kgu/developers/api/post/application/PostService.java (2)
3-21
: LGTM - 임포트 구문이 잘 정리되어 있습니다!
새로운 기능을 위한 필수 클래스들이 잘 임포트되어 있으며, 논리적으로 잘 구성되어 있습니다.
42-47
: 성능 최적화 고려사항
카테고리 기반 검색의 성능을 향상시키기 위한 제안사항입니다:
- 카테고리와 제목에 대한 복합 인덱스 추가 검토
- 자주 접근되는 카테고리에 대한 캐싱 전략 고려
또한, 쿼리 성능을 확인하기 위해 다음 사항들을 검토해보시기 바랍니다:
aics-api/src/main/java/kgu/developers/api/post/presentation/PostController.java (3)
5-15
: LGTM - 임포트 구문이 적절히 구성되어 있습니다!
필요한 Spring 프레임워크 클래스들과 Category 도메인 클래스가 잘 임포트되어 있습니다.
Also applies to: 30-30
60-68
: 응답 타입에 카테고리 정보가 포함되어 있는지 확인해 주세요.
PostSummaryPageResponse
에 다음 사항들이 반영되어 있는지 확인이 필요합니다:
- 카테고리 필드 추가 여부
- 카테고리 정보의 직렬화/역직렬화 처리
응답 타입 구현을 확인하기 위해 다음 스크립트를 실행하세요:
✅ Verification successful
카테고리 정보가 응답에 올바르게 포함되어 있습니다.
PostSummaryResponse
클래스에서 카테고리 필드가 다음과 같이 구현되어 있습니다:
category
필드가 필수값으로 정의됨Post
엔티티로부터 카테고리 정보를getDescription()
을 통해 적절히 변환하여 포함- Swagger 문서화도 올바르게 되어있음
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# PostSummaryPageResponse 클래스에서 카테고리 관련 필드 검색
ast-grep --pattern 'class PostSummaryPageResponse {
$$$
category
$$$
}'
Length of output: 79
Script:
#!/bin/bash
# Find and show PostSummaryPageResponse class implementation
rg -l "PostSummaryPageResponse"
# Show content of files containing PostSummaryPageResponse
rg -A 10 "class PostSummaryPageResponse"
# Find Category usage in response classes
rg "Category" --type java
Length of output: 11291
Script:
#!/bin/bash
# PostSummaryPageResponse 클래스의 전체 내용 확인
cat aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostSummaryPageResponse.java
# PostSummaryResponse 클래스의 전체 내용 확인 (PostSummaryPageResponse에서 사용될 가능성이 높음)
cat aics-api/src/main/java/kgu/developers/api/post/presentation/response/PostSummaryResponse.java
Length of output: 2994
47-51
: 카테고리 파라미터의 필수 여부를 검토해 주세요.
새로 추가된 category 파라미터가 required=true로 설정되어 있습니다. 이는 다음과 같은 영향을 고려해야 할 수 있습니다:
- 기존 API 클라이언트들의 호환성
- 마이그레이션 계획의 필요성
기존 API 사용처를 확인하기 위해 다음 스크립트를 실행하세요:
✅ Verification successful
카테고리 파라미터 필수화는 안전해 보입니다.
코드베이스 분석 결과, 게시글 생성 API의 사용 패턴이 제한적이며 현재 구현이 새로운 것으로 보입니다:
- API를 사용하는 클라이언트 코드가 발견되지 않았습니다
- 프론트엔드 구현이 아직 완료되지 않은 것으로 보입니다
- 테스트 코드에서도 API 사용 패턴이 발견되지 않았습니다
따라서 category를 필수 파라미터로 추가하는 것이 기존 클라이언트에 영향을 미칠 가능성은 매우 낮습니다.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# API 클라이언트에서 createPost 호출 패턴 검색
rg -t java -t typescript -t javascript "createPost|posts.*POST"
Length of output: 100
Script:
#!/bin/bash
# Search for createPost method calls and POST endpoints in the codebase
rg -t java "createPost|posts.*POST"
# Find all frontend source files that might contain API calls
fd -e js -e jsx -e ts -e tsx | xargs rg "createPost|posts.*POST"
# Search for test files related to post creation
fd -e java -e js -e jsx -e ts -e tsx test | xargs rg "createPost"
# Look for Swagger or API documentation files
fd -g "*api*.{yaml,json,md}" | xargs cat
Length of output: 1921
Script:
#!/bin/bash
# Check git history for previous implementations of the post creation endpoint
git log -p --all -- "**/PostController.java"
# Look for integration tests that might show API usage patterns
fd -e java "test" | xargs rg "createPost|PostController"
# Search for any HTTP client configurations or API client implementations
rg -t java "WebClient|RestTemplate|HttpClient|FeignClient"
Length of output: 117
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java (1)
25-26
: 메서드 시그니처 변경에 따른 영향 확인
findAllByTitleContainingOrderByCreatedAtDesc
메서드가 findAllByTitleContainingAndCategoryOrderByCreatedAtDesc
로 변경되었습니다. 이 변경 사항에 따라 해당 메서드를 호출하는 모든 부분이 올바르게 업데이트되었는지 확인해주세요.
다음 스크립트를 실행하여 메서드 호출부를 확인하세요:
✅ Verification successful
Let me check if there are any remaining references to the old method name.
메서드 시그니처 변경이 올바르게 적용되었습니다
이전 메서드명(findAllByTitleContainingOrderByCreatedAtDesc
)에 대한 참조가 없고, 새로운 메서드명(findAllByTitleContainingAndCategoryOrderByCreatedAtDesc
)이 다음 파일들에서 일관되게 사용되고 있음을 확인했습니다:
aics-domain/src/main/java/kgu/developers/domain/post/domain/PostRepository.java
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/PostRepositoryImpl.java
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java
aics-api/src/main/java/kgu/developers/api/post/application/PostService.java
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: 변경된 메서드 시그니처에 따라 모든 호출부가 업데이트되었는지 확인합니다.
# Test: 메서드 사용처 검색. 기대 결과: 새로운 시그니처만 존재해야 합니다.
rg 'findAllByTitleContainingAndCategoryOrderByCreatedAtDesc'
Length of output: 1039
Script:
#!/bin/bash
# Check for the old method name
rg 'findAllByTitleContainingOrderByCreatedAtDesc'
Length of output: 49
aics-api/src/main/java/kgu/developers/api/post/application/PostService.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빠른 작업 대단합니다! 👍
한 가지 의견 있으니 검토 부탁드려요~
aics-domain/src/main/java/kgu/developers/domain/post/infrastructure/QueryPostRepository.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뒤늦게 확인해서 죄송합니다! 고생 많으셨어요 👍
Summary
게시글 생성, 조회 시 카테고리 컬럼 설정 추가
Tasks
To Reviewer
부족한 부분 있으면 말씀해주세요.