-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] 유저 프로필 조회 API 리팩토링 #105
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,14 @@ Content-Type: application/json | |
| client.global.set("accessToken", response.body.data.accessToken); | ||
| %} | ||
|
|
||
| ### 유저 정보 조회 | ||
| ### 유저 정보 조회 (로그인) | ||
| GET http://localhost:8080/api/v1/users/1 | ||
| Authorization: Bearer {{accessToken}} | ||
|
|
||
| ### 유저 정보 조회 (비로그인) | ||
| GET http://localhost:8080/api/v1/users/1 | ||
|
|
||
|
|
||
| ### 유저 프로필 이미지 변경 | ||
| PATCH http://localhost:8080/api/v1/users/profile-image | ||
| Authorization: Bearer {{accessToken}} | ||
|
|
@@ -64,7 +68,7 @@ Content-Type: application/json | |
| } | ||
|
|
||
| ### 팔로우 요청 | ||
| POST http://localhost:8080/api/v1/users/follow?followNickname=팔로우 대상 | ||
| POST http://localhost:8080/api/v1/users/follow?followNickname=user0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트 데이터 일관성을 확인하세요. 라인 67에서 생성한 테스트 유저의 닉네임은 "팔로우 대상"인데, 라인 71의 팔로우 요청은 "user0"을 대상으로 하고 있습니다. "user0" 유저가 사전에 존재하지 않는다면 이 테스트는 실패할 수 있습니다. 테스트 데이터를 일관되게 수정하세요: -POST http://localhost:8080/api/v1/users/follow?followNickname=user0
+POST http://localhost:8080/api/v1/users/follow?followNickname=팔로우 대상또는 "user0" 유저가 별도로 생성되는 것이 의도된 것이라면, 해당 유저를 생성하는 테스트 케이스를 추가하거나 주석으로 명시해주세요. 🤖 Prompt for AI Agents |
||
| Authorization: Bearer {{accessToken}} | ||
|
|
||
| ### 팔로우 취소 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion | 🟠 Major
중복 코드를 제거하여 유지보수성을 개선하세요.
새로운 팩토리 메서드가 기존
from(User)메서드와 거의 동일한 코드를 중복하고 있습니다. 이는 DRY 원칙을 위반하며, 향후 필드 추가 시 두 메서드를 모두 수정해야 하는 유지보수 부담을 발생시킵니다.다음과 같이 기존 메서드를 재사용하도록 리팩토링하세요:
public static UserInfoResponse from(User user, Boolean isFollow) { - return UserInfoResponse.builder() - .userId(user.getId()) - .email(user.getEmail()) - .nickName(user.getNickName()) - .mbti(user.getMbti()) - .profileImage(user.getProfileImage()) - .profileMessage(user.getProfileMessage()) - .followeesCnt(user.getFolloweesCnt()) - .followersCnt(user.getFollowersCnt()) - .groupJoinedCnt(user.getGroupJoinedCnt()) - .groupCreatedCnt(user.getGroupCreatedCnt()) - .isNotificationEnabled(user.getNotificationEnabled()) - .isFollow(isFollow) - .createdAt(user.getCreatedAt()) - .build(); + UserInfoResponse response = from(user); + return response.toBuilder() + .isFollow(isFollow) + .build(); }참고: 위 해결책은 Lombok의
@Builder가 자동으로 생성하는toBuilder()메서드를 활용합니다. 만약toBuilder옵션이 활성화되어 있지 않다면, 클래스 선언에@Builder(toBuilder = true)를 추가해야 합니다.🤖 Prompt for AI Agents