feat: 내 정보 조회 + 사용자 언어 설정 변경#66
Conversation
…nto feat/#62-language-change
📝 WalkthroughWalkthrough사용자 엔티티에 언어 코드와 알림 설정을 저장하고, 회원가입 시 언어를 지정하도록 변경했습니다. 사용자 정보 조회 및 언어 변경 API를 추가하고, 뉴스레터 업로드 시 사용자의 저장된 언어를 활용하도록 수정했습니다. Changes사용자 엔티티 확장 및 회원가입 언어 지원
사용자 정보 및 언어 변경 API
뉴스레터 업로드 언어 처리 재구성
Sequence DiagramsequenceDiagram
participant User as 사용자
participant AuthAPI as 회원가입 API
participant UserService as 사용자 서비스
participant Database as 데이터베이스
User->>AuthAPI: POST /signup (언어 코드 포함)
AuthAPI->>UserService: signup(SignupRequest)
UserService->>Database: User.builder().languageCode(...).save()
Database-->>UserService: User 저장 완료
UserService-->>AuthAPI: 회원가입 성공
AuthAPI-->>User: 토큰 반환
User->>UserAPI: PATCH /me/language (새 언어)
UserAPI->>Database: updateLanguage(newLanguage)
UserAPI->>Database: cancelInProgressByUserId(FAILED)
Database-->>UserAPI: 취소된 건수
UserAPI-->>User: USER_LANGUAGE_UPDATED
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/com/gachi/be/domain/auth/dto/request/SignupRequest.java`:
- Around line 20-22: The languageCode parameter in SignupRequest is only
annotated with `@Pattern`, allowing nulls to pass and default to "KO"; change the
declaration for languageCode in the SignupRequest (the parameter named
languageCode in the SignupRequest record/constructor) to be required by adding a
null-check constraint (e.g., annotate with `@NotNull` or `@NotBlank` alongside the
existing `@Pattern`) so validation fails on missing language selection instead of
silently falling back.
In
`@src/main/java/com/gachi/be/domain/newsletter/repository/NewsletterRepository.java`:
- Around line 100-112: The cancelInProgressByUserId query only updates status
and leaves Newsletter.language unchanged, causing retried jobs to use the old
language; modify the repository method cancelInProgressByUserId to accept a new
language parameter (e.g., `@Param`("language") String newLanguage) and change the
JPQL to "SET n.status = :failedStatus, n.language = :language" (update the
method signature to include the language param), then update the caller (e.g.,
UserController.changeLanguage(...) where cancelInProgressByUserId is invoked) to
pass request.languageCode() so in-progress PENDING/PROCESSING newsletters get
their language updated; alternatively, if you prefer, ensure retryAnalysis()
overwrites newsletter.language with the current user language before
reprocessing (refer to methods cancelInProgressByUserId and retryAnalysis).
In `@src/main/java/com/gachi/be/domain/user/api/controller/UserController.java`:
- Around line 69-80: The controller unconditionally cancels in-progress
pipelines even when the language didn't change; modify UserController to compare
previousLanguage and newLanguage (e.g., using Objects.equals or String.equals)
and only call user.updateLanguage(...), userRepository.save(user) and
newsletterRepository.cancelInProgressByUserId(...) when the language actually
changed; if unchanged, skip the cancel logic (and optionally skip calling
update/save) to avoid interrupting active pipelines.
In
`@src/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.java`:
- Around line 6-7: Change the record field type in ChangeNotificationRequest
from the primitive boolean to the wrapper Boolean so `@NotNull` can actually
validate presence; update the record declaration (the notificationEnabled
component) to use Boolean and adjust any call sites or tests that construct this
DTO to pass a Boolean (or handle null) so missing JSON produces a null and
triggers validation.
In `@src/main/java/com/gachi/be/domain/user/entity/User.java`:
- Around line 116-118: updateLanguage 메서드가 null 또는 blank 값을 허용해 DB 제약이나 잘못된 언어
처리로 이어지므로 User.updateLanguage에서 입력값을 검증해 도메인 불변식을 강제하세요: languageCode가 null이거나 빈
문자열(또는 공백만 있는 경우)일 때는 trim 후에도 비어있으면 IllegalArgumentException(또는 도메인 전용 예외)로 즉시
실패시키고, 유효하면 trim한 값을 this.languageCode에 할당하도록 수정하세요; 메서드명 updateLanguage와 엔티티
User, 컬럼 users.language_code를 참고해서 변경하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 93e39d3a-234f-48af-816f-d78220be4b5b
📒 Files selected for processing (21)
src/main/java/com/gachi/be/domain/auth/dto/request/SignupRequest.javasrc/main/java/com/gachi/be/domain/auth/service/AuthenticatedUserResolver.javasrc/main/java/com/gachi/be/domain/auth/service/impl/AuthServiceImpl.javasrc/main/java/com/gachi/be/domain/newsletter/api/controller/NewsletterController.javasrc/main/java/com/gachi/be/domain/newsletter/repository/NewsletterRepository.javasrc/main/java/com/gachi/be/domain/newsletter/service/NewsletterService.javasrc/main/java/com/gachi/be/domain/newsletter/service/impl/NewsletterServiceImpl.javasrc/main/java/com/gachi/be/domain/user/api/controller/UserController.javasrc/main/java/com/gachi/be/domain/user/dto/request/ChangeLanguageRequest.javasrc/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.javasrc/main/java/com/gachi/be/domain/user/dto/response/UserMeResponse.javasrc/main/java/com/gachi/be/domain/user/entity/User.javasrc/main/java/com/gachi/be/domain/user/entity/enums/UserStatus.javasrc/main/java/com/gachi/be/domain/user/repository/UserRepository.javasrc/main/java/com/gachi/be/global/code/ErrorCode.javasrc/main/java/com/gachi/be/global/code/SuccessCode.javasrc/main/java/com/gachi/be/global/security/JwtAuthenticationFilter.javasrc/main/resources/db/migration/V12__user_add_language_code.sqlsrc/main/resources/db/migration/V13__user_add_notification_enabled.sqlsrc/test/java/com/gachi/be/domain/auth/api/controller/AuthRateLimitIntegrationTest.javasrc/test/java/com/gachi/be/domain/child/api/controller/ChildControllerIntegrationTest.java
| public record ChangeNotificationRequest( | ||
| @NotNull(message = "notificationEnabled는 필수입니다.") boolean notificationEnabled) {} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# primitive boolean + `@NotNull` 조합 확인
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+notificationEnabled' src/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.java
# 동일 패턴이 다른 DTO에도 있는지 점검
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+' src/main/javaRepository: GACHI-Project/GACHI-BE
Length of output: 324
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) 해당 선언을 정확히 확인
echo "---- ChangeNotificationRequest.java (lines around record) ----"
nl -ba src/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.java | sed -n '1,120p'
# 2) 동일 안티패턴 전체 개수/경로 확인
echo "---- All occurrences of `@NotNull`(...) boolean <name> in src/main/java ----"
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+\w+' src/main/java || true
echo "---- Count ----"
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+\w+' src/main/java | wc -lRepository: GACHI-Project/GACHI-BE
Length of output: 190
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "---- ChangeNotificationRequest.java (lines around record) ----"
cat -n src/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.java | sed -n '1,120p'
echo "---- All occurrences of `@NotNull`(...) boolean <name> in src/main/java ----"
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+\w+' src/main/java || true
echo "---- Count ----"
rg -nP '`@NotNull`\([^\n]*\)\s*boolean\s+\w+' src/main/java | wc -l || trueRepository: GACHI-Project/GACHI-BE
Length of output: 687
@NotNull을 primitive boolean에 적용한 부분 수정 필요 (ChangeNotificationRequest.java)
notificationEnabled가booleanprimitive라@NotNull은 null 검증이 불가능합니다.- 요청 JSON에서 해당 필드가 누락되면 primitive 기본값(예:
false)으로 처리되어 “필수” 의미가 깨질 수 있습니다. - 동일 패턴(
@NotNull(...) boolean)은src/main/java에서 이 DTO 1건만 확인됩니다.
boolean → Boolean(래퍼 타입)으로 바꿔 null 유무로 필수 검증이 되게 하세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/main/java/com/gachi/be/domain/user/dto/request/ChangeNotificationRequest.java`
around lines 6 - 7, Change the record field type in ChangeNotificationRequest
from the primitive boolean to the wrapper Boolean so `@NotNull` can actually
validate presence; update the record declaration (the notificationEnabled
component) to use Boolean and adjust any call sites or tests that construct this
DTO to pass a Boolean (or handle null) so missing JSON produces a null and
triggers validation.
deli-minju
left a comment
There was a problem hiding this comment.
내 정보 조회 응답과 언어 설정 변경 흐름이 디자인 요구사항에 맞게 잘 반영된 것 같습니다. 고생하셨습니다!
📌 작업 요약
🌿 브랜치 정보
feat/#62-language-changedevelop(기본)✅ 체크리스트
feat/refac/hotfix/chore/design/bugfix)feat/fix/refactor/docs/style/chore)🧪 테스트 결과
에러코드 추가
USER4001 (HTTP 400 Bad Request): 지원하지 않는 언어 코드 요청 차단
Summary by CodeRabbit
새로운 기능
개선사항