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

#257 [feat] 모델 메인뷰 API의 제안 상태 정보 추가 #259

Merged
merged 9 commits into from
Mar 3, 2024
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.moddy.server.controller.model.dto.response;

import com.moddy.server.domain.prefer_offer_condition.OfferCondition;
import com.moddy.server.domain.hair_service_offer.OfferStatus;

import java.util.List;

public record OfferResponse(
Expand All @@ -9,6 +10,6 @@ public record OfferResponse(
String name,
String shopName,
List<String> conditions,
boolean isClicked
OfferStatus status
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;

import java.time.LocalDateTime;
Copy link
Member

Choose a reason for hiding this comment

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

p3
사용하지 않는 import 인 것 같습니다!


@Entity
@Getter
@Builder
Expand Down Expand Up @@ -50,11 +48,8 @@ public HairServiceOffer(HairModelApplication hairModelApplication, Model model,
this.isClicked = isClicked;
}

public void agreeOfferToModel(){
this.isModelAgree = true;
}
public void agreeOfferToModel() { this.isModelAgree = true; }

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


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.moddy.server.domain.hair_service_offer;

import lombok.Getter;

@Getter
public enum OfferStatus {
EXPIRED, UNCLICKED, CLICKED
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public DownloadUrlResponseDto getApplicationCaptureDownloadUrl(final Long applic
return new DownloadUrlResponseDto(applicationDownloadUrl);
}

public boolean getApplicationExpiredStatus(final Long applicationId){
final HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId)
.orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION));
return hairModelApplication.isExpired();
}

private Page<HairModelApplication> findApplicationsByPaging(final int page, final int size) {
PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "id"));
Page<HairModelApplication> applicationPage = hairModelApplicationJpaRepository.findAll(pageRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.moddy.server.controller.offer.dto.response.OfferInfoResponse;
import com.moddy.server.domain.designer.Designer;
import com.moddy.server.domain.hair_service_offer.HairServiceOffer;
import com.moddy.server.domain.hair_service_offer.OfferStatus;
import com.moddy.server.domain.hair_service_offer.repository.HairServiceOfferJpaRepository;
import com.moddy.server.domain.model.ModelApplyStatus;
import com.moddy.server.domain.prefer_offer_condition.OfferCondition;
Expand Down Expand Up @@ -116,13 +117,22 @@ private List<OfferResponse> getModelMainOfferList(final Page<HairServiceOffer> o
return offerCondition.getOfferCondition().getValue();
}).collect(Collectors.toList());

OfferResponse offerResponse = new OfferResponse(offer.getId(), designer.getProfileImgUrl(), designer.getName(), designer.getHairShop().getName(), offerConditionTop2List, offer.isClicked());
OfferResponse offerResponse = new OfferResponse(offer.getId(), designer.getProfileImgUrl(), designer.getName(), designer.getHairShop().getName(), offerConditionTop2List, calOfferStatus(offer));
return offerResponse;
}).collect(Collectors.toList());

return offerResponseList;
}

private OfferStatus calOfferStatus(final HairServiceOffer hairServiceOffer){
if(hairModelApplicationRetrieveService.getApplicationExpiredStatus(hairServiceOffer.getHairModelApplication().getId())){
return OfferStatus.EXPIRED;
} else if (hairServiceOffer.isClicked()){
return OfferStatus.CLICKED;
}
return OfferStatus.UNCLICKED;
}

private Page<HairServiceOffer> findOffersByPaging(final Long modelId, final int page, final int size) {
PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt"));
Page<HairServiceOffer> offerPage = hairServiceOfferJpaRepository.findByModelId(modelId, pageRequest);
Expand Down
Loading