From 6b3f6bc1898ee9facac7d5c1aa738e872d3e5c79 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 01:04:29 +0900 Subject: [PATCH 01/24] =?UTF-8?q?#133=20[feat]=20aws=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 +-- .../moddy/server/config/sms/AwsSnsConfig.java | 27 ------------------- .../external/sms/impl/AwsSmsServiceImpl.java | 24 ----------------- 3 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 src/main/java/com/moddy/server/config/sms/AwsSnsConfig.java delete mode 100644 src/main/java/com/moddy/server/external/sms/impl/AwsSmsServiceImpl.java diff --git a/build.gradle b/build.gradle index cf3de54a..75c8d5e3 100644 --- a/build.gradle +++ b/build.gradle @@ -25,8 +25,8 @@ repositories { } dependencies { - // coolsms - implementation group: 'io.awspring.cloud', name: 'spring-cloud-aws-messaging', version: '2.3.1' + implementation 'com.squareup.okhttp3:okhttp:4.9.3' + implementation 'com.google.code.gson:gson:2.9.0' //JWT implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2' diff --git a/src/main/java/com/moddy/server/config/sms/AwsSnsConfig.java b/src/main/java/com/moddy/server/config/sms/AwsSnsConfig.java deleted file mode 100644 index 66d14c62..00000000 --- a/src/main/java/com/moddy/server/config/sms/AwsSnsConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.moddy.server.config.sms; - -import com.amazonaws.auth.AWSStaticCredentialsProvider; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.sns.AmazonSNSClient; -import com.amazonaws.services.sns.AmazonSNSClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class AwsSnsConfig { - @Value("${cloud.aws.credentials.accessKey}") - private String accessKey; - @Value("${cloud.aws.credentials.secretKey}") - private String secretKey; - - @Bean - public AmazonSNSClient amazonSNSClient() { - BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); - return (AmazonSNSClient) AmazonSNSClientBuilder - .standard() - .withRegion("ap-northeast-1") - .withCredentials(new AWSStaticCredentialsProvider(credentials)) - .build(); - } -} diff --git a/src/main/java/com/moddy/server/external/sms/impl/AwsSmsServiceImpl.java b/src/main/java/com/moddy/server/external/sms/impl/AwsSmsServiceImpl.java deleted file mode 100644 index 5c81b0d5..00000000 --- a/src/main/java/com/moddy/server/external/sms/impl/AwsSmsServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.moddy.server.external.sms.impl; - -import com.amazonaws.services.sns.AmazonSNSClient; -import com.amazonaws.services.sns.model.PublishRequest; -import com.moddy.server.external.sms.SmsService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class AwsSmsServiceImpl implements SmsService { - private final AmazonSNSClient amazonSNSClient; - private static final String KR = "+82"; - - @Override - public boolean sendSms(String to, String verificationCode) { - PublishRequest request = new PublishRequest(); - request.setMessage(String.format(MESSAGE_FORM, verificationCode)); - request.setPhoneNumber(KR + to); - - amazonSNSClient.publish(request); - return true; - } -} From cac27063b0055982561cc09ac651fe7c82451816 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 01:31:41 +0900 Subject: [PATCH 02/24] =?UTF-8?q?#133=20[feat]=20=EA=B0=80=EB=B9=84?= =?UTF-8?q?=EC=95=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/common/util/SmsUtil.java | 4 +- .../moddy/server/external/sms/SmsService.java | 4 +- .../sms/impl/GabiaSmsServiceImpl.java | 56 +++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java diff --git a/src/main/java/com/moddy/server/common/util/SmsUtil.java b/src/main/java/com/moddy/server/common/util/SmsUtil.java index dd81c39c..966e5bcc 100644 --- a/src/main/java/com/moddy/server/common/util/SmsUtil.java +++ b/src/main/java/com/moddy/server/common/util/SmsUtil.java @@ -4,12 +4,14 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.io.IOException; + @Component @RequiredArgsConstructor public class SmsUtil { private final SmsService smsService; - public boolean sendVerificationCode(String to, String verificationCode) { + public boolean sendVerificationCode(String to, String verificationCode) throws IOException { return smsService.sendSms(to, verificationCode); } } diff --git a/src/main/java/com/moddy/server/external/sms/SmsService.java b/src/main/java/com/moddy/server/external/sms/SmsService.java index db3a4a8f..24c0f09e 100644 --- a/src/main/java/com/moddy/server/external/sms/SmsService.java +++ b/src/main/java/com/moddy/server/external/sms/SmsService.java @@ -1,7 +1,9 @@ package com.moddy.server.external.sms; +import java.io.IOException; + public interface SmsService { String MESSAGE_FORM = "[%s] moddy에서 보낸 인증번호입니다. 해당 인증번호는 3분간 유효합니다."; - boolean sendSms(String to, String verificationCode); + boolean sendSms(String to, String verificationCode) throws IOException; } diff --git a/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java b/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java new file mode 100644 index 00000000..9e8ca28a --- /dev/null +++ b/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java @@ -0,0 +1,56 @@ +package com.moddy.server.external.sms.impl; + +import com.google.gson.Gson; +import com.moddy.server.external.sms.SmsService; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; +import java.util.Objects; + +@Component +public class GabiaSmsServiceImpl implements SmsService { + public static final String SMS_SEND_URL = "https://sms.gabia.com/api/send/sms"; + private static final String SMS_ID = "YOUR_SMS_ID"; // SMS ID 를 입력해 주세요. + private static final String ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"; // ACCESS TOKEN 을 입력해 주세요. + private static final String AUTH_VALUE = Base64.getEncoder() + .encodeToString(String.format("%s:%s", SMS_ID, ACCESS_TOKEN) + .getBytes(StandardCharsets.UTF_8)); + private static final String AUTHORIZATION_CODE = "Basic " + AUTH_VALUE; + + @Override + public boolean sendSms(final String to, final String verificationCode) throws IOException { + OkHttpClient client = new OkHttpClient(); + String message = String.format(MESSAGE_FORM, verificationCode); + + RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM) + .addFormDataPart("phone", "RECEIPT_PHONE_NUMBER") + .addFormDataPart("callback", to) + .addFormDataPart("message", message) + .addFormDataPart("refkey", "YOUR_REF_KEY") + .build(); + + Request request = new Request.Builder() + .url(SMS_SEND_URL) + .post(requestBody) + .addHeader("Content-Type", "application/x-www-form-urlencoded") + .addHeader("Authorization", AUTHORIZATION_CODE) + .addHeader("cache-control", "no-cache") + .build(); + + Response response = client.newCall(request).execute(); + + HashMap result = new Gson().fromJson(Objects.requireNonNull(response.body()).string(), HashMap.class); + for (String key : result.keySet()) { + System.out.printf("%s: %s%n", key, result.get(key)); + } + return true; + } +} From 38d9e9ac3df8ecb00b527fadfd76a113d4839323 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 14:30:16 +0900 Subject: [PATCH 03/24] =?UTF-8?q?#140=20[fix]=20getAge()=20user=20->=20mod?= =?UTF-8?q?el=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/domain/model/Model.java | 8 ++++++++ src/main/java/com/moddy/server/domain/user/User.java | 5 ----- .../moddy/server/service/designer/DesignerService.java | 8 +++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/model/Model.java b/src/main/java/com/moddy/server/domain/model/Model.java index 3dc628d6..56305763 100644 --- a/src/main/java/com/moddy/server/domain/model/Model.java +++ b/src/main/java/com/moddy/server/domain/model/Model.java @@ -7,6 +7,8 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import java.time.LocalDateTime; + @Getter @Entity @NoArgsConstructor @@ -14,4 +16,10 @@ @SuperBuilder public class Model extends User { private String year; + + public Integer getAge(String year) { + LocalDateTime currentDateTime = LocalDateTime.now(); + Integer age = currentDateTime.getYear() - Integer.parseInt(year) + 1; + return age; + } } diff --git a/src/main/java/com/moddy/server/domain/user/User.java b/src/main/java/com/moddy/server/domain/user/User.java index 5eddb860..750f442f 100644 --- a/src/main/java/com/moddy/server/domain/user/User.java +++ b/src/main/java/com/moddy/server/domain/user/User.java @@ -45,11 +45,6 @@ public class User extends BaseTimeEntity { @Enumerated(EnumType.STRING) private Role role; - public Integer getAge(String year) { - LocalDateTime currentDateTime = LocalDateTime.now(); - Integer age = currentDateTime.getYear() - Integer.parseInt(year) + 1; - return age; - } public void update(String name, Gender gender, String phoneNumber, Boolean isMarketingAgree, String profileImgUrl, Role role) { this.name = name; diff --git a/src/main/java/com/moddy/server/service/designer/DesignerService.java b/src/main/java/com/moddy/server/service/designer/DesignerService.java index 16a8cbc8..d824bdac 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerService.java @@ -72,7 +72,6 @@ public class DesignerService { private final UserRepository userRepository; private final HairServiceOfferJpaRepository hairServiceOfferJpaRepository; - private Page findApplications(int page, int size){ PageRequest pageRequest = PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC,"id")); Page applicationPage = hairModelApplicationJpaRepository.findAll(pageRequest); @@ -119,7 +118,7 @@ public UserCreateResponse createDesigner(Long userId, DesignerCreateRequest requ @Transactional public DesignerMainResponse getDesignerMainView(Long userId, int page, int size){ - User user = new User(); + Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); Page applicationPage = findApplications(page, size); @@ -135,7 +134,7 @@ public DesignerMainResponse getDesignerMainView(Long userId, int page, int size) HairModelApplicationResponse applicationResponse = new HairModelApplicationResponse( application.getId(), model.getName(), - user.getAge(model.getYear()), + model.getAge(model.getYear()), model.getProfileImgUrl(), model.getGender().getValue(), top2hairStyles @@ -179,7 +178,6 @@ public void postOffer(Long userId, Long applicationId, OfferCreateRequest reques @Transactional public ApplicationDetailInfoResponse getApplicationDetail(Long userId, Long applicationId){ - User user = new User(); HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); @@ -221,7 +219,7 @@ public ApplicationDetailInfoResponse getApplicationDetail(Long userId, Long appl ModelInfoResponse modelInfoResponse = new ModelInfoResponse( model.getId(), model.getName(), - user.getAge(model.getYear()), + model.getAge(model.getYear()), model.getGender().getValue(), regionList, hairModelApplication.getInstagramId() From 72fd8ec8a0a4521649fcc71527b42300a43d90ec Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 14:37:00 +0900 Subject: [PATCH 04/24] =?UTF-8?q?#140=20[fix]=20=EA=B3=B5=EB=B0=B1=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/domain/model/Model.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/moddy/server/domain/model/Model.java b/src/main/java/com/moddy/server/domain/model/Model.java index 56305763..3a601eeb 100644 --- a/src/main/java/com/moddy/server/domain/model/Model.java +++ b/src/main/java/com/moddy/server/domain/model/Model.java @@ -16,7 +16,6 @@ @SuperBuilder public class Model extends User { private String year; - public Integer getAge(String year) { LocalDateTime currentDateTime = LocalDateTime.now(); Integer age = currentDateTime.getYear() - Integer.parseInt(year) + 1; From 19304076dcdef6e4b0f2247d5a922f58855fef89 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 15:20:00 +0900 Subject: [PATCH 05/24] =?UTF-8?q?#140=20[refactor]=20NOTHING=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java index fe90463f..5c8d5896 100644 --- a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java +++ b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java @@ -11,7 +11,7 @@ @Getter @AllArgsConstructor public enum DayOfWeek { - NOTHING("없음"), MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); + MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); private final String value; From f40dfa4c8f983bb65b229e00b3dcd3151860a9ad Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 15:53:31 +0900 Subject: [PATCH 06/24] =?UTF-8?q?#144=20[feat]=20required=20false=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moddy/server/controller/auth/AuthController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/auth/AuthController.java b/src/main/java/com/moddy/server/controller/auth/AuthController.java index 719e409d..42c2a71c 100644 --- a/src/main/java/com/moddy/server/controller/auth/AuthController.java +++ b/src/main/java/com/moddy/server/controller/auth/AuthController.java @@ -1,7 +1,6 @@ package com.moddy.server.controller.auth; - import com.moddy.server.common.dto.ErrorResponse; import com.moddy.server.common.dto.SuccessNonDataResponse; import com.moddy.server.common.dto.SuccessResponse; @@ -30,7 +29,12 @@ import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -86,7 +90,7 @@ public SuccessResponse> getRegionList() { @PostMapping(value = "/signup/designer", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) SuccessResponse createDesigner( @Parameter(hidden = true) @UserId Long userId, - @RequestPart("profileImg") MultipartFile profileImg, + @RequestPart(value = "profileImg", required = false) MultipartFile profileImg, @RequestPart("designerInfo") DesignerCreateRequest designerInfo) { return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerService.createDesigner(userId, designerInfo, profileImg)); } From 629aae95475a0eafa600dc218edab52b22fe1d6a Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 16:16:28 +0900 Subject: [PATCH 07/24] [feat] check content type add --- src/main/java/com/moddy/server/config/aspect/LoggingAspect.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java b/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java index 097e41fc..ea6be316 100644 --- a/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java +++ b/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java @@ -71,6 +71,7 @@ private String getCommunicationData( sb.append(START_LOG); sb.append(String.format("====> Request: %s %s ({%d}ms)\n====> *Header = {%s}\n", request.getMethod(), request.getRequestURL(), endAt - startAt, getHeaders(request))); + sb.append("=================> content type is ").append(request.getContentType()).append("\n"); if ("POST".equalsIgnoreCase(request.getMethod()) && request.getContentType() != null && request.getContentType().contains(MULTI_PART_FORM_DATA)) { sb.append("====> Body: "); cachingRequest.getParts().stream().map(Part::getName).forEach(n -> { From d18325a62d347648d6838f7dc4a70f837d409ded Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 16:45:40 +0900 Subject: [PATCH 08/24] body log add --- .../java/com/moddy/server/config/aspect/LoggingAspect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java b/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java index ea6be316..0f4fb144 100644 --- a/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java +++ b/src/main/java/com/moddy/server/config/aspect/LoggingAspect.java @@ -73,14 +73,14 @@ private String getCommunicationData( sb.append(String.format("====> Request: %s %s ({%d}ms)\n====> *Header = {%s}\n", request.getMethod(), request.getRequestURL(), endAt - startAt, getHeaders(request))); sb.append("=================> content type is ").append(request.getContentType()).append("\n"); if ("POST".equalsIgnoreCase(request.getMethod()) && request.getContentType() != null && request.getContentType().contains(MULTI_PART_FORM_DATA)) { - sb.append("====> Body: "); + sb.append("====> form-data Body: "); cachingRequest.getParts().stream().map(Part::getName).forEach(n -> { String keyValue = String.format("%s = %s", n, request.getParameter(n)); sb.append(keyValue).append(", "); }); sb.append("\n"); } else if ("POST".equalsIgnoreCase(request.getMethod())) { - sb.append(String.format("====> Body: {%s}\n", objectMapper.readTree(cachingRequest.getContentAsByteArray()))); + sb.append(String.format("====> application/json Body: {%s}\n", objectMapper.readTree(cachingRequest.getContentAsByteArray()))); } if (returnValue != null) { sb.append(String.format("====> Response: {%s}\n", returnValue)); From e2c68e9e2890c328528a6ef447c7f5f6f77250c7 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 16:59:13 +0900 Subject: [PATCH 09/24] =?UTF-8?q?#141[fix]=20dayoff=20=EC=97=86=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EB=B9=88=EB=B0=B0=EC=97=B4=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/model/dto/response/DesignerInfoResponse.java | 3 --- src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java | 2 +- .../server/domain/hair_service_offer/HairServiceOffer.java | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/dto/response/DesignerInfoResponse.java b/src/main/java/com/moddy/server/controller/model/dto/response/DesignerInfoResponse.java index 8260757a..d452c8b0 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/response/DesignerInfoResponse.java +++ b/src/main/java/com/moddy/server/controller/model/dto/response/DesignerInfoResponse.java @@ -1,8 +1,5 @@ package com.moddy.server.controller.model.dto.response; -import com.moddy.server.domain.day_off.DayOfWeek; -import com.moddy.server.domain.user.Gender; - import java.util.List; public record DesignerInfoResponse( diff --git a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java index fe90463f..5c8d5896 100644 --- a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java +++ b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java @@ -11,7 +11,7 @@ @Getter @AllArgsConstructor public enum DayOfWeek { - NOTHING("없음"), MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); + MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); private final String value; 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 e5399a52..f5c2e330 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 @@ -4,7 +4,6 @@ import com.moddy.server.domain.designer.Designer; import com.moddy.server.domain.hair_model_application.HairModelApplication; import com.moddy.server.domain.model.Model; -import com.moddy.server.domain.user.User; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.*; From ff48c1c050e38f87bf54bb8438a58e37019531aa Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 17:31:48 +0900 Subject: [PATCH 10/24] =?UTF-8?q?#140=20[refactor]=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/domain/model/Model.java | 4 ++-- .../com/moddy/server/service/designer/DesignerService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/model/Model.java b/src/main/java/com/moddy/server/domain/model/Model.java index 3a601eeb..2f12c428 100644 --- a/src/main/java/com/moddy/server/domain/model/Model.java +++ b/src/main/java/com/moddy/server/domain/model/Model.java @@ -16,9 +16,9 @@ @SuperBuilder public class Model extends User { private String year; - public Integer getAge(String year) { + public int getAge() { LocalDateTime currentDateTime = LocalDateTime.now(); - Integer age = currentDateTime.getYear() - Integer.parseInt(year) + 1; + Integer age = currentDateTime.getYear() - Integer.parseInt(this.year) + 1; return age; } } diff --git a/src/main/java/com/moddy/server/service/designer/DesignerService.java b/src/main/java/com/moddy/server/service/designer/DesignerService.java index f3521077..88d5ec49 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerService.java @@ -92,7 +92,7 @@ public DesignerMainResponse getDesignerMainInfo(Long userId, int page, int size) HairModelApplicationResponse applicationResponse = new HairModelApplicationResponse( application.getId(), model.getName(), - model.getAge(model.getYear()), + model.getAge(), model.getProfileImgUrl(), model.getGender().getValue(), top2hairStyles @@ -210,7 +210,7 @@ public ApplicationDetailInfoResponse getApplicationDetail(Long userId, Long appl ModelInfoResponse modelInfoResponse = new ModelInfoResponse( model.getId(), model.getName(), - model.getAge(model.getYear()), + model.getAge(), model.getGender().getValue(), regionList, hairModelApplication.getInstagramId() From ffdfaaa49a8253d0ae2055c52f7d39170731bfe6 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Tue, 16 Jan 2024 18:27:20 +0900 Subject: [PATCH 11/24] =?UTF-8?q?=EB=94=94=EC=9E=90=EC=9D=B4=EB=84=88=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/designer/repository/DesignerJpaRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/domain/designer/repository/DesignerJpaRepository.java b/src/main/java/com/moddy/server/domain/designer/repository/DesignerJpaRepository.java index 0c0c58d9..02091670 100644 --- a/src/main/java/com/moddy/server/domain/designer/repository/DesignerJpaRepository.java +++ b/src/main/java/com/moddy/server/domain/designer/repository/DesignerJpaRepository.java @@ -11,7 +11,7 @@ public interface DesignerJpaRepository extends JpaRepository { @Modifying(clearAutomatically = true) - @Query(value = "insert into Designer (id, hair_shop_address, hair_shop_detail_address, hair_shop_name, instagram_url, naver_place_url, introduction, kakao_open_chat_url) VALUES (:id, :hairShopAddress, :hairShopDetailAddress, :hairShopName, :instagramUrl, :naverPlaceUrl, :introduction, :kakaoOpenChatUrl)", nativeQuery = true) + @Query(value = "insert into designer (id, hair_shop_address, hair_shop_detail_address, hair_shop_name, instagram_url, naver_place_url, introduction, kakao_open_chat_url) VALUES (:id, :hairShopAddress, :hairShopDetailAddress, :hairShopName, :instagramUrl, :naverPlaceUrl, :introduction, :kakaoOpenChatUrl)", nativeQuery = true) void designerRegister(@Param("id") Long id, @Param("hairShopAddress") String hairShopAddress, @Param("hairShopDetailAddress") String hairShopDetailAddress, @Param("hairShopName") String hairShopName, @Param("instagramUrl") String instagramUrl, @Param("naverPlaceUrl") String naverPlaceUrl, @Param("introduction") String introduction, @Param("kakaoOpenChatUrl") String kakaoOpenChatUrl); Optional findById(Long userId); From 191841b134dee6a10a8f223b1da4dfac5aea6593 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Tue, 16 Jan 2024 18:32:57 +0900 Subject: [PATCH 12/24] =?UTF-8?q?[hotfix]=20JPQL=20insert=EB=AC=B8=20Model?= =?UTF-8?q?=20->=20model=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/model/repository/ModelJpaRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/domain/model/repository/ModelJpaRepository.java b/src/main/java/com/moddy/server/domain/model/repository/ModelJpaRepository.java index 9b01d072..56859c85 100644 --- a/src/main/java/com/moddy/server/domain/model/repository/ModelJpaRepository.java +++ b/src/main/java/com/moddy/server/domain/model/repository/ModelJpaRepository.java @@ -13,7 +13,7 @@ public interface ModelJpaRepository extends JpaRepository { @Modifying(clearAutomatically = true) - @Query(value = "insert into Model (id, year) VALUES (:id, :year)", nativeQuery = true) + @Query(value = "insert into model (id, year) VALUES (:id, :year)", nativeQuery = true) void modelRegister(@Param("id") Long id, @Param("year") String year); } From 2d66f5758e719dee2418cfd482849d034bfe6c29 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 23:42:16 +0900 Subject: [PATCH 13/24] =?UTF-8?q?#133=20[feat]=20gabia=20sms=20service=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/impl/GabiaSmsServiceImpl.java | 102 ++++++++++++++---- 1 file changed, 79 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java b/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java index 9e8ca28a..ea242b1b 100644 --- a/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java +++ b/src/main/java/com/moddy/server/external/sms/impl/GabiaSmsServiceImpl.java @@ -2,11 +2,13 @@ import com.google.gson.Gson; import com.moddy.server.external.sms.SmsService; +import lombok.extern.slf4j.Slf4j; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.io.IOException; @@ -15,42 +17,96 @@ import java.util.HashMap; import java.util.Objects; +@Slf4j @Component public class GabiaSmsServiceImpl implements SmsService { + public static final String SMS_OAUTH_TOKEN_URL = "https://sms.gabia.com/oauth/token"; public static final String SMS_SEND_URL = "https://sms.gabia.com/api/send/sms"; - private static final String SMS_ID = "YOUR_SMS_ID"; // SMS ID 를 입력해 주세요. - private static final String ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"; // ACCESS TOKEN 을 입력해 주세요. - private static final String AUTH_VALUE = Base64.getEncoder() - .encodeToString(String.format("%s:%s", SMS_ID, ACCESS_TOKEN) - .getBytes(StandardCharsets.UTF_8)); - private static final String AUTHORIZATION_CODE = "Basic " + AUTH_VALUE; + + @Value("${gabia.sms-id}") + private String smsId; + @Value("${gabia.api-key}") + private String apiKey; + @Value("${gabia.caller-phone-number}") + private String from; + @Value("${gabia.ref-key}") + private String refKey; @Override public boolean sendSms(final String to, final String verificationCode) throws IOException { - OkHttpClient client = new OkHttpClient(); - String message = String.format(MESSAGE_FORM, verificationCode); + final String accessToken = getGabiaAccessToken(); + final String smsValue = createAuthValue(accessToken); - RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("phone", "RECEIPT_PHONE_NUMBER") - .addFormDataPart("callback", to) - .addFormDataPart("message", message) - .addFormDataPart("refkey", "YOUR_REF_KEY") - .build(); + final String message = String.format(MESSAGE_FORM, verificationCode); + final RequestBody requestBody = createMessageRequestBody(to, message); + final Request request = createRequest(requestBody, smsValue, SMS_SEND_URL); + final Response response = callExecute(request); + + final HashMap result = getExecuteResult(response); + + final boolean status = result.get("code").equals("200"); + saveLog(status, result); + + return status; + } + + private void saveLog(final boolean status, final HashMap result) { + final StringBuilder sb = new StringBuilder(); + for (String key : result.keySet()) { + sb.append(String.format("%s: %s \n", key, result.get(key))); + } + if (status) log.info(sb.toString()); + else log.error(sb.toString()); + } + + private String createAuthValue(final String key) { + return Base64.getEncoder() + .encodeToString(String.format("%s:%s", smsId, key) + .getBytes(StandardCharsets.UTF_8)); + } + + private String getGabiaAccessToken() throws IOException { + final String authValue = createAuthValue(apiKey); - Request request = new Request.Builder() - .url(SMS_SEND_URL) + final RequestBody requestBody = createAuthRequestBody(); + final Request request = createRequest(requestBody, authValue, SMS_OAUTH_TOKEN_URL); + final Response response = callExecute(request); + + final HashMap result = getExecuteResult(response); + return result.get("access_token"); + } + + private HashMap getExecuteResult(final Response response) throws IOException { + return new Gson().fromJson(Objects.requireNonNull(response.body()).string(), HashMap.class); + } + + private Response callExecute(final Request request) throws IOException { + final OkHttpClient client = new OkHttpClient(); + return client.newCall(request).execute(); + } + + private Request createRequest(final RequestBody requestBody, final String authorization, final String url) { + return new Request.Builder() + .url(url) .post(requestBody) .addHeader("Content-Type", "application/x-www-form-urlencoded") - .addHeader("Authorization", AUTHORIZATION_CODE) + .addHeader("Authorization", "Basic " + authorization) .addHeader("cache-control", "no-cache") .build(); + } - Response response = client.newCall(request).execute(); + private RequestBody createAuthRequestBody() { + return new MultipartBody.Builder().setType(MultipartBody.FORM) + .addFormDataPart("grant_type", "client_credentials") + .build(); + } - HashMap result = new Gson().fromJson(Objects.requireNonNull(response.body()).string(), HashMap.class); - for (String key : result.keySet()) { - System.out.printf("%s: %s%n", key, result.get(key)); - } - return true; + private RequestBody createMessageRequestBody(final String to, final String message) { + return new MultipartBody.Builder().setType(MultipartBody.FORM) + .addFormDataPart("phone", to) + .addFormDataPart("callback", from) + .addFormDataPart("message", message) + .addFormDataPart("refkey", refKey) + .build(); } } From db59646cc674251156022d064b09b3fef82afe94 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 23:42:44 +0900 Subject: [PATCH 14/24] =?UTF-8?q?#133=20[feat]=20sms=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/moddy/server/service/auth/AuthService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moddy/server/service/auth/AuthService.java b/src/main/java/com/moddy/server/service/auth/AuthService.java index 5c0698e8..cc335781 100644 --- a/src/main/java/com/moddy/server/service/auth/AuthService.java +++ b/src/main/java/com/moddy/server/service/auth/AuthService.java @@ -20,12 +20,14 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.io.IOException; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import static com.moddy.server.common.exception.enums.ErrorCode.EXPIRE_VERIFICATION_CODE_EXCEPTION; +import static com.moddy.server.common.exception.enums.ErrorCode.INVALID_PHONE_NUMBER_EXCEPTION; import static com.moddy.server.common.exception.enums.ErrorCode.NOT_FOUND_VERIFICATION_CODE_EXCEPTION; import static com.moddy.server.common.exception.enums.ErrorCode.NOT_MATCH_VERIFICATION_CODE_EXCEPTION; import static com.moddy.server.common.exception.enums.ErrorCode.USER_NOT_FOUND_EXCEPTION; @@ -81,14 +83,15 @@ public UserCreateResponse createUserToken(String useId) { } @Transactional - public void sendVerificationCodeMessageToUser(String phoneNumber) { + public void sendVerificationCodeMessageToUser(String phoneNumber) throws IOException { Optional userVerification = userVerificationRepository.findByPhoneNumber(phoneNumber); if (userVerification.isPresent()) { userVerificationRepository.deleteByPhoneNumber(phoneNumber); } String verificationCode = VerificationCodeGenerator.generate(); - // smsUtil.sendVerificationCode(phoneNumber, verificationCode); + if (!smsUtil.sendVerificationCode(phoneNumber, verificationCode)) + throw new BadRequestException(INVALID_PHONE_NUMBER_EXCEPTION); UserVerification newUserVerification = UserVerification.builder() .phoneNumber(phoneNumber) From 3d6ce6ffa291d87f637c05f405929873c8af3a57 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 16 Jan 2024 23:43:37 +0900 Subject: [PATCH 15/24] =?UTF-8?q?#133=20[feat]=20auth=20controller=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moddy/server/common/exception/enums/ErrorCode.java | 1 + .../com/moddy/server/controller/auth/AuthController.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moddy/server/common/exception/enums/ErrorCode.java b/src/main/java/com/moddy/server/common/exception/enums/ErrorCode.java index a6230dad..f965d22e 100644 --- a/src/main/java/com/moddy/server/common/exception/enums/ErrorCode.java +++ b/src/main/java/com/moddy/server/common/exception/enums/ErrorCode.java @@ -20,6 +20,7 @@ public enum ErrorCode { INVALID_HAIR_SERVICE_RECORD_TERM_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않은 헤어시술 이력기간을 입력했습니다."), INVALID_HAIR_STYLE_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않은 헤어스타일을 입력했습니다."), INVALID_VALUE_TYPE_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않은 타입 값을 입력했습니다."), + INVALID_PHONE_NUMBER_EXCEPTION(HttpStatus.BAD_REQUEST, "유효하지 않은 전화번호를 입력했습니다."), // 401 TOKEN_NOT_CONTAINED_EXCEPTION(HttpStatus.UNAUTHORIZED, "Access Token이 필요합니다."), diff --git a/src/main/java/com/moddy/server/controller/auth/AuthController.java b/src/main/java/com/moddy/server/controller/auth/AuthController.java index 42c2a71c..0efde41c 100644 --- a/src/main/java/com/moddy/server/controller/auth/AuthController.java +++ b/src/main/java/com/moddy/server/controller/auth/AuthController.java @@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import static com.moddy.server.common.exception.enums.SuccessCode.LOGOUT_SUCCESS; @@ -110,15 +111,14 @@ public SuccessResponse createModel( return SuccessResponse.success(SuccessCode.MODEL_CREATE_SUCCESS, modelService.createModel(userId, modelCreateRequest)); } - @Operation(summary = "[SMS 기능 미완성] 인증번호 요청 API", description = "인증번호 요청 API입니다.") + @Operation(summary = "인증번호 요청 API", description = "인증번호 요청 API입니다.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "전화번호 인증 요청 성공입니다."), - @ApiResponse(responseCode = "400", description = "유효하지 않은 카카오 코드를 입력했습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse(responseCode = "404", description = "유효하지 않은 값을 입력했습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "400", description = "유효하지 않은 전화번호를 입력했습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("/phoneNumber") - public SuccessNonDataResponse sendVerificationCodeMessageToUser(@RequestBody PhoneNumberRequestDto phoneNumberRequestDto) { + public SuccessNonDataResponse sendVerificationCodeMessageToUser(@RequestBody PhoneNumberRequestDto phoneNumberRequestDto) throws IOException { authService.sendVerificationCodeMessageToUser(phoneNumberRequestDto.phoneNumber()); return SuccessNonDataResponse.success(SEND_VERIFICATION_CODE_SUCCESS); } From 973e0400a16a8b01cd4dca4686252517aba9849d Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 17 Jan 2024 02:22:00 +0900 Subject: [PATCH 16/24] =?UTF-8?q?#155=20[fix]=20=EC=95=88=EC=93=B0?= =?UTF-8?q?=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/requestEditor/ListPropertyEditor.java | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/main/java/com/moddy/server/controller/model/dto/requestEditor/ListPropertyEditor.java diff --git a/src/main/java/com/moddy/server/controller/model/dto/requestEditor/ListPropertyEditor.java b/src/main/java/com/moddy/server/controller/model/dto/requestEditor/ListPropertyEditor.java deleted file mode 100644 index 8f16fdb1..00000000 --- a/src/main/java/com/moddy/server/controller/model/dto/requestEditor/ListPropertyEditor.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.moddy.server.controller.model.dto.requestEditor; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.util.StringUtils; -import java.beans.PropertyEditorSupport; -import java.io.IOException; -import java.util.List; - - -public class ListPropertyEditor extends PropertyEditorSupport { - - private final Class elementType; - private final ObjectMapper objectMapper; - - public ListPropertyEditor(Class elementType) { - this.elementType = elementType; - this.objectMapper = new ObjectMapper(); - } - - @Override - public void setAsText(String text) throws IllegalArgumentException { - if (StringUtils.hasText(text)) { - try { - List list = objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, elementType)); - setValue(list); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to convert value to List: " + text, e); - } - } else { - setValue(null); - } - } - - @Override - public String getAsText() { - Object value = getValue(); - if (value == null) { - return ""; - } - try { - return objectMapper.writeValueAsString(value); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to convert value to JSON: " + value, e); - } - } -} From 3e354346fa75b1bb6794362362622090eaa479eb Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 17 Jan 2024 02:50:55 +0900 Subject: [PATCH 17/24] =?UTF-8?q?#158=20[fix]=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/service/user/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/service/user/UserService.java b/src/main/java/com/moddy/server/service/user/UserService.java index 87cc1689..c88202c9 100644 --- a/src/main/java/com/moddy/server/service/user/UserService.java +++ b/src/main/java/com/moddy/server/service/user/UserService.java @@ -40,7 +40,7 @@ public class UserService { public UserDetailResponseDto getUserDetail(Long userId) { User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); - return new UserDetailResponseDto(user.getId(), user.getName(), user.getName(), user.getRole()); + return new UserDetailResponseDto(user.getId(), user.getProfileImgUrl(), user.getName(), user.getRole()); } private void deleteModelInfos(Long userId) { From 753129493b2cda4ff80cb50ee375707792085d1d Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 17 Jan 2024 02:51:30 +0900 Subject: [PATCH 18/24] =?UTF-8?q?#158=20[feat]=20pre=20signed=20url=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moddy/server/external/s3/S3Service.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/external/s3/S3Service.java b/src/main/java/com/moddy/server/external/s3/S3Service.java index 8e7d2bc7..d3cfb9e3 100644 --- a/src/main/java/com/moddy/server/external/s3/S3Service.java +++ b/src/main/java/com/moddy/server/external/s3/S3Service.java @@ -1,8 +1,10 @@ package com.moddy.server.external.s3; import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; +import com.amazonaws.services.s3.model.ResponseHeaderOverrides; import com.moddy.server.domain.user.Role; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; @@ -12,7 +14,11 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Date; import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import static com.amazonaws.HttpMethod.GET; @Service @RequiredArgsConstructor @@ -20,6 +26,7 @@ public class S3Service { private final static String APPLICATION_PATH = "APPLICATION"; private final static String MODEL_PROFILE_PATH = "HAIR_MODEL_PROFILE"; private final static String MODEL_PROFILE_IMAGE_NAME = "/model_default_profile.png"; + private final static int EXPIRED_TIME = 3; private final AmazonS3 amazonS3; @Value("${cloud.aws.s3.bucket}") private String bucket; @@ -33,7 +40,7 @@ public String uploadApplicationImage(MultipartFile multipartFile) { return uploadImage(multipartFile, APPLICATION_PATH); } - public String getDefaultProfileImageUrl(){ + public String getDefaultProfileImageUrl() { return amazonS3.getUrl(bucket, MODEL_PROFILE_PATH + MODEL_PROFILE_IMAGE_NAME).toString(); } @@ -51,6 +58,23 @@ private String uploadImage(MultipartFile multipartFile, String path) { } } + public String getPreSignedUrlToDownload(final String fileName) { + GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucket, fileName) + .withMethod(GET) + .withExpiration(getExpiredTime()) + .withResponseHeaders(new ResponseHeaderOverrides().withContentDisposition("attachment")); + + return amazonS3.generatePresignedUrl(generatePresignedUrlRequest).toString(); + } + + private Date getExpiredTime() { + Date expiration = new Date(); + long expTime = expiration.getTime(); + expTime += TimeUnit.MINUTES.toMillis(EXPIRED_TIME); + expiration.setTime(expTime); + return expiration; + } + private String createFileName(String fileName) { return UUID.randomUUID().toString().concat(getFileExtension(fileName)); } From e83b5dcd3eacd64386b23ce2ae04c0101e18aa6e Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 17 Jan 2024 02:52:03 +0900 Subject: [PATCH 19/24] =?UTF-8?q?#158=20[feat]=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/designer/DesignerService.java | 364 +++++++++--------- 1 file changed, 190 insertions(+), 174 deletions(-) diff --git a/src/main/java/com/moddy/server/service/designer/DesignerService.java b/src/main/java/com/moddy/server/service/designer/DesignerService.java index cc0463b2..dd8da0c9 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerService.java @@ -5,7 +5,14 @@ import com.moddy.server.config.jwt.JwtService; import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest; import com.moddy.server.controller.designer.dto.request.OfferCreateRequest; -import com.moddy.server.controller.designer.dto.response.*; +import com.moddy.server.controller.designer.dto.response.ApplicationDetailInfoResponse; +import com.moddy.server.controller.designer.dto.response.ApplicationInfoResponse; +import com.moddy.server.controller.designer.dto.response.DesignerMainResponse; +import com.moddy.server.controller.designer.dto.response.DownloadUrlResponseDto; +import com.moddy.server.controller.designer.dto.response.HairModelApplicationResponse; +import com.moddy.server.controller.designer.dto.response.HairRecordResponse; +import com.moddy.server.controller.designer.dto.response.ModelInfoResponse; +import com.moddy.server.controller.designer.dto.response.UserCreateResponse; import com.moddy.server.domain.day_off.DayOff; import com.moddy.server.domain.day_off.repository.DayOffJpaRepository; import com.moddy.server.domain.designer.Designer; @@ -48,191 +55,200 @@ import java.util.Optional; import java.util.stream.Collectors; - @Service - @RequiredArgsConstructor - @Transactional(readOnly = true) - @Builder - public class DesignerService { - private final DesignerJpaRepository designerJpaRepository; - private final DayOffJpaRepository dayOffJpaRepository; - private final S3Service s3Service; - private final KakaoSocialService kakaoSocialService; - private final KakaoAuthApiClient kakaoAuthApiClient; - private final KakaoApiClient kakaoApiClient; - private final JwtService jwtService; - private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository; - private final PreferHairStyleJpaRepository preferHairStyleJpaRepository; - private final ModelJpaRepository modelJpaRepository; - private final PreferOfferConditionJpaRepository preferOfferConditionJpaRepository; - private final HairServcieRecordJpaRepository hairServiceRecordJpaRepository; - private final AuthService authService; - private final PreferRegionJpaRepository preferRegionJpaRepository; - private final HairServcieRecordJpaRepository hairServcieRecordJpaRepository; - private final UserRepository userRepository; - private final HairServiceOfferJpaRepository hairServiceOfferJpaRepository; - - - @Transactional - public DesignerMainResponse getDesignerMainInfo(Long userId, int page, int size) { - User user = new User(); - Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); - - Page applicationPage = findApplicationsByPaging(page, size); - long totalElements = applicationPage.getTotalElements(); - - List applicationResponsesList = applicationPage.stream().map(application -> { - - Model model = modelJpaRepository.findById(application.getModel().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION)); - - List preferHairStyle = preferHairStyleJpaRepository.findTop2ByHairModelApplicationId(application.getId()); - - List top2hairStyles = preferHairStyle.stream().map(haireStyle -> { - return haireStyle.getHairStyle().getValue(); - }).collect(Collectors.toList()); - - HairModelApplicationResponse applicationResponse = new HairModelApplicationResponse( - application.getId(), - model.getName(), - model.getAge(), - model.getProfileImgUrl(), - model.getGender().getValue(), - top2hairStyles - ); - return applicationResponse; +import static com.moddy.server.common.exception.enums.ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +@Builder +public class DesignerService { + private final DesignerJpaRepository designerJpaRepository; + private final DayOffJpaRepository dayOffJpaRepository; + private final S3Service s3Service; + private final KakaoSocialService kakaoSocialService; + private final KakaoAuthApiClient kakaoAuthApiClient; + private final KakaoApiClient kakaoApiClient; + private final JwtService jwtService; + private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository; + private final PreferHairStyleJpaRepository preferHairStyleJpaRepository; + private final ModelJpaRepository modelJpaRepository; + private final PreferOfferConditionJpaRepository preferOfferConditionJpaRepository; + private final HairServcieRecordJpaRepository hairServiceRecordJpaRepository; + private final AuthService authService; + private final PreferRegionJpaRepository preferRegionJpaRepository; + private final HairServcieRecordJpaRepository hairServcieRecordJpaRepository; + private final UserRepository userRepository; + private final HairServiceOfferJpaRepository hairServiceOfferJpaRepository; + + + @Transactional + public DesignerMainResponse getDesignerMainInfo(Long userId, int page, int size) { + User user = new User(); + Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); + + Page applicationPage = findApplicationsByPaging(page, size); + long totalElements = applicationPage.getTotalElements(); + + List applicationResponsesList = applicationPage.stream().map(application -> { + + Model model = modelJpaRepository.findById(application.getModel().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION)); + + List preferHairStyle = preferHairStyleJpaRepository.findTop2ByHairModelApplicationId(application.getId()); + + List top2hairStyles = preferHairStyle.stream().map(haireStyle -> { + return haireStyle.getHairStyle().getValue(); }).collect(Collectors.toList()); - return new DesignerMainResponse( - page, - size, - totalElements, - designer.getName(), - applicationResponsesList + HairModelApplicationResponse applicationResponse = new HairModelApplicationResponse( + application.getId(), + model.getName(), + model.getAge(), + model.getProfileImgUrl(), + model.getGender().getValue(), + top2hairStyles ); - } - - @Transactional - public UserCreateResponse createDesigner(Long userId, DesignerCreateRequest request, MultipartFile profileImg) { - - String profileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); - - User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); - - user.update(request.name(), request.gender(), request.phoneNumber(), request.isMarketingAgree(), profileImgUrl, Role.HAIR_DESIGNER); - - HairShop hairShop = HairShop.builder() - .name(request.hairShop().name()) - .address(request.hairShop().address()) - .detailAddress(request.hairShop().detailAddress()) - .build(); - Portfolio portfolio = Portfolio.builder() - .instagramUrl(request.portfolio().instagramUrl()) - .naverPlaceUrl(request.portfolio().naverPlaceUrl()) - .build(); - designerJpaRepository.designerRegister(user.getId(), hairShop.getAddress(), hairShop.getDetailAddress(), hairShop.getName(), portfolio.getInstagramUrl(), portfolio.getNaverPlaceUrl(), request.introduction(), request.kakaoOpenChatUrl()); - Designer designer = designerJpaRepository.findById(user.getId()).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); - request.dayOffs().stream() - .forEach(d -> { - DayOff dayOff = DayOff.builder() - .dayOfWeek(d) - .designer(designer) - .build(); - dayOffJpaRepository.save(dayOff); - - }); - return authService.createUserToken(designer.getId().toString()); - } - - - @Transactional - public void postOffer(Long userId, Long applicationId, OfferCreateRequest request) { - Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); - HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); - HairServiceOffer offer = HairServiceOffer.builder() - .model(hairModelApplication.getModel()) - .hairModelApplication(hairModelApplication) - .designer(designer) - .offerDetail(request.offerDetail()) - .isModelAgree(false) - .isClicked(false) - .build(); - hairServiceOfferJpaRepository.save(offer); - - request.preferOfferConditions().stream() - .forEach(p -> { - PreferOfferCondition preferOfferCondition = PreferOfferCondition.builder() - .offerCondition(p) - .hairServiceOffer(offer) - .build(); - preferOfferConditionJpaRepository.save(preferOfferCondition); - - }); - } - - @Transactional - public ApplicationDetailInfoResponse getApplicationDetail(Long userId, Long applicationId) { - User user = new User(); - - HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); - - Model model = modelJpaRepository.findById(hairModelApplication.getModel().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); - - List preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(applicationId); - - List preferhairStyleList = preferHairStyles.stream().map(hairStyle -> { - return hairStyle.getHairStyle().getValue(); - }).collect(Collectors.toList()); + return applicationResponse; + }).collect(Collectors.toList()); + + return new DesignerMainResponse( + page, + size, + totalElements, + designer.getName(), + applicationResponsesList + ); + } - List hairServiceRecords = hairServiceRecordJpaRepository.findAllByHairModelApplicationId(applicationId); - hairServiceRecords.sort(Comparator.comparingInt(e -> e.getServiceRecordTerm().ordinal())); + @Transactional + public UserCreateResponse createDesigner(Long userId, DesignerCreateRequest request, MultipartFile profileImg) { + + String profileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); + + User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); + + user.update(request.name(), request.gender(), request.phoneNumber(), request.isMarketingAgree(), profileImgUrl, Role.HAIR_DESIGNER); + + HairShop hairShop = HairShop.builder() + .name(request.hairShop().name()) + .address(request.hairShop().address()) + .detailAddress(request.hairShop().detailAddress()) + .build(); + Portfolio portfolio = Portfolio.builder() + .instagramUrl(request.portfolio().instagramUrl()) + .naverPlaceUrl(request.portfolio().naverPlaceUrl()) + .build(); + designerJpaRepository.designerRegister(user.getId(), hairShop.getAddress(), hairShop.getDetailAddress(), hairShop.getName(), portfolio.getInstagramUrl(), portfolio.getNaverPlaceUrl(), request.introduction(), request.kakaoOpenChatUrl()); + Designer designer = designerJpaRepository.findById(user.getId()).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); + request.dayOffs().stream() + .forEach(d -> { + DayOff dayOff = DayOff.builder() + .dayOfWeek(d) + .designer(designer) + .build(); + dayOffJpaRepository.save(dayOff); + + }); + return authService.createUserToken(designer.getId().toString()); + } - List preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId()); - List regionList = preferRegions.stream().map(preferregion -> { - return preferregion.getRegion().getName(); - }).collect(Collectors.toList()); + @Transactional + public void postOffer(Long userId, Long applicationId, OfferCreateRequest request) { + Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); + HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); + HairServiceOffer offer = HairServiceOffer.builder() + .model(hairModelApplication.getModel()) + .hairModelApplication(hairModelApplication) + .designer(designer) + .offerDetail(request.offerDetail()) + .isModelAgree(false) + .isClicked(false) + .build(); + hairServiceOfferJpaRepository.save(offer); + + request.preferOfferConditions().stream() + .forEach(p -> { + PreferOfferCondition preferOfferCondition = PreferOfferCondition.builder() + .offerCondition(p) + .hairServiceOffer(offer) + .build(); + preferOfferConditionJpaRepository.save(preferOfferCondition); + + }); + } - List recordResponseList = hairServiceRecords.stream().map(records -> { - HairRecordResponse hairRecordResponse = new HairRecordResponse( - records.getServiceRecordTerm().getValue(), - records.getServiceRecord().getValue() - ); - return hairRecordResponse; - }).collect(Collectors.toList()); + @Transactional + public ApplicationDetailInfoResponse getApplicationDetail(Long userId, Long applicationId) { + User user = new User(); - ApplicationInfoResponse applicationInfoResponse = new ApplicationInfoResponse( - applicationId, - hairModelApplication.getModelImgUrl(), - hairModelApplication.getHairLength().getValue(), - preferhairStyleList, - recordResponseList, - hairModelApplication.getHairDetail(), - getIsSendStatus(applicationId, userId) - ); + HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); - ModelInfoResponse modelInfoResponse = new ModelInfoResponse( - model.getId(), - model.getName(), - model.getAge(), - model.getGender().getValue(), - regionList, - hairModelApplication.getInstagramId() - ); + Model model = modelJpaRepository.findById(hairModelApplication.getModel().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); + + List preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(applicationId); + + List preferhairStyleList = preferHairStyles.stream().map(hairStyle -> { + return hairStyle.getHairStyle().getValue(); + }).collect(Collectors.toList()); + + List hairServiceRecords = hairServiceRecordJpaRepository.findAllByHairModelApplicationId(applicationId); + hairServiceRecords.sort(Comparator.comparingInt(e -> e.getServiceRecordTerm().ordinal())); + + List preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId()); - return new ApplicationDetailInfoResponse( - applicationInfoResponse, - modelInfoResponse + List regionList = preferRegions.stream().map(preferregion -> { + return preferregion.getRegion().getName(); + }).collect(Collectors.toList()); + + List recordResponseList = hairServiceRecords.stream().map(records -> { + HairRecordResponse hairRecordResponse = new HairRecordResponse( + records.getServiceRecordTerm().getValue(), + records.getServiceRecord().getValue() ); - } + return hairRecordResponse; + }).collect(Collectors.toList()); + + ApplicationInfoResponse applicationInfoResponse = new ApplicationInfoResponse( + applicationId, + hairModelApplication.getModelImgUrl(), + hairModelApplication.getHairLength().getValue(), + preferhairStyleList, + recordResponseList, + hairModelApplication.getHairDetail(), + getIsSendStatus(applicationId, userId) + ); + + ModelInfoResponse modelInfoResponse = new ModelInfoResponse( + model.getId(), + model.getName(), + model.getAge(), + model.getGender().getValue(), + regionList, + hairModelApplication.getInstagramId() + ); + + return new ApplicationDetailInfoResponse( + applicationInfoResponse, + modelInfoResponse + ); + } - private Page findApplicationsByPaging(int page, int size) { - PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "id")); - Page applicationPage = hairModelApplicationJpaRepository.findAll(pageRequest); + private Page findApplicationsByPaging(int page, int size) { + PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "id")); + Page applicationPage = hairModelApplicationJpaRepository.findAll(pageRequest); - return applicationPage; - } + return applicationPage; + } + + private Boolean getIsSendStatus(Long applicationId, Long userId) { + Optional offer = hairServiceOfferJpaRepository.findByHairModelApplicationIdAndModelId(applicationId, userId); + return offer.isPresent(); + } - private Boolean getIsSendStatus(Long applicationId, Long userId) { - Optional offer = hairServiceOfferJpaRepository.findByHairModelApplicationIdAndModelId(applicationId, userId); - return offer.isPresent(); - } + public DownloadUrlResponseDto getOfferImageDownloadUrl(final Long userId, final String offerImageUrl) { + //Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); + String s3Key = offerImageUrl.substring(54); + String preSignedUrl = s3Service.getPreSignedUrlToDownload(s3Key); + return new DownloadUrlResponseDto(preSignedUrl); } +} From 95e50b895bb897d792e0c5914c454ceec1792a48 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 17 Jan 2024 02:52:18 +0900 Subject: [PATCH 20/24] =?UTF-8?q?#158=20[feat]=20controller=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/enums/SuccessCode.java | 3 ++- .../designer/DesignerController.java | 27 ++++++++++++++++++- .../dto/request/OfferImageUrlRequestDto.java | 4 +++ .../dto/response/DownloadUrlResponseDto.java | 4 +++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java create mode 100644 src/main/java/com/moddy/server/controller/designer/dto/response/DownloadUrlResponseDto.java diff --git a/src/main/java/com/moddy/server/common/exception/enums/SuccessCode.java b/src/main/java/com/moddy/server/common/exception/enums/SuccessCode.java index 02b2e4d8..f07d5513 100644 --- a/src/main/java/com/moddy/server/common/exception/enums/SuccessCode.java +++ b/src/main/java/com/moddy/server/common/exception/enums/SuccessCode.java @@ -24,7 +24,8 @@ public enum SuccessCode { VERIFICATION_CODE_MATCH_SUCCESS(HttpStatus.OK, "전화번호 인증 성공입니다."), LOGOUT_SUCCESS(HttpStatus.OK, "로그아웃 성공입니다."), CREATE_MODEL_APPLICATION_SUCCESS(HttpStatus.OK, "모델 지원서 생성 성공입니다."), - USER_WITHDRAW_SUCCESS(HttpStatus.OK, "회원 탈퇴 성공입니다."); + USER_WITHDRAW_SUCCESS(HttpStatus.OK, "회원 탈퇴 성공입니다."), + GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공"); private final HttpStatus httpStatus; private final String message; diff --git a/src/main/java/com/moddy/server/controller/designer/DesignerController.java b/src/main/java/com/moddy/server/controller/designer/DesignerController.java index 8dc8eb14..2437ce7e 100644 --- a/src/main/java/com/moddy/server/controller/designer/DesignerController.java +++ b/src/main/java/com/moddy/server/controller/designer/DesignerController.java @@ -6,8 +6,10 @@ import com.moddy.server.common.exception.enums.SuccessCode; import com.moddy.server.config.resolver.user.UserId; import com.moddy.server.controller.designer.dto.request.OfferCreateRequest; +import com.moddy.server.controller.designer.dto.request.OfferImageUrlRequestDto; import com.moddy.server.controller.designer.dto.response.ApplicationDetailInfoResponse; import com.moddy.server.controller.designer.dto.response.DesignerMainResponse; +import com.moddy.server.controller.designer.dto.response.DownloadUrlResponseDto; import com.moddy.server.service.designer.DesignerService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -18,7 +20,15 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static com.moddy.server.common.exception.enums.SuccessCode.GET_PRE_SIGNED_URL_SUCCESS; @RestController @RequestMapping("/designer") @@ -75,4 +85,19 @@ public SuccessResponse getApplicationDetailInfo( return SuccessResponse.success(SuccessCode.MODEL_APPLICATION_DETAil_INFO_SUCCESS, designerService.getApplicationDetail(userId, applicationId)); } + @Operation(summary = "[JWT] 제안서 다운로드 링크", description = "디자이너 제안서 다운로드 링크 불러오는 API") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "모델 지원서 상세 조회 성공", content = @Content(schema = @Schema(implementation = ApplicationDetailInfoResponse.class))), + @ApiResponse(responseCode = "404", description = "해당 디자이너는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + }) + @PostMapping("/offer/download-url") + @SecurityRequirement(name = "JWT Auth") + public SuccessResponse getOfferImageDownloadUrl( + @Parameter(hidden = true) @UserId Long userId, + @RequestBody OfferImageUrlRequestDto offerImageUrlRequestDto + ) { + return SuccessResponse.success(GET_PRE_SIGNED_URL_SUCCESS, designerService.getOfferImageDownloadUrl(userId, offerImageUrlRequestDto.offerImageUrl())); + } + } diff --git a/src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java b/src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java new file mode 100644 index 00000000..6dccba06 --- /dev/null +++ b/src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java @@ -0,0 +1,4 @@ +package com.moddy.server.controller.designer.dto.request; + +public record OfferImageUrlRequestDto(String offerImageUrl) { +} diff --git a/src/main/java/com/moddy/server/controller/designer/dto/response/DownloadUrlResponseDto.java b/src/main/java/com/moddy/server/controller/designer/dto/response/DownloadUrlResponseDto.java new file mode 100644 index 00000000..97b65480 --- /dev/null +++ b/src/main/java/com/moddy/server/controller/designer/dto/response/DownloadUrlResponseDto.java @@ -0,0 +1,4 @@ +package com.moddy.server.controller.designer.dto.response; + +public record DownloadUrlResponseDto(String offerImageUrl) { +} From 5b7a40eaee38dc1a1e3b391c0937aae46b348f2b Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 17 Jan 2024 03:08:46 +0900 Subject: [PATCH 21/24] =?UTF-8?q?#155=20[fix]=20ENUM=EC=97=90=20Valeu=20->?= =?UTF-8?q?=20name=20=EB=B0=94=EA=BE=B8=EB=8A=94=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moddy/server/domain/day_off/DayOfWeek.java | 13 ------------- .../domain/hair_model_application/HairLength.java | 14 -------------- .../domain/hair_service_record/ServiceRecord.java | 14 -------------- .../hair_service_record/ServiceRecordTerm.java | 13 ------------- .../domain/prefer_hair_style/HairStyle.java | 15 --------------- .../java/com/moddy/server/domain/user/Gender.java | 13 +------------ 6 files changed, 1 insertion(+), 81 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java index 5c8d5896..90ddff1c 100644 --- a/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java +++ b/src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java @@ -1,25 +1,12 @@ package com.moddy.server.domain.day_off; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; - @Getter @AllArgsConstructor public enum DayOfWeek { MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); private final String value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DayOfWeek findByDayOfWeek(String dayOfWeek) { - return Stream.of(DayOfWeek.values()) - .filter(c -> c.name().equals(dayOfWeek)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_DAY_OF_WEEK_EXCEPTION)); - } } diff --git a/src/main/java/com/moddy/server/domain/hair_model_application/HairLength.java b/src/main/java/com/moddy/server/domain/hair_model_application/HairLength.java index 4b8a1cca..57dca38c 100644 --- a/src/main/java/com/moddy/server/domain/hair_model_application/HairLength.java +++ b/src/main/java/com/moddy/server/domain/hair_model_application/HairLength.java @@ -1,26 +1,12 @@ package com.moddy.server.domain.hair_model_application; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; -import com.moddy.server.domain.user.Gender; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; - @AllArgsConstructor @Getter public enum HairLength { SHORT("숏"), ABOVE_SHOULDER("단발"), UNDER_SHOULDER("어깨 아래"), UNDER_WAIST("허리 아래"); private final String value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static HairLength findByHairLength(String hairLength) { - return Stream.of(HairLength.values()) - .filter(c -> c.name().equals(hairLength)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_LENGTH_EXCEPTION)); - } } diff --git a/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecord.java b/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecord.java index 4bf6a3cf..84c6bb0a 100644 --- a/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecord.java +++ b/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecord.java @@ -1,26 +1,12 @@ package com.moddy.server.domain.hair_service_record; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; -import com.moddy.server.domain.hair_model_application.HairLength; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; - @Getter @AllArgsConstructor public enum ServiceRecord { PERM("펌"), DECOLOR("탈색"), BLACK("블랙 염색"), COLOR("컬러 염색"); private final String value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static ServiceRecord findByServiceRecord(String serviceRecord) { - return Stream.of(ServiceRecord.values()) - .filter(c -> c.name().equals(serviceRecord)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_SERVICE_RECORD_EXCEPTION)); - } } diff --git a/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecordTerm.java b/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecordTerm.java index abeb4b76..dc218236 100644 --- a/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecordTerm.java +++ b/src/main/java/com/moddy/server/domain/hair_service_record/ServiceRecordTerm.java @@ -1,25 +1,12 @@ package com.moddy.server.domain.hair_service_record; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; - @Getter @AllArgsConstructor public enum ServiceRecordTerm { UNDER_ONE("1 개월 미만"), ONE_THREE("1 - 3 개월"), FOUR_SIX("4 - 6 개월"), SEVEN_TWELVE("7 - 12 개월"), ABOVE_TWELVE("12 개월 초과"); private final String value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static ServiceRecordTerm findByServiceRecord(String serviceRecordTerm) { - return Stream.of(ServiceRecordTerm.values()) - .filter(c -> c.name().equals(serviceRecordTerm)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_SERVICE_RECORD_TERM_EXCEPTION)); - } } diff --git a/src/main/java/com/moddy/server/domain/prefer_hair_style/HairStyle.java b/src/main/java/com/moddy/server/domain/prefer_hair_style/HairStyle.java index 0763be91..0bbf260c 100644 --- a/src/main/java/com/moddy/server/domain/prefer_hair_style/HairStyle.java +++ b/src/main/java/com/moddy/server/domain/prefer_hair_style/HairStyle.java @@ -1,28 +1,13 @@ package com.moddy.server.domain.prefer_hair_style; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; -import com.moddy.server.domain.hair_model_application.HairLength; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; - @AllArgsConstructor @Getter public enum HairStyle { NORMAL_CUT("일반 커트"), ALL_COLOR("전체 염색"), ALL_DECOLOR("전체 탈색"), SETTING_PERM("셋팅펌"), NORMAL_PERM("일반펌"), STRAIGHTENING("매직"); private final String value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static HairStyle findByHairStyle(String hairStyle) { - return Stream.of(HairStyle.values()) - .filter(c -> c.name().equals(hairStyle)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_HAIR_STYLE_EXCEPTION)); - } - } diff --git a/src/main/java/com/moddy/server/domain/user/Gender.java b/src/main/java/com/moddy/server/domain/user/Gender.java index 91dcf5ae..8918519e 100644 --- a/src/main/java/com/moddy/server/domain/user/Gender.java +++ b/src/main/java/com/moddy/server/domain/user/Gender.java @@ -1,24 +1,13 @@ package com.moddy.server.domain.user; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.moddy.server.common.exception.enums.ErrorCode; -import com.moddy.server.common.exception.model.BadRequestException; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.stream.Stream; @Getter @AllArgsConstructor public enum Gender { MALE("남성"), FEMALE("여성"); - private final String value; - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static Gender findByGender(String gender) { - return Stream.of(Gender.values()) - .filter(c -> c.name().equals(gender)) - .findFirst() - .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_GENDER_EXCEPTION)); - } + private final String value; } From 69d1f9405b22edd1ba62d0af7d2503713d960cdf Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 17 Jan 2024 03:09:14 +0900 Subject: [PATCH 22/24] =?UTF-8?q?#155=20[fix]=20@RequestPart=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/model/ModelController.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/ModelController.java b/src/main/java/com/moddy/server/controller/model/ModelController.java index 010bb50b..66115002 100644 --- a/src/main/java/com/moddy/server/controller/model/ModelController.java +++ b/src/main/java/com/moddy/server/controller/model/ModelController.java @@ -5,9 +5,7 @@ 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.model.dto.requestEditor.ListPropertyEditor; import com.moddy.server.controller.model.dto.request.ModelApplicationRequest; -import com.moddy.server.controller.model.dto.request.ModelHairServiceRequest; import com.moddy.server.controller.model.dto.response.DetailOfferResponse; import com.moddy.server.controller.model.dto.response.ModelMainResponse; import com.moddy.server.controller.model.dto.response.OpenChatResponse; @@ -22,9 +20,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; -import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; -import java.util.List; +import org.springframework.web.multipart.MultipartFile; @RestController @Tag(name = "ModelController") @@ -104,14 +101,11 @@ public SuccessNonDataResponse acceptOffer( @PostMapping(value = "/application", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) public SuccessNonDataResponse submitModelApplication( @Parameter(hidden = true) @UserId Long userId, - @ModelAttribute ModelApplicationRequest request) { - modelService.postApplication(userId, request); + @RequestPart(value = "modelImgUrl", required = false) MultipartFile modelImgUrl, + @RequestPart(value = "applicationCaptureImgUrl", required = false) MultipartFile applicationCaptureImgUrl, + @RequestPart(value = "applicationInfo") ModelApplicationRequest applicationInfo) { + modelService.postApplication(userId, modelImgUrl, applicationCaptureImgUrl, applicationInfo); return SuccessNonDataResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS); } - @InitBinder - public void initBinder(WebDataBinder binder) { - binder.registerCustomEditor(List.class, "hairServiceRecords", new ListPropertyEditor(ModelHairServiceRequest.class)); - } - } From 67a17ba55f4d05ed58dc943076392527c657531d Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 17 Jan 2024 03:09:37 +0900 Subject: [PATCH 23/24] =?UTF-8?q?#155=20[fix]=20Parameter=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/model/ModelService.java | 101 ++++-------------- 1 file changed, 18 insertions(+), 83 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 40c3521f..26605117 100644 --- a/src/main/java/com/moddy/server/service/model/ModelService.java +++ b/src/main/java/com/moddy/server/service/model/ModelService.java @@ -17,19 +17,15 @@ import com.moddy.server.domain.day_off.repository.DayOffJpaRepository; import com.moddy.server.domain.designer.Designer; import com.moddy.server.domain.designer.repository.DesignerJpaRepository; -import com.moddy.server.domain.hair_model_application.HairLength; 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.HairServiceOffer; import com.moddy.server.domain.hair_service_offer.repository.HairServiceOfferJpaRepository; import com.moddy.server.domain.hair_service_record.HairServiceRecord; -import com.moddy.server.domain.hair_service_record.ServiceRecord; -import com.moddy.server.domain.hair_service_record.ServiceRecordTerm; import com.moddy.server.domain.hair_service_record.repository.HairServiceRecordJpaRepository; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.model.ModelApplyStatus; import com.moddy.server.domain.model.repository.ModelJpaRepository; -import com.moddy.server.domain.prefer_hair_style.HairStyle; 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_offer_condition.OfferCondition; @@ -42,7 +38,6 @@ import com.moddy.server.domain.user.Role; import com.moddy.server.domain.user.User; import com.moddy.server.domain.user.repository.UserRepository; -import com.moddy.server.external.kakao.service.KakaoSocialService; import com.moddy.server.external.s3.S3Service; import com.moddy.server.service.auth.AuthService; import lombok.RequiredArgsConstructor; @@ -51,6 +46,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; import java.util.Arrays; @@ -89,14 +85,7 @@ public ModelMainResponse getModelMainInfo(Long userId, int page, int size) { ModelApplyStatus modelApplyStatus = calModelStatus(applyStatus, offerStatus); if (modelApplyStatus != ModelApplyStatus.APPLY_AND_OFFER) { - return new ModelMainResponse( - page, - size, - totalElements, - modelApplyStatus, - user.getName(), - new ArrayList<>() - ); + return new ModelMainResponse(page, size, totalElements, modelApplyStatus, user.getName(), new ArrayList<>()); } List offerResponseList = offerPage.stream().map(offer -> { @@ -106,32 +95,18 @@ public ModelMainResponse getModelMainInfo(Long userId, int page, int size) { return offerCondition.getOfferCondition().getValue(); }).collect(Collectors.toList()); - OfferResponse offerResponse = new OfferResponse( - offer.getId(), - designer.getProfileImgUrl(), - designer.getName(), - designer.getHairShop().getName(), - offerConditionTop2List, - offer.getIsClicked() - ); + OfferResponse offerResponse = new OfferResponse(offer.getId(), designer.getProfileImgUrl(), designer.getName(), designer.getHairShop().getName(), offerConditionTop2List, offer.getIsClicked()); return offerResponse; }).collect(Collectors.toList()); - return new ModelMainResponse( - page, - size, - totalElements, - modelApplyStatus, - user.getName(), - offerResponseList - ); + return new ModelMainResponse(page, size, totalElements, modelApplyStatus, user.getName(), offerResponseList); } @Transactional public UserCreateResponse createModel(long userId, ModelCreateRequest request) { User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); - user.update(request.name(),request.gender(), request.phoneNumber(), request.isMarketingAgree(), s3Service.getDefaultProfileImageUrl(), Role.MODEL); + user.update(request.name(), request.gender(), request.phoneNumber(), request.isMarketingAgree(), s3Service.getDefaultProfileImageUrl(), Role.MODEL); modelJpaRepository.modelRegister(userId, request.year()); Model model = modelJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION)); @@ -146,37 +121,23 @@ public UserCreateResponse createModel(long userId, ModelCreateRequest request) { } @Transactional - public void postApplication(Long userId, ModelApplicationRequest request) { + public void postApplication(Long userId, MultipartFile modelImgUrl, MultipartFile applicationCaptureImgUrl, ModelApplicationRequest applicationInfo) { Model model = modelJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); - String modelImgUrl = s3Service.uploadProfileImage(request.modelImgUrl(), model.getRole()); - String applicationCaptureUmgUrl = s3Service.uploadApplicationImage(request.applicationCaptureImgUrl()); - - HairModelApplication hairModelApplication = HairModelApplication.builder() - .model(model) - .hairLength(HairLength.findByHairLength(request.hairLength())) - .hairDetail(request.hairDetail()) - .modelImgUrl(modelImgUrl) - .instagramId(request.instagramId()) - .applicationCaptureUrl(applicationCaptureUmgUrl) - .build(); + String s3ModelImgUrl = s3Service.uploadProfileImage(modelImgUrl, model.getRole()); + String s3applicationCaptureImgUrl = s3Service.uploadApplicationImage(applicationCaptureImgUrl); + + HairModelApplication hairModelApplication = HairModelApplication.builder().model(model).hairLength(applicationInfo.hairLength()).hairDetail(applicationInfo.hairDetail()).modelImgUrl(s3ModelImgUrl).instagramId(applicationInfo.instagramId()).applicationCaptureUrl(s3applicationCaptureImgUrl).build(); hairModelApplicationJpaRepository.save(hairModelApplication); - request.preferHairStyles().stream().forEach(hairStyle -> { - PreferHairStyle preferHairStyle = PreferHairStyle.builder() - .hairModelApplication(hairModelApplication) - .hairStyle(HairStyle.findByHairStyle(hairStyle)) - .build(); + applicationInfo.preferHairStyles().stream().forEach(hairStyle -> { + PreferHairStyle preferHairStyle = PreferHairStyle.builder().hairModelApplication(hairModelApplication).hairStyle(hairStyle).build(); preferHairStyleJpaRepository.save(preferHairStyle); }); - request.getHairServiceRecords().stream().forEach(modelHairServiceRecord -> { - HairServiceRecord hairServiceRecord = HairServiceRecord.builder() - .hairModelApplication(hairModelApplication) - .serviceRecord(ServiceRecord.findByServiceRecord(modelHairServiceRecord.hairService())) - .serviceRecordTerm(ServiceRecordTerm.findByServiceRecord(modelHairServiceRecord.hairServiceTerm())) - .build(); + applicationInfo.getHairServiceRecords().stream().forEach(modelHairServiceRecord -> { + HairServiceRecord hairServiceRecord = HairServiceRecord.builder().hairModelApplication(hairModelApplication).serviceRecord(modelHairServiceRecord.hairService()).serviceRecordTerm(modelHairServiceRecord.hairServiceTerm()).build(); hairServiceRecordJpaRepository.save(hairServiceRecord); }); @@ -207,18 +168,9 @@ public OpenChatResponse getOpenChatInfo(Long userId, Long offerId) { HairModelApplication application = hairModelApplicationJpaRepository.findById(hairServiceOffer.getId()).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); Designer designer = designerJpaRepository.findById(hairServiceOffer.getDesigner().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); - DesignerInfoOpenChatResponse designerInfoOpenChatResponse = new DesignerInfoOpenChatResponse( - designer.getProfileImgUrl(), - designer.getHairShop().getName(), - designer.getName(), - designer.getIntroduction() - ); + DesignerInfoOpenChatResponse designerInfoOpenChatResponse = new DesignerInfoOpenChatResponse(designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction()); - OpenChatResponse openChatResponse = new OpenChatResponse( - application.getApplicationCaptureUrl(), - designer.getKakaoOpenChatUrl(), - designerInfoOpenChatResponse - ); + OpenChatResponse openChatResponse = new OpenChatResponse(application.getApplicationCaptureUrl(), designer.getKakaoOpenChatUrl(), designerInfoOpenChatResponse); return openChatResponse; } @@ -232,18 +184,7 @@ private DesignerInfoResponse getDesignerInfoResponse(HairServiceOffer hairServic return dayOff.getDayOfWeek().getValue(); }).collect(Collectors.toList()); - DesignerInfoResponse designerInfoResponse = new DesignerInfoResponse( - designer.getProfileImgUrl(), - designer.getHairShop().getName(), - designer.getName(), - designer.getPortfolio().getInstagramUrl(), - designer.getPortfolio().getNaverPlaceUrl(), - designer.getIntroduction(), - designer.getGender().getValue(), - dayOfWeekList, - designer.getHairShop().getAddress(), - designer.getHairShop().getDetailAddress() - ); + DesignerInfoResponse designerInfoResponse = new DesignerInfoResponse(designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getPortfolio().getInstagramUrl(), designer.getPortfolio().getNaverPlaceUrl(), designer.getIntroduction(), designer.getGender().getValue(), dayOfWeekList, designer.getHairShop().getAddress(), designer.getHairShop().getDetailAddress()); return designerInfoResponse; @@ -265,13 +206,7 @@ private StyleDetailResponse getStyleDetailResponse(HairServiceOffer hairServiceO else return false; }).collect(Collectors.toList()); - StyleDetailResponse styleDetailResponse = new StyleDetailResponse( - hairServiceOffer.getIsModelAgree(), - hairStyleList, - hairServiceOffer.getOfferDetail(), - hairModelApplication.getHairDetail(), - preferOfferConditionBooleanList - ); + StyleDetailResponse styleDetailResponse = new StyleDetailResponse(hairServiceOffer.getIsModelAgree(), hairStyleList, hairServiceOffer.getOfferDetail(), hairModelApplication.getHairDetail(), preferOfferConditionBooleanList); return styleDetailResponse; } From 11266ce344094406bd57cb97b31e71e535649132 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 17 Jan 2024 03:10:00 +0900 Subject: [PATCH 24/24] =?UTF-8?q?#155=20[fix]=20=EC=83=81=EC=88=98=20-->?= =?UTF-8?q?=20ENUM=20=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/dto/request/ModelApplicationRequest.java | 12 ++++++------ .../model/dto/request/ModelHairServiceRequest.java | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.java b/src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.java index 5858a9b3..158b3bd7 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.java +++ b/src/main/java/com/moddy/server/controller/model/dto/request/ModelApplicationRequest.java @@ -1,22 +1,22 @@ package com.moddy.server.controller.model.dto.request; -import org.springframework.web.multipart.MultipartFile; +import com.moddy.server.domain.hair_model_application.HairLength; import java.util.List; + +import com.moddy.server.domain.prefer_hair_style.HairStyle; import io.swagger.v3.oas.annotations.media.Schema; public record ModelApplicationRequest( @Schema(description = "모델의 현재 머리 기장 예시입니다.", example ="SHORT") - String hairLength, + HairLength hairLength, @Schema(description = "PreferHaireStyle의 예시 JSON 배열 포맷입니다.", example ="[\"NORMAL_CUT\", \"ALL_COLOR\"]") - List preferHairStyles, + List preferHairStyles, @Schema(description = "모델이 원하는 헤어스타일 예시입니다.", example = "안녕하세요 저는 숱을 많이 친 허쉬컷이 하고 싶어요 근데 머리가 곱슬이라 매직도 같이 해야지 이쁘게 될것 같아요. 그리고 머리가 얇아서 그거 감안하고 해야할것 같습니다.") String hairDetail, @Schema(description = "HairServiceRecords 의 예시 JSON 배열 포맷입니다.", example = "[{\"hairService\": \"PERM\", \"hairServiceTerm\": \"UNDER_ONE\"}, {\"hairService\": \"BLACK\", \"hairServiceTerm\": \"ABOVE_TWELVE\"}]") List hairServiceRecords, - MultipartFile modelImgUrl, @Schema(description = "모델의 인스타그램 예시입니다.", example ="hizo0") - String instagramId, - MultipartFile applicationCaptureImgUrl + String instagramId ) { public List getHairServiceRecords() { return hairServiceRecords; diff --git a/src/main/java/com/moddy/server/controller/model/dto/request/ModelHairServiceRequest.java b/src/main/java/com/moddy/server/controller/model/dto/request/ModelHairServiceRequest.java index f4556bb6..2b6fbefc 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/request/ModelHairServiceRequest.java +++ b/src/main/java/com/moddy/server/controller/model/dto/request/ModelHairServiceRequest.java @@ -1,7 +1,10 @@ package com.moddy.server.controller.model.dto.request; +import com.moddy.server.domain.hair_service_record.ServiceRecord; +import com.moddy.server.domain.hair_service_record.ServiceRecordTerm; + public record ModelHairServiceRequest( - String hairService, - String hairServiceTerm + ServiceRecord hairService, + ServiceRecordTerm hairServiceTerm ) { }