From 862ffed5fd475b769963ea0b2e426dfc54586216 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 16:50:16 +0900 Subject: [PATCH 1/8] =?UTF-8?q?#257=20[feat]=20=EC=A0=9C=EC=95=88=EC=84=9C?= =?UTF-8?q?=EC=9D=98=20=EC=83=81=ED=83=9C=20enum=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/hair_service_offer/OfferStatus.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/moddy/server/domain/hair_service_offer/OfferStatus.java diff --git a/src/main/java/com/moddy/server/domain/hair_service_offer/OfferStatus.java b/src/main/java/com/moddy/server/domain/hair_service_offer/OfferStatus.java new file mode 100644 index 00000000..4a82afbb --- /dev/null +++ b/src/main/java/com/moddy/server/domain/hair_service_offer/OfferStatus.java @@ -0,0 +1,8 @@ +package com.moddy.server.domain.hair_service_offer; + +import lombok.Getter; + +@Getter +public enum OfferStatus { + EXPIRED, UNCLICKED, CLICKED +} From 979e13e00102644756058be95f2fcbceffa88b63 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 16:52:20 +0900 Subject: [PATCH 2/8] =?UTF-8?q?#257=20[feat]=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=EB=B7=B0=20=EC=9D=91=EB=8B=B5Dto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/model/dto/response/OfferResponse.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/dto/response/OfferResponse.java b/src/main/java/com/moddy/server/controller/model/dto/response/OfferResponse.java index fb5d86f6..d091f7c0 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/response/OfferResponse.java +++ b/src/main/java/com/moddy/server/controller/model/dto/response/OfferResponse.java @@ -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( @@ -9,6 +10,6 @@ public record OfferResponse( String name, String shopName, List conditions, - boolean isClicked + OfferStatus status ) { } From 589ec3f2d878e5cc22cbc1b6acb087be75100ae3 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 18:05:25 +0900 Subject: [PATCH 3/8] =?UTF-8?q?#257=20[feat]=20=EC=A0=9C=EC=95=88=EC=84=9C?= =?UTF-8?q?=EC=9D=98=20=EB=A7=8C=EB=A3=8C=EC=97=AC=EB=B6=80=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=ED=95=98=EB=8A=94=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/hair_service_offer/HairServiceOffer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 404cef13..fbc9324e 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 @@ -8,7 +8,7 @@ import jakarta.validation.constraints.NotNull; import lombok.*; -import java.time.LocalDateTime; +import java.time.LocalDate; @Entity @Getter @@ -50,11 +50,14 @@ 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; } + public boolean isExpired() { + LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate(); + LocalDate currentDate = LocalDate.now(); + return currentDate.isAfter(expiredDate); + } } From 4b5dc48efe6be746236a1f88b81cafc18b18b587 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 18:06:04 +0900 Subject: [PATCH 4/8] =?UTF-8?q?#257=20[feat]=20=EC=A0=9C=EC=95=88=EC=84=9C?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EA=B3=84=EC=82=B0=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EB=94=B0=EB=A1=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../offer/HairServiceOfferRetrieveService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java index 623c6476..60feb9ff 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java @@ -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; @@ -116,13 +117,23 @@ private List getModelMainOfferList(final Page 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(hairServiceOffer.isExpired()){ + return OfferStatus.EXPIRED; + } else if (hairServiceOffer.isClicked()){ + return OfferStatus.CLICKED; + } else { + return OfferStatus.UNCLICKED; + } + } + private Page findOffersByPaging(final Long modelId, final int page, final int size) { PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt")); Page offerPage = hairServiceOfferJpaRepository.findByModelId(modelId, pageRequest); From a529130a77d20687077ed742da979c9f101c0a16 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 19:30:51 +0900 Subject: [PATCH 5/8] =?UTF-8?q?#257=20[fix]=20offer=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=EB=A7=8C=EB=A3=8C=EC=9D=BC=EC=9D=B4=20=EC=95=84?= =?UTF-8?q?=EB=8B=8C=20application=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hair_model_application/HairModelApplication.java | 9 +++++++++ .../domain/hair_service_offer/HairServiceOffer.java | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/hair_model_application/HairModelApplication.java b/src/main/java/com/moddy/server/domain/hair_model_application/HairModelApplication.java index 378fb6c1..d03d1736 100644 --- a/src/main/java/com/moddy/server/domain/hair_model_application/HairModelApplication.java +++ b/src/main/java/com/moddy/server/domain/hair_model_application/HairModelApplication.java @@ -10,6 +10,8 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import java.time.LocalDate; + @Entity @Getter @NoArgsConstructor @@ -48,4 +50,11 @@ public HairModelApplication(Model model, HairLength hairLength, String hairDetai this.instagramId = instagramId; this.applicationCaptureUrl = applicationCaptureUrl; } + + public boolean isExpired() { + LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate(); + LocalDate currentDate = LocalDate.now(); + + return currentDate.isAfter(expiredDate); + } } 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 fbc9324e..e494df5c 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 @@ -54,10 +54,4 @@ public HairServiceOffer(HairModelApplication hairModelApplication, Model model, public void updateClickStatus() { this.isClicked = true; } - public boolean isExpired() { - LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate(); - LocalDate currentDate = LocalDate.now(); - - return currentDate.isAfter(expiredDate); - } } From 7df20afda535fceb227bb661e909c35bf1b6da31 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 19:31:27 +0900 Subject: [PATCH 6/8] =?UTF-8?q?#257=20[fix]=20=EC=A7=80=EC=9B=90=EC=84=9C?= =?UTF-8?q?=EC=9D=98=20=EB=A7=8C=EB=A3=8C=20=EC=83=81=ED=83=9C=EB=8A=94=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=EC=84=9C=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=B2=98=EB=A6=AC=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/HairModelApplicationRetrieveService.java | 7 +++++++ .../service/offer/HairServiceOfferRetrieveService.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java index 8213992d..1fabbe26 100644 --- a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java +++ b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java @@ -12,6 +12,7 @@ import com.moddy.server.controller.model.dto.response.ApplicationImgUrlResponse; import com.moddy.server.domain.hair_model_application.HairModelApplication; import com.moddy.server.domain.hair_model_application.repository.HairModelApplicationJpaRepository; +import com.moddy.server.domain.hair_service_offer.OfferStatus; import com.moddy.server.domain.hair_service_record.HairServiceRecord; import com.moddy.server.domain.hair_service_record.repository.HairServiceRecordJpaRepository; import com.moddy.server.domain.prefer_hair_style.PreferHairStyle; @@ -115,6 +116,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 findApplicationsByPaging(final int page, final int size) { PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "id")); Page applicationPage = hairModelApplicationJpaRepository.findAll(pageRequest); diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java index 60feb9ff..97440131 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java @@ -125,7 +125,7 @@ private List getModelMainOfferList(final Page o } private OfferStatus calOfferStatus(final HairServiceOffer hairServiceOffer){ - if(hairServiceOffer.isExpired()){ + if(hairModelApplicationRetrieveService.getApplicationExpiredStatus(hairServiceOffer.getHairModelApplication().getId())){ return OfferStatus.EXPIRED; } else if (hairServiceOffer.isClicked()){ return OfferStatus.CLICKED; From 27a9ea9a2c1175f38fb0e9f86e3849d249197fcc Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:33:35 +0900 Subject: [PATCH 7/8] =?UTF-8?q?#257=20[fix]=20=EC=95=88=EC=93=B0=EB=8A=94?= =?UTF-8?q?=20import=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/hair_service_offer/HairServiceOffer.java | 2 -- .../application/HairModelApplicationRetrieveService.java | 2 -- 2 files changed, 4 deletions(-) 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 e494df5c..0fc7a84c 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 @@ -8,8 +8,6 @@ import jakarta.validation.constraints.NotNull; import lombok.*; -import java.time.LocalDate; - @Entity @Getter @Builder diff --git a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java index 1fabbe26..58e9d893 100644 --- a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java +++ b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java @@ -12,12 +12,10 @@ import com.moddy.server.controller.model.dto.response.ApplicationImgUrlResponse; import com.moddy.server.domain.hair_model_application.HairModelApplication; import com.moddy.server.domain.hair_model_application.repository.HairModelApplicationJpaRepository; -import com.moddy.server.domain.hair_service_offer.OfferStatus; import com.moddy.server.domain.hair_service_record.HairServiceRecord; import com.moddy.server.domain.hair_service_record.repository.HairServiceRecordJpaRepository; import com.moddy.server.domain.prefer_hair_style.PreferHairStyle; import com.moddy.server.domain.prefer_hair_style.repository.PreferHairStyleJpaRepository; -import com.moddy.server.domain.prefer_region.repository.PreferRegionJpaRepository; import com.moddy.server.external.s3.S3Service; import com.moddy.server.service.designer.DesignerRetrieveService; import com.moddy.server.service.model.ModelRetrieveService; From 47b874c189df2d89059dedfab5e16a25a0b999e5 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:34:58 +0900 Subject: [PATCH 8/8] =?UTF-8?q?#257=20[fix]=20=EB=93=A4=EC=97=AC=EC=93=B0?= =?UTF-8?q?=EA=B8=B0=20=EC=B6=95=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/offer/HairServiceOfferRetrieveService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java index 97440131..e6a2b628 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java @@ -129,9 +129,8 @@ private OfferStatus calOfferStatus(final HairServiceOffer hairServiceOffer){ return OfferStatus.EXPIRED; } else if (hairServiceOffer.isClicked()){ return OfferStatus.CLICKED; - } else { - return OfferStatus.UNCLICKED; } + return OfferStatus.UNCLICKED; } private Page findOffersByPaging(final Long modelId, final int page, final int size) {