Skip to content

Commit 8d39a9b

Browse files
committed
refactor: 유저조회 id 활용하게 수정
1 parent c54fc4f commit 8d39a9b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/main/java/com/example/log4u/domain/user/controller/UserController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ public ResponseEntity<UserProfileResponseDto> getMyProfile(
9090
return ResponseEntity.ok(userProfileResponseDto);
9191
}
9292

93-
@GetMapping("/{nickname}")
93+
@GetMapping("/{id}")
9494
public ResponseEntity<UserProfileResponseDto> getUserProfile(
9595
@AuthenticationPrincipal CustomOAuth2User customOAuth2User,
96-
@PathVariable String nickname
96+
@PathVariable Long id
9797
) {
9898
UserProfileResponseDto userProfileResponseDto =
99-
userService.getUserProfile(nickname);
99+
userService.getUserProfileById(id);
100100
return ResponseEntity.ok(userProfileResponseDto);
101101
}
102102

src/main/java/com/example/log4u/domain/user/service/UserService.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ public UserProfileResponseDto getMyProfile(Long userId) {
3838
);
3939
}
4040

41-
public UserProfileResponseDto getUserProfile(String nickname) {
42-
User target = getUserByNickname(nickname);
43-
final Long targetId = target.getUserId();
41+
public UserProfileResponseDto getUserProfileById(Long id) {
42+
User target = getUserById(id);
4443

4544
return UserProfileResponseDto.fromUser(
4645
target,
47-
followRepository.countByTargetId(targetId),
48-
followRepository.countByInitiatorId(targetId)
46+
followRepository.countByTargetId(id),
47+
followRepository.countByInitiatorId(id)
4948
);
5049
}
5150

0 commit comments

Comments
 (0)