Skip to content

Commit

Permalink
Merge pull request #107 from TeamSobokSobok/develop
Browse files Browse the repository at this point in the history
[Feat]: 내 닉네임 조회 API (#106)
  • Loading branch information
dev-Crayon authored Mar 5, 2024
2 parents 2e30513 + 046650f commit b3b73e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public Boolean duplicateNickname(String username) {
return userRepository.existsByUsername(username);
}

@Transactional
public String getMyUsername(Long userId) {
User user = UserServiceUtil.findUserById(userRepository, userId);

return user.getUsername();
}

@Transactional
public List<UsernameResponse> getUsername(Long userId, String username) {
UserServiceUtil.existsUserById(userRepository, userId);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/sobok/SobokSobok/auth/ui/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ public class UserController {

private final UserService userService;

@GetMapping("/info")
@Operation(
summary = "내 닉네임 조회 API",
description = "메인 캘린더 뷰에서 사용자의 이름을 나타낼 때 사용합니다."
)
public ResponseEntity<ApiResponse<String>> getUsername(@AuthenticationPrincipal User user) {
return ResponseEntity
.status(HttpStatus.OK)
.body(ApiResponse.success(
SuccessCode.GET_USERNAME_SUCCESS,
userService.getMyUsername(user.getId())
));
}

@GetMapping("")
@Operation(
summary = "닉네임 중복 확인 API 메서드",
Expand Down

0 comments on commit b3b73e0

Please sign in to comment.