Skip to content
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

[Feat]: 내 닉네임 조회 API (#106) #107

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading