[feat] #37 - 온보딩 - #39
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
Walkthrough온보딩 완료 API가 추가되었습니다. 요청/응답 DTO, 서비스 검증 로직, 사용자 엔티티 갱신, 성공·오류 코드, 컨트롤러 엔드포인트가 함께 변경되었습니다. Changes온보딩 완료 처리
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (5)
src/main/java/com/Timo/Timo/domain/user/dto/request/OnboardingRequest.java (2)
19-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value시간 정규식 중복
wakeUpTime과bedTime에 동일한 HH:MM 정규식이 중복 정의되어 있습니다. 상수로 추출하면 유지보수성이 개선됩니다.♻️ 제안
private static final String TIME_PATTERN = "^([01]\\d|2[0-3]):[0-5]\\d$";🤖 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/Timo/Timo/domain/user/dto/request/OnboardingRequest.java` around lines 19 - 25, The HH:MM regex is duplicated on wakeUpTime and bedTime in OnboardingRequest, so extract it into a shared constant and reuse it in both `@Pattern` annotations. Add a single TIME_PATTERN field in the same DTO and update the wakeUpTime and bedTime validation annotations to reference that constant for easier maintenance.
1-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff시간 값을 String으로 받아 수동 파싱하는 대신
LocalTime+@JsonFormat사용 검토
wakeUpTime/bedTime을String으로 받아 정규식으로 형식을 검증하고, 서비스에서 다시LocalTime.parse하는 방식입니다.LocalTime타입에@JsonFormat(pattern = "HH:mm")을 적용하면 형식 오류를 Jackson 역직렬화 단계에서 처리할 수 있어 중복 검증/파싱 로직을 줄일 수 있습니다. (단, Jackson 파싱 오류를 GlobalExceptionHandler가 일관되게 처리하는지 별도 확인 필요)🤖 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/Timo/Timo/domain/user/dto/request/OnboardingRequest.java` around lines 1 - 27, OnboardingRequest의 wakeUpTime/bedTime을 String 정규식 검증으로 받고 나중에 다시 파싱하는 중복을 줄이기 위해 LocalTime으로 변경하고 `@JsonFormat`(pattern = "HH:mm")를 적용하세요. OnboardingRequest 레코드의 wakeUpTime/bedTime 필드를 LocalTime으로 바꾸고, 서비스에서 LocalTime.parse를 제거한 뒤 Jackson 역직렬화 단계에서 형식 검증이 되도록 맞추세요. 또한 GlobalExceptionHandler가 Jackson 파싱 예외를 일관되게 처리하는지 확인해 같은 응답 형식을 유지하세요.src/main/java/com/Timo/Timo/domain/user/controller/OnboardingController.java (1)
37-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value하드코딩된
ResponseEntity.ok()는 successCode의 HTTP 상태와 별개로 동작현재
UserSuccessCode.ONBOARDING_COMPLETED가HttpStatus.OK이므로 문제가 되지 않지만,ResponseEntity.ok(...)를 하드코딩하면 향후 성공 코드의 상태값이 변경되더라도 실제 HTTP 응답 코드는 반영되지 않는 구조적 위험이 있습니다.BaseResponse.onSuccess가 반환하는successCode.getHttpStatus()를ResponseEntity에도 그대로 사용하는 것이 일관성 있습니다.♻️ 제안
- return ResponseEntity.ok( - BaseResponse.onSuccess(UserSuccessCode.ONBOARDING_COMPLETED, response) - ); + return ResponseEntity.status(UserSuccessCode.ONBOARDING_COMPLETED.getHttpStatus()) + .body(BaseResponse.onSuccess(UserSuccessCode.ONBOARDING_COMPLETED, response));🤖 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/Timo/Timo/domain/user/controller/OnboardingController.java` around lines 37 - 39, `OnboardingController` in the onboarding response path is hardcoding `ResponseEntity.ok(...)`, which can diverge from `UserSuccessCode.ONBOARDING_COMPLETED` if its HTTP status changes. Update the controller to use the HTTP status from the success code returned by `BaseResponse.onSuccess(...)` instead of always using `ok`, so the `ResponseEntity` status stays aligned with the code’s `getHttpStatus()` behavior.src/main/java/com/Timo/Timo/domain/user/service/OnboardingService.java (1)
40-42: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value응답 값을 하드코딩하는 대신 엔티티 상태 참조 권장
onboardingCompleted(true)를 하드코딩하고 있는데,user.completeOnboarding(...)호출 이후 실제 엔티티 상태(user.isOnboardingCompleted())를 참조하면 향후 로직 변경 시에도 응답이 실제 상태와 항상 일치함을 보장할 수 있습니다.🤖 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/Timo/Timo/domain/user/service/OnboardingService.java` around lines 40 - 42, In OnboardingService, the OnboardingResponse is still hardcoded with onboardingCompleted(true) after user.completeOnboarding(...); update the response builder to read the actual state from the user entity via user.isOnboardingCompleted() so the returned value always matches the domain state. Use the existing completeOnboarding method and the OnboardingResponse.builder() call as the main points to locate and adjust the logic.src/main/java/com/Timo/Timo/domain/user/entity/User.java (1)
79-90: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win도메인 불변식이 엔티티가 아닌 서비스에만 존재
completeOnboarding은 파라미터를 그대로 필드에 대입할 뿐, 취침시간이 기상시간보다 이후여야 한다는 규칙을 검증하지 않습니다. 현재는OnboardingService에서만 이 규칙을 검증하는데, 이 메서드가 다른 경로로 호출될 경우 잘못된 상태가 저장될 수 있습니다. 도메인 규칙을 엔티티 메서드 내부로 옮겨 캡슐화하는 것을 권장합니다.As per path instructions, "Entity에 필요한 도메인 규칙과 상태 변경 메서드가 적절히 캡슐화되어 있는지 확인해 주세요."
🤖 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/Timo/Timo/domain/user/entity/User.java` around lines 79 - 90, Move the onboarding validation into User.completeOnboarding so the entity enforces its own domain invariant, not just OnboardingService. In User.completeOnboarding, check that bedTime is after wakeUpTime before assigning fields, and reject invalid input consistently from any caller. Use the existing completeOnboarding method and the wakeUpTime/bedTime fields as the main place to encapsulate this rule.
🤖 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.
Nitpick comments:
In
`@src/main/java/com/Timo/Timo/domain/user/controller/OnboardingController.java`:
- Around line 37-39: `OnboardingController` in the onboarding response path is
hardcoding `ResponseEntity.ok(...)`, which can diverge from
`UserSuccessCode.ONBOARDING_COMPLETED` if its HTTP status changes. Update the
controller to use the HTTP status from the success code returned by
`BaseResponse.onSuccess(...)` instead of always using `ok`, so the
`ResponseEntity` status stays aligned with the code’s `getHttpStatus()`
behavior.
In `@src/main/java/com/Timo/Timo/domain/user/dto/request/OnboardingRequest.java`:
- Around line 19-25: The HH:MM regex is duplicated on wakeUpTime and bedTime in
OnboardingRequest, so extract it into a shared constant and reuse it in both
`@Pattern` annotations. Add a single TIME_PATTERN field in the same DTO and update
the wakeUpTime and bedTime validation annotations to reference that constant for
easier maintenance.
- Around line 1-27: OnboardingRequest의 wakeUpTime/bedTime을 String 정규식 검증으로 받고
나중에 다시 파싱하는 중복을 줄이기 위해 LocalTime으로 변경하고 `@JsonFormat`(pattern = "HH:mm")를 적용하세요.
OnboardingRequest 레코드의 wakeUpTime/bedTime 필드를 LocalTime으로 바꾸고, 서비스에서
LocalTime.parse를 제거한 뒤 Jackson 역직렬화 단계에서 형식 검증이 되도록 맞추세요. 또한
GlobalExceptionHandler가 Jackson 파싱 예외를 일관되게 처리하는지 확인해 같은 응답 형식을 유지하세요.
In `@src/main/java/com/Timo/Timo/domain/user/entity/User.java`:
- Around line 79-90: Move the onboarding validation into User.completeOnboarding
so the entity enforces its own domain invariant, not just OnboardingService. In
User.completeOnboarding, check that bedTime is after wakeUpTime before assigning
fields, and reject invalid input consistently from any caller. Use the existing
completeOnboarding method and the wakeUpTime/bedTime fields as the main place to
encapsulate this rule.
In `@src/main/java/com/Timo/Timo/domain/user/service/OnboardingService.java`:
- Around line 40-42: In OnboardingService, the OnboardingResponse is still
hardcoded with onboardingCompleted(true) after user.completeOnboarding(...);
update the response builder to read the actual state from the user entity via
user.isOnboardingCompleted() so the returned value always matches the domain
state. Use the existing completeOnboarding method and the
OnboardingResponse.builder() call as the main points to locate and adjust the
logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b0321237-0cdc-4095-8f96-f3c4fce2c73f
⛔ Files ignored due to path filters (1)
src/main/java/com/Timo/Timo/domain/user/docs/OnboardingControllerDocs.javais excluded by!**/docs/**
📒 Files selected for processing (7)
src/main/java/com/Timo/Timo/domain/user/controller/OnboardingController.javasrc/main/java/com/Timo/Timo/domain/user/dto/request/OnboardingRequest.javasrc/main/java/com/Timo/Timo/domain/user/dto/response/OnboardingResponse.javasrc/main/java/com/Timo/Timo/domain/user/entity/User.javasrc/main/java/com/Timo/Timo/domain/user/exception/UserErrorCode.javasrc/main/java/com/Timo/Timo/domain/user/exception/UserSuccessCode.javasrc/main/java/com/Timo/Timo/domain/user/service/OnboardingService.java
…to feat/#37-onboarding # Conflicts: # src/main/java/com/Timo/Timo/domain/user/exception/UserSuccessCode.java
laura-jung
left a comment
There was a problem hiding this comment.
아주 깔끔하고 굳입니다. 불필요한 여백만 없애주시면 될 것 같아용
어푸드립니다아ㅏ
| public record OnboardingResponse( | ||
| boolean onboardingCompleted | ||
| ) { | ||
|
|
There was a problem hiding this comment.
p4) 별도로 들어가는 값이 없다면 빈칸 없애도 될 것 같아요
| public enum UserErrorCode implements BaseErrorCode { | ||
|
|
||
| USER_400_INVALID_TIME(HttpStatus.BAD_REQUEST, "USER_400", "취침 시간은 기상 시간보다 이후여야 합니다."), | ||
|
|
aneykrap
left a comment
There was a problem hiding this comment.
pr 내용에 맞게 구현된 거 확인했습니다!!
취침시간 기상시간이 24시 이내로 기획된 내용이면 같은 날짜로 비교해서 진행해도 될것 같습니다
고생 많았어용
관련 이슈 🛠
작업 내용 요약 ✏️
온보딩(언어, 작업 시간 예측 정확도, 기상/취침 시간)에서 수집한 값을 한 번에 저장하고, 온보딩 완료 상태(
onboarding_completed = true)로 전환하는 API를 구현했습니다.주요 변경 사항 🛠️
POST /api/v1/users/onboarding온보딩 완료 API 엔드포인트AuthResponseFactory패턴에 맞춰 응답 조립 책임 분리completeOnboarding()메서드에 파라미터 추가하여 온보딩 데이터 반영하도록 수정ONBOARDING_COMPLETED성공 코드USER_400_INVALID_TIME에러 코드 (취침 시간이 기상 시간보다 빠른 경우)트러블 슈팅 ⚽️
테스트 결과 📄
onboardingCompleted: true반환 확인25:00등) 400 에러 반환 확인predictionAccuracy범위(1~4) 밖 값 요청 시 400 에러 반환 확인스크린샷 📷 (추가 예정)
정상 케이스: 온보딩 값 저장 및





onboardingCompleted: true반환 확인취침 시간 < 기상 시간인 경우 400 에러 반환 확인
필수 필드 누락 시 400 에러 반환 확인
시간 형식이 잘못된 경우(
25:00등) 400 에러 반환 확인predictionAccuracy범위(1~4) 밖 값 요청 시 400 에러 반환 확인리뷰 요구사항 📢
📎 참고 자료 (선택)
Summary by CodeRabbit
Summary by CodeRabbit
/api/v1/users/onboarding)가 추가되었습니다.