diff --git a/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java b/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java index e752366c..20922055 100644 --- a/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java +++ b/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java @@ -45,4 +45,6 @@ public void setIsModelAgree(final Boolean isModelAgree){ this.isModelAgree = isModelAgree; } + public void updateClickStatus() { this.isClicked = true; } + } diff --git a/src/main/java/com/moddy/server/service/model/ModelService.java b/src/main/java/com/moddy/server/service/model/ModelService.java index 7d993e60..de10ba51 100644 --- a/src/main/java/com/moddy/server/service/model/ModelService.java +++ b/src/main/java/com/moddy/server/service/model/ModelService.java @@ -138,9 +138,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 dayOffList = dayOffJpaRepository.findAllByDesignerId(designer.getId()); @@ -165,10 +164,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 preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(hairServiceOffer.getHairModelApplication().getId()); List hairStyleList = preferHairStyles.stream().map(hairStyle -> { @@ -193,10 +191,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); }