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

유저 닉네임 변경 API 쿼리 변수 어노테이션 버그 개선 #105

Merged
merged 3 commits into from
Feb 18, 2023
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 @@ -113,7 +113,7 @@ public ResponseEntity<UserThumbnailResponseDto> my(Authentication authentication
@PatchMapping("/{id}")
public ResponseEntity<? extends HttpEntity> updateUserName(Authentication authentication,
@Parameter(name = "id", description = "유저 ID", in = ParameterIn.PATH) @Valid @PathVariable("id") Long artworkId,
@Parameter(name = "name", description = "변경할 닉네임", in = ParameterIn.QUERY) @Valid @PathVariable("name") String name) {
@Parameter(name = "name", description = "변경할 닉네임", in = ParameterIn.QUERY) @Valid @RequestParam("name") String name) {

Long userId = getUserId(authentication);
userService.updateUserName(userId, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public User findById(Long id) {
return userRepository.findById(id).orElseThrow(UserNotFoundException::new);
}

public void updateUserName(Long userId, String name) {
User user = findById(userId);
user.setName(name);
}

@Transactional
public CreateUserResponseDto register(String uid, String username, String picture) {
User user = findByUid(uid)
Expand All @@ -56,4 +51,10 @@ public UserDetails loadUserByUsername(String username) {
.authorities("user")
.build();
}

@Transactional
public void updateUserName(Long userId, String name) {
User user = findById(userId);
user.setName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UserServiceTest {
UserService userService;

@Test
public void updateUserName() throws Exception {
public void updateUserName() {
User user = userRepository.save(User.create("sample-uid", "sample-name", "sample-picture"));

userService.updateUserName(user.getId(), "sample-name-2");
Expand Down