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

[Fix/#109] 모델 메인뷰에서 상세보기 할시에, isClicked true 처리 #111

Merged
merged 3 commits into from
Jan 12, 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 @@ -45,4 +45,6 @@ public void setIsModelAgree(final Boolean isModelAgree){
this.isModelAgree = isModelAgree;
}

public void updateClickStatus() { this.isClicked = true; }

}
23 changes: 16 additions & 7 deletions src/main/java/com/moddy/server/service/model/ModelService.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ public ModelMainResponse getModelMainInfo(Long userId, int page, int size){
);
}

private DesignerInfoResponse getDesignerInfoResponseList(Long userId, Long offerId){
private DesignerInfoResponse getDesignerInfoResponseList(HairServiceOffer hairServiceOffer, Long userId, Long offerId){

HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION));
Designer designer = designerJpaRepository.findById(hairServiceOffer.getDesigner().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION));

List<DayOff> dayOffList = dayOffJpaRepository.findAllByDesignerId(designer.getId());
Expand All @@ -155,10 +154,9 @@ private DesignerInfoResponse getDesignerInfoResponseList(Long userId, Long offer

}

private StyleDetailResponse getStyleDetailResponse(Long userId, Long offerId) {
private StyleDetailResponse getStyleDetailResponse(HairServiceOffer hairServiceOffer, Long userId, Long offerId) {

HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION));
HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findByUserId(userId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION));
HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(hairServiceOffer.getHairModelApplication().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION));

List<PreferHairStyle> preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(hairServiceOffer.getHairModelApplication().getId());
List<String> hairStyleList = preferHairStyles.stream().map(hairStyle -> {
Expand All @@ -183,10 +181,21 @@ private StyleDetailResponse getStyleDetailResponse(Long userId, Long offerId) {
return styleDetailResponse;
}

private void handleOfferClickStatus(HairServiceOffer hairServiceOffer){

if(!hairServiceOffer.getIsClicked()){
hairServiceOffer.updateClickStatus();
}
}

@Transactional
public DetailOfferResponse getModelDetailOfferInfo(Long userId, Long offerId){

DesignerInfoResponse designerInfoResponseList = getDesignerInfoResponseList(userId, offerId);
StyleDetailResponse styleDetailResponse = getStyleDetailResponse(userId, offerId);
HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION));

DesignerInfoResponse designerInfoResponseList = getDesignerInfoResponseList(hairServiceOffer, userId, offerId);
StyleDetailResponse styleDetailResponse = getStyleDetailResponse(hairServiceOffer, userId, offerId);
handleOfferClickStatus(hairServiceOffer);

return new DetailOfferResponse(designerInfoResponseList, styleDetailResponse);
}
Expand Down