From 56ee845fda9c142d93c11510728ca2ed294f8d7b Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:29:25 +0900 Subject: [PATCH 1/5] =?UTF-8?q?#260=20[feat]=20=EB=A7=8C=EB=A3=8C=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=20response=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ApplicationExpireDateResponse.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/moddy/server/controller/application/dto/response/ApplicationExpireDateResponse.java diff --git a/src/main/java/com/moddy/server/controller/application/dto/response/ApplicationExpireDateResponse.java b/src/main/java/com/moddy/server/controller/application/dto/response/ApplicationExpireDateResponse.java new file mode 100644 index 00000000..81b06795 --- /dev/null +++ b/src/main/java/com/moddy/server/controller/application/dto/response/ApplicationExpireDateResponse.java @@ -0,0 +1,6 @@ +package com.moddy.server.controller.application.dto.response; + +public record ApplicationExpireDateResponse( + String expireDate +) { +} From 0543be46f2419c6a37a50eb2fe48969beb26a194 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:29:54 +0900 Subject: [PATCH 2/5] =?UTF-8?q?#260=20[feat]=20Post=20API=EC=97=90=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20data=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ApplicationRegisterController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/application/ApplicationRegisterController.java b/src/main/java/com/moddy/server/controller/application/ApplicationRegisterController.java index d052e89a..0918b4a8 100644 --- a/src/main/java/com/moddy/server/controller/application/ApplicationRegisterController.java +++ b/src/main/java/com/moddy/server/controller/application/ApplicationRegisterController.java @@ -1,9 +1,10 @@ package com.moddy.server.controller.application; import com.moddy.server.common.dto.ErrorResponse; -import com.moddy.server.common.dto.SuccessNonDataResponse; +import com.moddy.server.common.dto.SuccessResponse; import com.moddy.server.common.exception.enums.SuccessCode; import com.moddy.server.config.resolver.user.UserId; +import com.moddy.server.controller.application.dto.response.ApplicationExpireDateResponse; import com.moddy.server.controller.model.dto.request.ModelApplicationRequest; import com.moddy.server.service.application.HairModelApplicationRegisterService; import io.swagger.v3.oas.annotations.Operation; @@ -33,18 +34,17 @@ public class ApplicationRegisterController { @Operation(summary = "[JWT] 모델 지원서 작성", description = "모델 지원서 작성 API입니다.") @ApiResponses({ - @ApiResponse(responseCode = "200", description = "모델 지원서 작성 성공"), + @ApiResponse(responseCode = "200", description = "모델 지원서 작성 성공", content = @Content(schema = @Schema(implementation = ApplicationExpireDateResponse.class))), @ApiResponse(responseCode = "400", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) @SecurityRequirement(name = "JWT Auth") @PostMapping(consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) - public SuccessNonDataResponse submitModelApplication( + public SuccessResponse submitModelApplication( @Parameter(hidden = true) @UserId Long modelId, @RequestPart(value = "modelImgUrl", required = false) MultipartFile modelImgUrl, @RequestPart(value = "applicationCaptureImgUrl", required = false) MultipartFile applicationCaptureImgUrl, @RequestPart(value = "applicationInfo") @Valid ModelApplicationRequest applicationInfo) { - hairModelApplicationRegisterService.postApplication(modelId, modelImgUrl, applicationCaptureImgUrl, applicationInfo); - return SuccessNonDataResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS); + return SuccessResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS, hairModelApplicationRegisterService.postApplication(modelId, modelImgUrl, applicationCaptureImgUrl, applicationInfo)); } } From beaca581b4ee4317e0cc4c7cb1d538202cf8aed9 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:30:14 +0900 Subject: [PATCH 3/5] =?UTF-8?q?#260=20[feat]=20=EB=A7=8C=EB=A3=8C=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EA=B3=84=EC=82=B0=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=EC=9B=90=ED=95=98=EB=8A=94=20=ED=8F=AC=EB=A7=B7=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=B4=EB=82=B4=EB=8A=94=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hair_model_application/HairModelApplication.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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..411da9b7 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 @@ -2,13 +2,14 @@ import com.moddy.server.domain.BaseTimeEntity; import com.moddy.server.domain.model.Model; -import com.moddy.server.domain.user.User; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; @Entity @Getter @@ -48,4 +49,9 @@ public HairModelApplication(Model model, HairLength hairLength, String hairDetai this.instagramId = instagramId; this.applicationCaptureUrl = applicationCaptureUrl; } + + public String calExpireDate(){ + LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate(); + return expiredDate.format(DateTimeFormatter.ofPattern("yyyy. MM. dd.")); + } } From bad0d1fba636b933248d85f33c0e27d614478bee Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 28 Feb 2024 22:30:41 +0900 Subject: [PATCH 4/5] =?UTF-8?q?#260=20[feat]=20Service=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=97=90=20return=20=ED=83=80=EC=9E=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/HairModelApplicationRegisterService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java b/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java index 6e7bd242..461cc832 100644 --- a/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java +++ b/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java @@ -2,6 +2,7 @@ import com.moddy.server.common.exception.enums.ErrorCode; import com.moddy.server.common.exception.model.NotFoundException; +import com.moddy.server.controller.application.dto.response.ApplicationExpireDateResponse; import com.moddy.server.controller.model.dto.request.ModelApplicationRequest; import com.moddy.server.domain.hair_model_application.HairModelApplication; import com.moddy.server.domain.hair_model_application.repository.HairModelApplicationJpaRepository; @@ -29,7 +30,7 @@ public class HairModelApplicationRegisterService { private final ModelJpaRepository modelJpaRepository; @Transactional - public void postApplication(final Long modelId, final MultipartFile modelImgUrl, final MultipartFile applicationCaptureImgUrl, final ModelApplicationRequest applicationInfo) { + public ApplicationExpireDateResponse postApplication(final Long modelId, final MultipartFile modelImgUrl, final MultipartFile applicationCaptureImgUrl, final ModelApplicationRequest applicationInfo) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); String s3ModelImgUrl = s3Service.uploadProfileImage(modelImgUrl, model.getRole()); String s3applicationCaptureImgUrl = s3Service.uploadApplicationImage(applicationCaptureImgUrl); @@ -39,6 +40,8 @@ public void postApplication(final Long modelId, final MultipartFile modelImgUrl, savePreferHairStyles(applicationInfo, hairModelApplication); saveHairServiceRecords(applicationInfo, hairModelApplication); + + return new ApplicationExpireDateResponse(hairModelApplication.calExpireDate()); } public void deleteModelApplications(final Long modelId) { From 587bec870d0bd1dfae4fb429494b03c7b7cb4fe4 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Thu, 29 Feb 2024 18:32:29 +0900 Subject: [PATCH 5/5] =?UTF-8?q?#260=20[fix]=20format=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9D=84=20Service=20=ED=8C=8C=EC=9D=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/hair_model_application/HairModelApplication.java | 6 ++---- .../application/HairModelApplicationRegisterService.java | 3 ++- 2 files changed, 4 insertions(+), 5 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 411da9b7..a96a8b2d 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 @@ -9,7 +9,6 @@ import lombok.NoArgsConstructor; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; @Entity @Getter @@ -50,8 +49,7 @@ public HairModelApplication(Model model, HairLength hairLength, String hairDetai this.applicationCaptureUrl = applicationCaptureUrl; } - public String calExpireDate(){ - LocalDate expiredDate = getCreatedAt().plusDays(7).toLocalDate(); - return expiredDate.format(DateTimeFormatter.ofPattern("yyyy. MM. dd.")); + public LocalDate getExpiredDate(){ + return getCreatedAt().plusDays(7).toLocalDate(); } } diff --git a/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java b/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java index 461cc832..762e7e86 100644 --- a/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java +++ b/src/main/java/com/moddy/server/service/application/HairModelApplicationRegisterService.java @@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import java.time.format.DateTimeFormatter; import java.util.List; @Service @@ -41,7 +42,7 @@ public ApplicationExpireDateResponse postApplication(final Long modelId, final M savePreferHairStyles(applicationInfo, hairModelApplication); saveHairServiceRecords(applicationInfo, hairModelApplication); - return new ApplicationExpireDateResponse(hairModelApplication.calExpireDate()); + return new ApplicationExpireDateResponse(hairModelApplication.getExpiredDate().format(DateTimeFormatter.ofPattern("yyyy. MM. dd."))); } public void deleteModelApplications(final Long modelId) {