Skip to content

[Feat] 유저 정보 조회 및 수정 API 추가 - #20

Merged
kosy00 merged 5 commits into
developfrom
feat/9-user-api
Jun 25, 2026
Merged

[Feat] 유저 정보 조회 및 수정 API 추가#20
kosy00 merged 5 commits into
developfrom
feat/9-user-api

Conversation

@kosy00

@kosy00 kosy00 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

관련 이슈

closes #9

구현 내용

내 정보 조회 및 수정 로직 구현

변경 사항

  • UserController 작성 (내 정보 조회, 수정)

  • UserResponseDto 작성

  • UserUpdateRequestDto 작성

  • UserService 작성

    • 내 정보 조회 로직 (@AuthenticationPrincipal 활용)
    • 내 정보 수정 로직 (닉네임, 연락처)

체크리스트

  • 코드 구현 완료
  • 동작 확인
  • 불필요한 코드/주석 제거

Summary by CodeRabbit

  • New Features
    • 내 정보 조회 및 수정 API가 추가되었습니다. (GET /api/users/me, PATCH /api/users/me)
    • 사용자 프로필 정보(닉네임, 전화번호)를 부분 수정할 수 있습니다.
    • 사용자 응답에 이메일, 역할, 평점, 프로필 이미지 등 표시 정보가 포함됩니다.
  • Bug Fixes
    • 수정 요청에서 일부 값만 보내도 나머지 기존 정보는 유지되도록 개선되었습니다.
    • 사용자 정보가 없을 경우 적절한 오류로 처리됩니다.
  • Bug Fixes
    • 인증 실패 시 JSON 형식의 에러 응답으로 일관되게 반환됩니다.

@kosy00 kosy00 self-assigned this Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35848191-9727-43c5-a020-d19c69949ed8

📥 Commits

Reviewing files that changed from the base of the PR and between 734c3c6 and 64f5407.

📒 Files selected for processing (2)
  • src/main/java/com/ilson/spotwork/domain/user/dto/UserUpdateRequestDto.java
  • src/main/java/com/ilson/spotwork/infra/security/SecurityConfig.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/ilson/spotwork/domain/user/dto/UserUpdateRequestDto.java

📝 Walkthrough

Walkthrough

내 정보 조회와 수정 API가 /api/users/me에 추가되었습니다. 사용자 응답 DTO와 수정 요청 DTO가 도입되었고, 서비스는 사용자 조회 후 예외 처리와 부분 갱신을 수행하며, 컨트롤러는 인증된 사용자 ID를 사용해 응답을 반환합니다. 인증 실패 시에는 JSON 형식의 401 응답이 반환되도록 변경되었습니다.

Changes

내 정보 조회/수정 API

Layer / File(s) Summary
DTO 정의
src/main/java/com/ilson/spotwork/domain/user/dto/UserResponseDto.java, src/main/java/com/ilson/spotwork/domain/user/dto/UserUpdateRequestDto.java
UserResponseDtoUser의 주요 필드를 담아 생성되고, UserUpdateRequestDto가 닉네임과 연락처 수정 요청 바디를 정의합니다.
조회 및 수정 서비스
src/main/java/com/ilson/spotwork/domain/user/service/UserService.java, src/main/java/com/ilson/spotwork/domain/user/entity/User.java
UserService가 사용자 조회 실패 시 USER_NOT_FOUND를 던지고 조회 결과를 응답 DTO로 변환하며, 수정 시 User.updateInfo(...)로 닉네임과 연락처를 선택적으로 갱신합니다.
내 정보 엔드포인트
src/main/java/com/ilson/spotwork/domain/user/controller/UserController.java
GET /api/users/mePATCH /api/users/meCustomUserDetails의 사용자 ID를 사용해 서비스 메서드를 호출하고 ApiResponse.success로 응답합니다.

인증 실패 JSON 응답

Layer / File(s) Summary
인증 실패 응답 처리
src/main/java/com/ilson/spotwork/infra/security/SecurityConfig.java
authenticationEntryPoint가 인증 실패 시 401 상태와 JSON 응답 본문을 직접 작성하도록 변경됩니다.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant UserController
  participant CustomUserDetails
  participant UserService
  participant UserRepository
  participant User

  Client->>UserController: GET /api/users/me
  UserController->>CustomUserDetails: getId()
  CustomUserDetails-->>UserController: userId
  UserController->>UserService: getMyInfo(userId)
  UserService->>UserRepository: findById(userId)
  UserRepository-->>UserService: User
  UserService-->>UserController: UserResponseDto
  UserController-->>Client: ApiResponse.success(...)

  Client->>UserController: PATCH /api/users/me
  UserController->>CustomUserDetails: getId()
  CustomUserDetails-->>UserController: userId
  UserController->>UserService: updateMyInfo(userId, request)
  UserService->>UserRepository: findById(userId)
  UserRepository-->>UserService: User
  UserService->>User: updateInfo(nickname, phone)
  UserService-->>UserController: UserResponseDto
  UserController-->>Client: ApiResponse.success(...)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • kosy00/ilson#14: SecurityConfig의 401 JSON 응답 처리를 같은 파일의 이전 변경과 함께 다룹니다.
  • kosy00/ilson#19: SecurityConfig#filterChain의 인증 경로 설정과 이번 PR의 authenticationEntryPoint 변경이 같은 보안 설정 흐름에 있습니다.

