-
Notifications
You must be signed in to change notification settings - Fork 0
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
#224 [refactor] 디자이너 회원가입 service 분리 #225
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구우욷... 고생하셨습니다..
그 Controller만 옮기면 될것 같아욤 ( 보니까 이전 카카오 오픈채팅 API에도 Controller 이동이 안된 것이 있는것 같더라구요..! 그것도 같이 옮기면.. 매우 좋을듯)
@SecurityRequirement(name = "JWT Auth") | ||
@PostMapping(value = "/signup/designer", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) | ||
SuccessResponse<UserCreateResponse> createDesigner( | ||
@Parameter(hidden = true) @UserId Long userId, | ||
@Parameter(hidden = true) @UserId Long designerId, | ||
@RequestPart(value = "profileImg", required = false) MultipartFile profileImg, | ||
@Valid @RequestPart("designerInfo") DesignerCreateRequest designerInfo) { | ||
return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerService.createDesigner(userId, designerInfo, profileImg)); | ||
return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerRegisterService.createDesigner(designerId, designerInfo, profileImg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String profileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); | ||
|
||
User user = userRepository.findById(designerId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); | ||
if (designerJpaRepository.existsById(designerId)) | ||
throw new ConflictException(ErrorCode.ALREADY_EXIST_USER_EXCEPTION); | ||
user.update(request.name(), request.gender(), request.phoneNumber(), request.isMarketingAgree(), profileImgUrl, Role.HAIR_DESIGNER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4:
저는 user정보를 update하는 메소드를 따로 하나 빼고 & 모델 정보 쿼리 날리는 코드 & 추가적으로 더 저장해야하는 부분 메소드로 하나 더 빼서 아래와 같이 모델을 저장했는데요
여기서도 유저 정보 업데이트 & 디자이너 정보 저장 & dayOff 저장 이렇게 크게 3가지로 메소드 구분해서 정리할 수도 있을 것같아요..!!
근데 이러게 되면 또 추후에 파일에 메소드들이 더 추가가 되면 보기 힘들고 어려울 수 있을 것 같긴한데 어느 정도 개념이 너무 분리 되는 것 또는 재사용이 가능할 것 같은 부분이 있다면 고려 해보는 것도 좋을거 같아요!!! (그말즉슥 할람할 말람말~...)
@Transactional
public UserCreateResponse createModel(final Long userId, ModelCreateRequest request) {
if (modelJpaRepository.existsById(userId)) throw new ConflictException(ErrorCode.ALREADY_EXIST_MODEL_EXCEPTION);
updateUserInfos(userId, request.userInfoUpdate());
modelJpaRepository.modelRegister(userId, request.year());
createModelPreferRegions(userId, request.preferRegions());
return authService.createUserToken(userId.toString());
}
private void updateUserInfos(final Long userId, final UserUpdateDto userUpdateDto) {
final User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
user.update(userUpdateDto.name(), userUpdateDto.gender(), userUpdateDto.phoneNumber(), userUpdateDto.isMarketingAgree(), s3Service.getDefaultProfileImageUrl(), Role.MODEL);
}
private void createModelPreferRegions(final Long modelId, final List<Long> preferRegions) {
Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION));
preferRegions.forEach(preferRegionId -> {
Region region = regionJpaRepository.findById(preferRegionId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_REGION_EXCEPTION));
PreferRegion preferRegion = new PreferRegion(model, region);
preferRegionJpaRepository.save(preferRegion);
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
작업하시느라 고생하셨습니다! 코맨트 확인해주세요!
private final UserRepository userRepository; | ||
|
||
@Transactional | ||
public UserCreateResponse createDesigner(Long designerId, DesignerCreateRequest request, MultipartFile profileImg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3
final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다 ~! 👍
…into refactor/#224 # Conflicts: # src/main/java/com/moddy/server/controller/application/ApplicationController.java # src/main/java/com/moddy/server/controller/designer/DesignerController.java
관련 이슈번호
해결하는 데 얼마나 걸렸나요? (예상 작업 시간 / 실제 작업 시간)
해결하려는 문제가 무엇인가요?
어떻게 해결했나요?