-
Notifications
You must be signed in to change notification settings - Fork 3
feat : 토론글 목록 조회 시 languageId 필드 추가 및 프론트 적용 #160
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
Conversation
Walkthrough이 변경사항은 토론(Discussion) 엔티티와 관련된 데이터 구조에 프로그래밍 언어 식별자(languageId)를 추가하고, 이를 프론트엔드와 백엔드 전체에 반영합니다. 토론 생성, 조회, 수정 시 언어 선택 및 표시가 가능하도록 API, DTO, 엔티티, 쿼리, 템플릿이 수정되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
participant DB
User->>Frontend: 토론 생성/수정 폼에서 언어 선택
Frontend->>Backend: POST/PUT /api/discussions (languageId 포함)
Backend->>DB: 토론 및 언어 정보 저장/갱신
DB-->>Backend: 저장된 토론 정보 반환
Backend-->>Frontend: 토론 응답 (languageId 포함)
Frontend-->>User: 토론 목록에 언어 태그 표시
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
🧹 Nitpick comments (1)
src/main/resources/templates/test-submit.html (1)
1510-1511: 댓글/대댓글 언어 ID 처리 개선 제안댓글과 대댓글에 하드코딩된
languageId: 1을 사용하고 있습니다. 일관성을 위해 상위 토론글의 언어 ID를 상속받거나, 최소한 상수로 정의하는 것을 고려해보세요.예시:
// 상수 정의 const DEFAULT_LANGUAGE_ID = 1; // 또는 상위 토론글의 언어 ID 상속 const discussionItem = item.closest('.discussion-item'); const discussionLangId = getDiscussionLanguageId(discussionItem); payload.languageId = discussionLangId || DEFAULT_LANGUAGE_ID;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/org/ezcode/codetest/application/community/dto/response/DiscussionResponse.java(3 hunks)src/main/java/org/ezcode/codetest/domain/community/dto/DiscussionQueryResult.java(3 hunks)src/main/java/org/ezcode/codetest/domain/community/model/entity/Discussion.java(1 hunks)src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/community/discussion/DiscussionQueryRepositoryImpl.java(1 hunks)src/main/resources/templates/test-submit.html(11 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#16
File: src/main/java/org/ezcode/codetest/infrastructure/persitence/repository/problem/LanguageRepositoryImpl.java:44-46
Timestamp: 2025-06-02T04:37:42.389Z
Learning: @Transactional이 적용된 Service 메서드 내에서 엔티티를 조회하고 수정하는 경우, JPA 더티 체킹이 정상적으로 작동하여 명시적인 save() 호출 없이도 데이터베이스 변경사항이 자동으로 반영됩니다.
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/community/discussion/DiscussionQueryRepositoryImpl.java (1)
Learnt from: Kimminu7
PR: ezcode-my/backend#63
File: src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/problem/ProblemQueryRepositoryImpl.java:24-40
Timestamp: 2025-06-14T14:33:58.372Z
Learning: ProblemController에서 ProblemSearchCondition 객체는 항상 new ProblemSearchCondition(category, difficulty)로 유효한 인스턴스를 생성해서 전달하므로, ProblemQueryRepositoryImpl의 searchByCondition 메서드에서 searchCondition 파라미터 자체에 대한 null 체크는 불필요하다. category와 difficulty 필드만 각각 null일 수 있다.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (8)
src/main/java/org/ezcode/codetest/domain/community/model/entity/Discussion.java (1)
84-86: 편의 메서드 추가가 적절합니다.
getLanguageId()메서드가 올바르게 구현되었습니다. 기존의getUserEmail(),getProblemId()메서드와 일관된 패턴을 따르고 있으며, JPA 매핑에서language필드가nullable=false로 설정되어 있어 null 안전성도 확보되어 있습니다.src/main/java/org/ezcode/codetest/domain/community/dto/DiscussionQueryResult.java (1)
21-21: DTO 필드 추가가 올바르게 구현되었습니다.
languageId필드가 적절히 추가되었습니다:
- 필드 타입
Long이 엔티티 ID에 적합함- 생성자 매개변수 순서가 올바름 (
problemId다음)- 필드 할당이 정확함
- 기존 필드들과 일관된
final키워드 사용Also applies to: 42-42, 54-54
src/main/java/org/ezcode/codetest/application/community/dto/response/DiscussionResponse.java (1)
26-27: 응답 DTO 업데이트가 완벽하게 구현되었습니다.
languageId필드 추가가 올바르게 처리되었습니다:
- Swagger 스키마 어노테이션이 적절히 추가됨
fromEntity메서드에서 편의 메서드getProblemId(),getLanguageId()사용이 좋은 리팩토링임from메서드에서도 일관되게 필드가 추가됨- 두 팩토리 메서드 모두 새 필드를 올바르게 채움
Also applies to: 56-57, 73-73
src/main/resources/templates/test-submit.html (5)
892-924: 언어 로딩 및 선택 기능이 잘 구현되었습니다.언어 목록을 비동기로 로드하고 전역 저장하는 구조가 적절합니다. 에러 처리도 포함되어 있어 견고합니다.
785-797: 언어 태그 스타일링이 깔끔합니다.언어 태그의 CSS 스타일이 전체 디자인과 잘 어울리며, 적절한 여백과 색상을 사용하고 있습니다.
931-939: 언어 로딩 후 렌더링 순서가 올바릅니다.
await loadLanguages()후에renderDiscussionCreateBox()를 호출하는 순서가 적절하여 언어 목록이 로드된 후에 토론글 작성 박스가 렌더링됩니다.
1235-1235: 언어 태그 표시가 올바르게 구현되었습니다.각 토론글에 언어 태그가 적절히 표시되도록 구현되었습니다.
1733-1736: 언어 목록 로딩 대기 처리가 적절합니다.언어 목록이 로드되지 않은 경우 적절한 메시지를 표시하여 사용자 경험을 개선했습니다.
| user.profileImageUrl | ||
| ), | ||
| discussion.problem.id, | ||
| discussion.language.id, |
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.
💡 Verification agent
🧩 Analysis chain
언어 ID 필드 추가가 올바르게 구현되었습니다.
discussion.language.id가 쿼리 프로젝션에 적절히 추가되었습니다. QDiscussionQueryResult 생성자의 매개변수 순서도 올바릅니다.
AI 요약에 따르면 groupBy 절에도 discussion.language.id가 추가되어야 한다고 언급되어 있는데, 현재 diff에서는 확인되지 않습니다. 다음 스크립트로 groupBy 절이 올바르게 업데이트되었는지 확인해주세요:
🏁 Script executed:
#!/bin/bash
# groupBy 절에 discussion.language.id가 포함되어 있는지 확인
ast-grep --pattern $'groupBy(
$$$,
discussion.language.id,
$$$
)'Length of output: 72
다음 스크립트로 DiscussionQueryRepositoryImpl.java 파일 내 groupBy 절에 discussion.language.id가 포함되었는지 확인해 보겠습니다.
🏁 Script executed:
#!/bin/bash
# DiscussionQueryRepositoryImpl.java에서 groupBy 절 검색
rg "groupBy" -A5 -B2 src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/community/discussion/DiscussionQueryRepositoryImpl.javaLength of output: 685
언어 ID 필드 프로젝션은 올바르게 추가되었으나 groupBy 절에도 반영이 필요합니다.
- 위치:
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/community/discussion/DiscussionQueryRepositoryImpl.java
두 번째 쿼리의groupBy블록
변경 전:
.groupBy(
discussion.id,
user.id,
user.nickname,
user.tier,
user.profileImageUrl,
// …
)변경 제안:
.groupBy(
discussion.id,
+ discussion.language.id,
user.id,
user.nickname,
user.tier,
user.profileImageUrl,
// …
)이렇게 하면 프로젝션에 추가한 discussion.language.id에 대해 그룹핑도 일관되게 처리됩니다.
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/community/discussion/DiscussionQueryRepositoryImpl.java
at line 90, the discussion.language.id field is correctly added to the select
projection but missing from the groupBy clause in the second query. To fix this,
add discussion.language.id to the groupBy block alongside the other grouped
fields to ensure consistent grouping with the projection.
Summary by CodeRabbit
신규 기능
스타일
버그 수정