From 8b80ebd579ccb2b8880f8dc5021c046e8068f0e0 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Fri, 12 Jan 2024 19:00:00 +0900 Subject: [PATCH] =?UTF-8?q?#109=20[fix]=20=ED=81=B4=EB=A6=AD=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/model/ModelService.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) 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 c95df33d..4b3d6ae9 100644 --- a/src/main/java/com/moddy/server/service/model/ModelService.java +++ b/src/main/java/com/moddy/server/service/model/ModelService.java @@ -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 dayOffList = dayOffJpaRepository.findAllByDesignerId(designer.getId()); @@ -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 preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(hairServiceOffer.getHairModelApplication().getId()); List hairStyleList = preferHairStyles.stream().map(hairStyle -> { @@ -183,10 +181,22 @@ private StyleDetailResponse getStyleDetailResponse(Long userId, Long offerId) { return styleDetailResponse; } + @Transactional + public 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); }