Suggested labels

feat

Poem

🐰 팔짝, /api/users/me로 뛰어가
닉네임과 전화번호를 살포시 다듬고
UserResponseDto를 품에 안은 뒤
401도 JSON으로 또박또박 전해요
오늘도 귀가 쫑긋, 토끼 발자국 반짝 ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 요구사항과 무관한 SecurityConfig의 인증 실패 JSON 응답 변경이 함께 포함되어 있습니다. 인증 실패 응답 변경은 별도 PR로 분리하거나 #9와의 직접적인 연관성을 설명해 범위를 명확히 해주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 유저 정보 조회/수정 API 추가라는 핵심 변경을 정확히 요약합니다.
Description check ✅ Passed 템플릿의 관련 이슈, 구현 내용, 변경 사항, 체크리스트를 모두 채워 형식 요건을 충족합니다.
Linked Issues check ✅ Passed UserController, DTO, UserService, @AuthenticationPrincipal 기반 조회/수정 로직이 #9의 요구사항을 충족합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/9-user-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/java/com/ilson/spotwork/domain/user/entity/User.java (1)

42-44: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

updateInfo에서 공백 문자열 업데이트를 차단하는 게 안전합니다.

현재는 ""/" "도 유효 업데이트로 반영됩니다. 도메인 메서드에서 hasText 기준으로 막아두는 편이 무결성에 유리합니다.

예시 수정안
+import org.springframework.util.StringUtils;

 public void updateInfo(String nickname, String phone) {
-    if (nickname != null) this.nickname = nickname;
-    if (phone != null) this.phone = phone;
+    if (StringUtils.hasText(nickname)) this.nickname = nickname.trim();
+    if (StringUtils.hasText(phone)) this.phone = phone.trim();
 }
🤖 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/ilson/spotwork/domain/user/entity/User.java` around lines
42 - 44, The User.updateInfo method currently accepts empty or whitespace-only
values as valid updates, so tighten the checks in updateInfo(String nickname,
String phone) to ignore blank input by using a hasText-style condition before
assigning nickname and phone. Keep the change localized to the User entity’s
updateInfo logic so only meaningful non-empty values are applied and existing
non-null behavior remains intact.
🤖 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/ilson/spotwork/domain/user/dto/UserUpdateRequestDto.java`:
- Around line 5-10: `UserUpdateRequestDto`의 `nickname`과 `phone`에 필드 검증 어노테이션이 없어
`@Valid`가 실제로 동작하지 않습니다. `LoginRequestDto`, `SignupRequestDto`처럼 이 DTO에도 각 필드에
문자열 비어있음/형식 불일치를 막는 제약조건을 추가하고, `UserUpdateRequestDto`의 두 필드에 적절한 검증 어노테이션을 붙여
일관된 요청 검증이 되도록 수정하세요.

---

Nitpick comments:
In `@src/main/java/com/ilson/spotwork/domain/user/entity/User.java`:
- Around line 42-44: The User.updateInfo method currently accepts empty or
whitespace-only values as valid updates, so tighten the checks in
updateInfo(String nickname, String phone) to ignore blank input by using a
hasText-style condition before assigning nickname and phone. Keep the change
localized to the User entity’s updateInfo logic so only meaningful non-empty
values are applied and existing non-null behavior remains intact.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e659101-952e-4a46-9f2a-335497a4fbdf

📥 Commits

Reviewing files that changed from the base of the PR and between 1169572 and 734c3c6.

📒 Files selected for processing (5)
  • src/main/java/com/ilson/spotwork/domain/user/controller/UserController.java
  • src/main/java/com/ilson/spotwork/domain/user/dto/UserResponseDto.java
  • src/main/java/com/ilson/spotwork/domain/user/dto/UserUpdateRequestDto.java
  • src/main/java/com/ilson/spotwork/domain/user/entity/User.java
  • src/main/java/com/ilson/spotwork/domain/user/service/UserService.java

@kosy00
kosy00 merged commit bf5d761 into develop Jun 25, 2026
2 checks passed
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.

[Feat] 내 정보 조회 / 수정 API

1 participant