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 구현 #85

Merged
merged 12 commits into from
Mar 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.ajou.hertz.domain.user.dto.UserDto;
import com.ajou.hertz.domain.user.dto.request.SignUpRequest;
import com.ajou.hertz.domain.user.dto.request.UpdateContactLinkRequest;
import com.ajou.hertz.domain.user.dto.response.UserContactLinkResponse;
import com.ajou.hertz.domain.user.dto.response.UserEmailResponse;
import com.ajou.hertz.domain.user.dto.response.UserExistenceResponse;
import com.ajou.hertz.domain.user.dto.response.UserResponse;
Expand Down Expand Up @@ -124,12 +123,13 @@ public ResponseEntity<UserResponse> signUpV1(
security = @SecurityRequirement(name = "access-token")
)
@PutMapping(value = "/me/contact-link", headers = API_VERSION_HEADER_NAME + "=" + 1)
public ResponseEntity<UserContactLinkResponse> updateContactLinkV1(
public UserResponse updateContactLinkV1(
@RequestBody @Valid UpdateContactLinkRequest updateContactLinkRequest,
@AuthenticationPrincipal UserPrincipal userPrincipal
) {
userCommandService.updateContactLink(userPrincipal.getUserId(), updateContactLinkRequest.getContactLink());
UserContactLinkResponse response = new UserContactLinkResponse(updateContactLinkRequest.getContactLink());
return ResponseEntity.ok(response);
UserDto userUpdated = userCommandService.updateContactLink(userPrincipal.getUserId(),
updateContactLinkRequest.getContactLink());
UserDto userDto = userQueryService.getDtoById(userPrincipal.getUserId());
return UserResponse.from(userUpdated);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ private String generateRandom16CharString() {
}

/**
* 연락 수단을 변경합니다.
*연락 수단을 변경합니다.
*
* @param userId 유저 ID
* @param contactLink 변경할 연락 수단
*@param userId 유저ID
*@param contactLink 변경할 연락 수단
*
*@return 변경된 유저 정보
*/
public void updateContactLink(Long userId, String contactLink) {
public UserDto updateContactLink(Long userId, String contactLink) {
User user = userQueryService.getById(userId);
user.changeContactLink(contactLink);
return UserDto.from(user);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public void securitySetUp() throws Exception {
String newContactLink = "https://new-contact-link.com";
UpdateContactLinkRequest updateContactLinkRequest = new UpdateContactLinkRequest(newContactLink);
UserDetails userDetails = createTestUser(userId);
willDoNothing().given(userCommandService).updateContactLink(userId, newContactLink);
UserDto updatedUserDto = createUserDto(userId);
given(userCommandService.updateContactLink(userId, newContactLink)).willReturn(updatedUserDto);
given(userQueryService.getDtoById(userId)).willReturn(updatedUserDto);

// when & then
mvc.perform(
Expand All @@ -232,9 +234,10 @@ public void securitySetUp() throws Exception {
)
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.contactLink").value(newContactLink));
.andExpect(jsonPath("$.contactLink").value(updatedUserDto.getContactLink()));

then(userCommandService).should().updateContactLink(userId, newContactLink);
then(userQueryService).should().getDtoById(userId);
verifyEveryMocksShouldHaveNoMoreInteractions();
}

Expand Down
Loading