Skip to content

Commit

Permalink
#109 [fix] 클릭상태 변경하는 메소드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
hellozo0 committed Jan 12, 2024
1 parent 4c232ff commit 8b80ebd
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 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,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);
}
Expand Down

0 comments on commit 8b80ebd

Please sign in to comment.