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

#224 [refactor] 디자이너 회원가입 service 분리 #225

Merged
merged 8 commits into from
Feb 7, 2024

Conversation

pkl0912
Copy link
Contributor

@pkl0912 pkl0912 commented Jan 31, 2024

관련 이슈번호

해결하는 데 얼마나 걸렸나요? (예상 작업 시간 / 실제 작업 시간)

  • 30m

해결하려는 문제가 무엇인가요?

  • service 분리 및 hairshop, portfolio builder 제거

어떻게 해결했나요?

  • 디자이너 회원가입 desigerRegisterService 변경, builder 삭제

@pkl0912 pkl0912 requested review from hellozo0 and KWY0218 January 31, 2024 10:33
@pkl0912 pkl0912 self-assigned this Jan 31, 2024
@pkl0912 pkl0912 changed the title #224 [refactor] #224 [refactor] 디자이너 회원가입 service 분리 Jan 31, 2024
Copy link
Member

@hellozo0 hellozo0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구우욷... 고생하셨습니다..
그 Controller만 옮기면 될것 같아욤 ( 보니까 이전 카카오 오픈채팅 API에도 Controller 이동이 안된 것이 있는것 같더라구요..! 그것도 같이 옮기면.. 매우 좋을듯)

Comment on lines 74 to 80
@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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2 :
저는 Controller랑 Service 파일 둘다 옮겨서 진행했는데 ...!
AuthController에 있는 해당 로직은 DesignerController로 옮겨야할것 같아요!!
스크린샷 2024-02-01 오전 1 24 25

Comment on lines 39 to 44
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);
Copy link
Member

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);
        });
    }

Copy link
Member

@KWY0218 KWY0218 left a 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3
final

Copy link
Member

@KWY0218 KWY0218 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다 ~! 👍

pkl0912 added 2 commits February 7, 2024 13:33
…into refactor/#224

# Conflicts:
#	src/main/java/com/moddy/server/controller/application/ApplicationController.java
#	src/main/java/com/moddy/server/controller/designer/DesignerController.java
@pkl0912 pkl0912 merged commit cfdb1ac into develop Feb 7, 2024
1 check passed
@pkl0912 pkl0912 deleted the refactor/#224 branch February 7, 2024 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] 디자이너 회원가입 service 분리
3 participants