From d835de9af1b4590d3298768616b94ee5f4964759 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:12:12 +0900 Subject: [PATCH 01/23] =?UTF-8?q?#273=20[feat]=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/common/exception/enums/SuccessCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 33dde320..8381f9ab 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 @@ -29,7 +29,8 @@ public enum SuccessCode { GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공"), GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공"), CHECK_VALID_APPLICATION_SUCCESS(HttpStatus.OK, "유효한 지원서 입니다."), - APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"); + APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"), + FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"); private final HttpStatus httpStatus; private final String message; From d57c1eaa1eff26ab22c87e78f3ed04c64429bcc5 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:12:28 +0900 Subject: [PATCH 02/23] =?UTF-8?q?#273=20[fix]=20=EC=95=88=EC=93=B0?= =?UTF-8?q?=EB=8A=94=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/controller/designer/dto/HairShopDto.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/designer/dto/HairShopDto.java b/src/main/java/com/moddy/server/controller/designer/dto/HairShopDto.java index 404e1db5..17a27ecd 100644 --- a/src/main/java/com/moddy/server/controller/designer/dto/HairShopDto.java +++ b/src/main/java/com/moddy/server/controller/designer/dto/HairShopDto.java @@ -1,9 +1,7 @@ package com.moddy.server.controller.designer.dto; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; import lombok.*; From c57ef3aa61d2c264cdfa47aab9b301ac84e9a4d6 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:12:51 +0900 Subject: [PATCH 03/23] =?UTF-8?q?#273=20[feat]=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=20=EB=94=94?= =?UTF-8?q?=EC=9E=90=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=EB=B0=94=EB=94=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/DesignerMyPageResponse.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java diff --git a/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java b/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java new file mode 100644 index 00000000..666fabaa --- /dev/null +++ b/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java @@ -0,0 +1,20 @@ +package com.moddy.server.controller.designer.dto.response; + +import com.moddy.server.domain.designer.HairShop; +import com.moddy.server.domain.designer.Portfolio; +import com.moddy.server.domain.user.Gender; + +import java.util.List; + +public record DesignerMyPageResponse( + String profileImgUrl, + String introduction, + String name, + Gender gender, + String phoneNumber, + HairShop hairShop, + List dayOffs, + Portfolio portfolio, + String kakaoOpenChatUrl +) { +} From 17134b1799ade92ba5f9a22b85d6ce3d3bf498f0 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:13:09 +0900 Subject: [PATCH 04/23] =?UTF-8?q?#273=20[feat]=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/DesignerRetrieveController.java | 16 ++++++++++++++++ .../designer/DesignerRetrieveService.java | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java b/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java index 094d48d3..1b4f41f3 100644 --- a/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java +++ b/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java @@ -4,6 +4,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.designer.dto.response.DesignerMyPageResponse; import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto; import com.moddy.server.service.designer.DesignerRetrieveService; import io.swagger.v3.oas.annotations.Operation; @@ -41,4 +42,19 @@ public SuccessResponse getDesignerOpenChatInfo( @Parameter(name = "designerId", description = "디자이너아이디") @PathVariable(value = "designerId") Long designerId) { return SuccessResponse.success(SuccessCode.OPEN_CHAT_GET_SUCCESS, designerRetrieveService.getDesignerOpenChatInfo(designerId)); } + + @Operation(summary = "[JWT] 마이페이지 디자이너 정보 조회", description = "마이페이지 수정시 디자이너 정보 조회입니다") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "디자이너 정보 조회 성공", content = @Content(schema = @Schema(implementation = DesignerInfoOpenChatDto.class))), + @ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + }) + @GetMapping() + @SecurityRequirement(name = "JWT Auth") + public SuccessResponse getDesignerInfo( + @Parameter(hidden = true) @UserId Long designerId){ + return SuccessResponse.success(SuccessCode.FIND_DESIGNER_INFO_SUCCESS, designerRetrieveService.getDesignerInfo(designerId)); + } + + } diff --git a/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java b/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java index 60fd1f03..c4910ed8 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java @@ -2,6 +2,7 @@ import com.moddy.server.common.exception.enums.ErrorCode; import com.moddy.server.common.exception.model.NotFoundException; +import com.moddy.server.controller.designer.dto.response.DesignerMyPageResponse; import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto; import com.moddy.server.controller.model.dto.response.DesignerInfoResponse; import com.moddy.server.domain.day_off.DayOff; @@ -28,6 +29,14 @@ public String getDesignerName(final Long designerId) { return designer.getName(); } + public DesignerMyPageResponse getDesignerInfo(final Long designerId) { + Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); + List dayOfWeekList = getDayOfWeekList(designerId); + + DesignerMyPageResponse designerMyPageResponse = new DesignerMyPageResponse(designer.getProfileImgUrl(), designer.getIntroduction(),designer.getName(), designer.getGender(), designer.getPhoneNumber(), designer.getHairShop(), dayOfWeekList, designer.getPortfolio(), designer.getKakaoOpenChatUrl()); + return designerMyPageResponse; + } + public DesignerInfoOpenChatDto getDesignerOpenChatInfo(final Long designerId) { Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); return new DesignerInfoOpenChatDto(designer.getKakaoOpenChatUrl(), designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction()); From 7af5837eb325c0ded1e45ba316867097ae78486f Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:26:44 +0900 Subject: [PATCH 05/23] =?UTF-8?q?#273=20[feat]=20=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EC=84=B1=EA=B3=B5?= =?UTF-8?q?=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/common/exception/enums/SuccessCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 8381f9ab..edc194bf 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 @@ -30,7 +30,8 @@ public enum SuccessCode { GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공"), CHECK_VALID_APPLICATION_SUCCESS(HttpStatus.OK, "유효한 지원서 입니다."), APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"), - FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"); + FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"), + FIND_MODEL_INFO_SUCCESS(HttpStatus.OK, "모델 정보 조회 성공"); private final HttpStatus httpStatus; private final String message; From 12ec64a8307c615e047d95e4cad475b5af5a8a47 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:27:02 +0900 Subject: [PATCH 06/23] =?UTF-8?q?#273=20[fear]=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/dto/response/ModelMyPageResponse.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java diff --git a/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java b/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java new file mode 100644 index 00000000..aa251e71 --- /dev/null +++ b/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java @@ -0,0 +1,13 @@ +package com.moddy.server.controller.model.dto.response; + +import com.moddy.server.domain.user.Gender; +import java.util.List; + +public record ModelMyPageResponse( + String name, + String year, + Gender gender, + String phoneNumber, + List preferRegions +) { +} From 3279ffe796e10d0af5b0b0265cd495e3c86cb9fc Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:27:26 +0900 Subject: [PATCH 07/23] =?UTF-8?q?#273=20[fix]=20swagger=EC=97=90=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EB=8A=94=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/designer/DesignerRetrieveController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java b/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java index 1b4f41f3..0230405e 100644 --- a/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java +++ b/src/main/java/com/moddy/server/controller/designer/DesignerRetrieveController.java @@ -45,7 +45,7 @@ public SuccessResponse getDesignerOpenChatInfo( @Operation(summary = "[JWT] 마이페이지 디자이너 정보 조회", description = "마이페이지 수정시 디자이너 정보 조회입니다") @ApiResponses({ - @ApiResponse(responseCode = "200", description = "디자이너 정보 조회 성공", content = @Content(schema = @Schema(implementation = DesignerInfoOpenChatDto.class))), + @ApiResponse(responseCode = "200", description = "디자이너 정보 조회 성공", content = @Content(schema = @Schema(implementation = DesignerMyPageResponse.class))), @ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) From e7e60d8aadf1bc11f5671c786ed52495e1a1ac4b Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:27:51 +0900 Subject: [PATCH 08/23] =?UTF-8?q?#273=20[feat]=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=A0=95=20=5F=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/ModelRetrieveController.java | 14 +++++++++++ .../service/model/ModelRetrieveService.java | 23 +++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/ModelRetrieveController.java b/src/main/java/com/moddy/server/controller/model/ModelRetrieveController.java index 46cea673..1d05582c 100644 --- a/src/main/java/com/moddy/server/controller/model/ModelRetrieveController.java +++ b/src/main/java/com/moddy/server/controller/model/ModelRetrieveController.java @@ -6,6 +6,7 @@ import com.moddy.server.config.resolver.user.UserId; import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse; +import com.moddy.server.controller.model.dto.response.ModelMyPageResponse; import com.moddy.server.service.model.ModelRetrieveService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,4 +53,17 @@ public SuccessResponse> getRegionList() { public SuccessResponse getUserDetailInApplication(@Parameter(hidden = true) @UserId final Long modelId) { return SuccessResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS, modelRetrieveService.getModelDetailInApplication(modelId)); } + + @Operation(summary = "[JWT] 마이페이지 모델 정보 조회", description = "마이페이지 수정시 모델 정보 조회입니다") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "모델 정보 조회 성공", content = @Content(schema = @Schema(implementation = ModelMyPageResponse.class))), + @ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + }) + @GetMapping() + @SecurityRequirement(name = "JWT Auth") + public SuccessResponse getDesignerInfo( + @Parameter(hidden = true) @UserId Long modelId) { + return SuccessResponse.success(SuccessCode.FIND_MODEL_INFO_SUCCESS, modelRetrieveService.getModelInfo(modelId)); + } } \ No newline at end of file diff --git a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java index de799472..1df2c609 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java @@ -5,6 +5,7 @@ import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.model.dto.ApplicationModelInfoDto; import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse; +import com.moddy.server.controller.model.dto.response.ModelMyPageResponse; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.model.repository.ModelJpaRepository; import com.moddy.server.domain.prefer_region.PreferRegion; @@ -27,13 +28,7 @@ public class ModelRetrieveService { public ApplicationModelInfoDto getApplicationModelInfo(final Long modelId) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); - - List preferRegions = preferRegionJpaRepository.findAllByModelId(modelId); - - List regionList = preferRegions.stream().map(preferregion -> { - return preferregion.getRegion().getName(); - }).collect(Collectors.toList()); - return new ApplicationModelInfoDto(modelId, model.getName(), model.getAge(), model.getGender().getValue(), regionList); + return new ApplicationModelInfoDto(modelId, model.getName(), model.getAge(), model.getGender().getValue(), getPreferRegionsList(modelId)); } public List getRegionList() { @@ -50,6 +45,12 @@ public String getModelName(final Long modelId) { return model.getName(); } + public ModelMyPageResponse getModelInfo(final Long modelId) { + Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); + ModelMyPageResponse modelMyPageResponse = new ModelMyPageResponse(model.getName(), model.getYear(), model.getGender(),model.getPhoneNumber(), getPreferRegionsList(modelId)); + return modelMyPageResponse; + } + public ApplicationUserDetailResponse getModelDetailInApplication(final Long modelId) { final Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); final List preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId()) @@ -59,4 +60,12 @@ public ApplicationUserDetailResponse getModelDetailInApplication(final Long mode return new ApplicationUserDetailResponse(model.getName(), model.getGender().getValue(), model.getAge(), preferRegions); } + + private List getPreferRegionsList(final Long modelId){ + List preferRegions = preferRegionJpaRepository.findAllByModelId(modelId); + List regionList = preferRegions.stream().map(preferregion -> { + return preferregion.getRegion().getName(); + }).collect(Collectors.toList()); + return regionList; + } } From de022d9decbd5b13c866fbed728d63db7d9e64df Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:39:32 +0900 Subject: [PATCH 09/23] =?UTF-8?q?#273=20[feat]=20Slashed=20=EC=A0=84?= =?UTF-8?q?=ED=99=94=20=EB=B2=88=ED=98=B8=20=ED=8C=A8=ED=84=B4=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EB=A7=8C=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moddy/server/domain/user/User.java | 4 ++++ 1 file changed, 4 insertions(+) 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 c540bcaf..29a4ed5e 100644 --- a/src/main/java/com/moddy/server/domain/user/User.java +++ b/src/main/java/com/moddy/server/domain/user/User.java @@ -52,4 +52,8 @@ public void update(String name, Gender gender, String phoneNumber, Boolean isMar this.profileImgUrl = profileImgUrl; this.role = role; } + + public String getSlashedPhoneNumber(String phoneNumber){ + return phoneNumber.substring(0, 3) + "-" + phoneNumber.substring(3, 7) + "-" + phoneNumber.substring(7); + } } From 800f59c8ed67c8bbc84415ba83c1a8885013b84c Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 20:39:52 +0900 Subject: [PATCH 10/23] =?UTF-8?q?#273=20[feat]=20GUI=EC=97=90=20fit?= =?UTF-8?q?=ED=95=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=98=95=ED=83=9C?= =?UTF-8?q?=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 --- .../designer/dto/response/DesignerMyPageResponse.java | 3 +-- .../controller/model/dto/response/ModelMyPageResponse.java | 3 +-- .../moddy/server/service/designer/DesignerRetrieveService.java | 2 +- .../com/moddy/server/service/model/ModelRetrieveService.java | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java b/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java index 666fabaa..bee477ed 100644 --- a/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java +++ b/src/main/java/com/moddy/server/controller/designer/dto/response/DesignerMyPageResponse.java @@ -2,7 +2,6 @@ import com.moddy.server.domain.designer.HairShop; import com.moddy.server.domain.designer.Portfolio; -import com.moddy.server.domain.user.Gender; import java.util.List; @@ -10,7 +9,7 @@ public record DesignerMyPageResponse( String profileImgUrl, String introduction, String name, - Gender gender, + String gender, String phoneNumber, HairShop hairShop, List dayOffs, diff --git a/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java b/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java index aa251e71..f767dbfd 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java +++ b/src/main/java/com/moddy/server/controller/model/dto/response/ModelMyPageResponse.java @@ -1,12 +1,11 @@ package com.moddy.server.controller.model.dto.response; -import com.moddy.server.domain.user.Gender; import java.util.List; public record ModelMyPageResponse( String name, String year, - Gender gender, + String gender, String phoneNumber, List preferRegions ) { diff --git a/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java b/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java index c4910ed8..802bb6fd 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java @@ -33,7 +33,7 @@ public DesignerMyPageResponse getDesignerInfo(final Long designerId) { Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); List dayOfWeekList = getDayOfWeekList(designerId); - DesignerMyPageResponse designerMyPageResponse = new DesignerMyPageResponse(designer.getProfileImgUrl(), designer.getIntroduction(),designer.getName(), designer.getGender(), designer.getPhoneNumber(), designer.getHairShop(), dayOfWeekList, designer.getPortfolio(), designer.getKakaoOpenChatUrl()); + DesignerMyPageResponse designerMyPageResponse = new DesignerMyPageResponse(designer.getProfileImgUrl(), designer.getIntroduction(),designer.getName(), designer.getGender().getValue(), designer.getSlashedPhoneNumber(designer.getPhoneNumber()), designer.getHairShop(), dayOfWeekList, designer.getPortfolio(), designer.getKakaoOpenChatUrl()); return designerMyPageResponse; } diff --git a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java index 1df2c609..0d295027 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java @@ -47,7 +47,7 @@ public String getModelName(final Long modelId) { public ModelMyPageResponse getModelInfo(final Long modelId) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); - ModelMyPageResponse modelMyPageResponse = new ModelMyPageResponse(model.getName(), model.getYear(), model.getGender(),model.getPhoneNumber(), getPreferRegionsList(modelId)); + ModelMyPageResponse modelMyPageResponse = new ModelMyPageResponse(model.getName(), model.getYear(), model.getGender().getValue(), model.getSlashedPhoneNumber(model.getPhoneNumber()), getPreferRegionsList(modelId)); return modelMyPageResponse; } From 2f3df7fbf596dea7912416b6d25773777600c268 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:55:20 +0900 Subject: [PATCH 11/23] =?UTF-8?q?#274=20[feat]=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/common/exception/enums/SuccessCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 edc194bf..aab685ec 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 @@ -31,7 +31,8 @@ public enum SuccessCode { CHECK_VALID_APPLICATION_SUCCESS(HttpStatus.OK, "유효한 지원서 입니다."), APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"), FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"), - FIND_MODEL_INFO_SUCCESS(HttpStatus.OK, "모델 정보 조회 성공"); + FIND_MODEL_INFO_SUCCESS(HttpStatus.OK, "모델 정보 조회 성공"), + MODEL_UPDATE_SUCCESS(HttpStatus.OK,"모델 정보 수정 성공"); private final HttpStatus httpStatus; private final String message; From 1f46be7bb4b5a9ba9eb9d1b27ae86b1b7d6f152c Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:55:47 +0900 Subject: [PATCH 12/23] =?UTF-8?q?#274=20[feat]=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=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 --- .../com/moddy/server/domain/prefer_region/PreferRegion.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/prefer_region/PreferRegion.java b/src/main/java/com/moddy/server/domain/prefer_region/PreferRegion.java index dde72080..8db465ad 100644 --- a/src/main/java/com/moddy/server/domain/prefer_region/PreferRegion.java +++ b/src/main/java/com/moddy/server/domain/prefer_region/PreferRegion.java @@ -3,7 +3,6 @@ import com.moddy.server.domain.BaseTimeEntity; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.region.Region; -import com.moddy.server.domain.user.User; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; @@ -15,7 +14,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Entity @Getter From 6cd102424cb93dbdefb01004df263d39e9efadc4 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:56:04 +0900 Subject: [PATCH 13/23] =?UTF-8?q?#274=20[feat]=20model=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20update=20=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= 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 | 6 +++++- 1 file changed, 5 insertions(+), 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 224a0856..ee3943f2 100644 --- a/src/main/java/com/moddy/server/domain/model/Model.java +++ b/src/main/java/com/moddy/server/domain/model/Model.java @@ -6,7 +6,6 @@ import lombok.Getter; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; -import lombok.Setter; import lombok.experimental.SuperBuilder; import java.time.LocalDateTime; @@ -20,9 +19,14 @@ public class Model extends User { @NotNull private String year; + public int getAge() { LocalDateTime currentDateTime = LocalDateTime.now(); Integer age = currentDateTime.getYear() - Integer.parseInt(this.year) + 1; return age; } + + public void update(String year){ + this.year = year; + } } From fb31538192c1000af354868607a4da1de9c336e0 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:57:16 +0900 Subject: [PATCH 14/23] =?UTF-8?q?#274=20[feat]=20=EC=95=88=EC=93=B0?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=EB=93=A4=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=20=EC=9E=91=EC=9D=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/model/dto/request/ModelCreateRequest.java | 2 +- .../server/domain/model/repository/ModelJpaRepository.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/model/dto/request/ModelCreateRequest.java b/src/main/java/com/moddy/server/controller/model/dto/request/ModelCreateRequest.java index 2c9e9a03..02ba7be2 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/request/ModelCreateRequest.java +++ b/src/main/java/com/moddy/server/controller/model/dto/request/ModelCreateRequest.java @@ -17,7 +17,7 @@ @NotNull public record ModelCreateRequest( @Schema(description = "모델 회원가입 유저 이름 예시입니다.", example ="안현주") - @Size(min = 0, max = 10, message = "name은 1~10 글자수 사이의 글자입니다.") + @Size(min = 0, max = 10, message = "name은 1~5 글자수 사이의 글자입니다.") String name, @Schema(description = "모델 회원가입 유저 나이 예시입니다.", example ="2000") @NotBlank 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 56859c85..81b9fc4d 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 @@ -7,7 +7,6 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import java.util.Optional; @Repository public interface ModelJpaRepository extends JpaRepository { @@ -15,6 +14,6 @@ public interface ModelJpaRepository extends JpaRepository { @Modifying(clearAutomatically = true) @Query(value = "insert into model (id, year) VALUES (:id, :year)", nativeQuery = true) void modelRegister(@Param("id") Long id, @Param("year") String year); - + } From 8299976eab9d39a97ac493e200ed3a4310690c50 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:57:53 +0900 Subject: [PATCH 15/23] =?UTF-8?q?#274=20[feat]=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20request,=20+=20valida?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/dto/request/ModelUpdateRequest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/moddy/server/controller/model/dto/request/ModelUpdateRequest.java diff --git a/src/main/java/com/moddy/server/controller/model/dto/request/ModelUpdateRequest.java b/src/main/java/com/moddy/server/controller/model/dto/request/ModelUpdateRequest.java new file mode 100644 index 00000000..b3067b4c --- /dev/null +++ b/src/main/java/com/moddy/server/controller/model/dto/request/ModelUpdateRequest.java @@ -0,0 +1,32 @@ +package com.moddy.server.controller.model.dto.request; + +import com.moddy.server.common.validation.prefer_regions.ValidPreferRegions; +import com.moddy.server.common.validation.year.ValidYear; +import com.moddy.server.domain.user.Gender; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.util.List; + +@NotNull +public record ModelUpdateRequest( + @Schema(description = "모델 회원가입 유저 이름 예시입니다.", example ="안현주") + @Size(min = 0, max = 5, message = "name은 1~5 글자수 사이의 글자입니다.") + String name, + @Schema(description = "모델 회원가입 유저 나이 예시입니다.", example ="2000") + @NotBlank + @ValidYear + String year, + @Schema(description = "모델 회원가입 유저 성별 예시입니다.", example ="FEMALE") + @Enumerated(EnumType.STRING) + @NotNull + Gender gender, + @Schema(description = "모델 회원가입 선호 지역 예시입니다.", example ="[\"3\", \"15\"]") + @ValidPreferRegions + List preferRegions +) { +} From 7559c9fcf9bd4a41e90708e9c923dbcb465e0375 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 21:58:08 +0900 Subject: [PATCH 16/23] =?UTF-8?q?#274=20[feat]=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=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 --- .../model/ModelRegisterController.java | 20 +++++++++++++++++++ .../service/model/ModelRegisterService.java | 13 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/com/moddy/server/controller/model/ModelRegisterController.java b/src/main/java/com/moddy/server/controller/model/ModelRegisterController.java index f64b4f31..532bf09e 100644 --- a/src/main/java/com/moddy/server/controller/model/ModelRegisterController.java +++ b/src/main/java/com/moddy/server/controller/model/ModelRegisterController.java @@ -1,11 +1,13 @@ package com.moddy.server.controller.model; import com.moddy.server.common.dto.ErrorResponse; +import com.moddy.server.common.dto.SuccessNonDataResponse; import com.moddy.server.common.dto.SuccessResponse; import com.moddy.server.common.exception.enums.SuccessCode; import com.moddy.server.config.resolver.user.UserId; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; import com.moddy.server.controller.model.dto.request.ModelCreateRequest; +import com.moddy.server.controller.model.dto.request.ModelUpdateRequest; import com.moddy.server.service.model.ModelRegisterService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -18,6 +20,7 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -44,4 +47,21 @@ public SuccessResponse createModel( @Valid @RequestBody ModelCreateRequest modelCreateRequest) { return SuccessResponse.success(SuccessCode.MODEL_CREATE_SUCCESS, modelRegisterService.createModel(userId, modelCreateRequest)); } + + @Operation(summary = "[JWT] 모델 마이페이지 수정 API", description = "모델 마이페이지 수정 API입니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "모델 마이페이지 수정 성공"), + @ApiResponse(responseCode = "401", description = "인증오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", description = "유효하지 않은 값을 입력했습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @PutMapping + @SecurityRequirement(name = "JWT Auth") + public SuccessNonDataResponse updateModel( + @Parameter(hidden = true) @UserId Long modelId, + @Valid @RequestBody ModelUpdateRequest modelUpdateRequest) { + modelRegisterService.updateModel(modelId, modelUpdateRequest); + return SuccessNonDataResponse.success(SuccessCode.MODEL_UPDATE_SUCCESS); + } + } diff --git a/src/main/java/com/moddy/server/service/model/ModelRegisterService.java b/src/main/java/com/moddy/server/service/model/ModelRegisterService.java index 4419f9f7..e706b6f7 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRegisterService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRegisterService.java @@ -5,6 +5,7 @@ import com.moddy.server.common.exception.model.NotFoundException; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; import com.moddy.server.controller.model.dto.request.ModelCreateRequest; +import com.moddy.server.controller.model.dto.request.ModelUpdateRequest; import com.moddy.server.controller.user.dto.request.UserUpdateDto; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.model.repository.ModelJpaRepository; @@ -45,6 +46,18 @@ public UserCreateResponse createModel(final Long userId, ModelCreateRequest requ return authService.createUserToken(userId.toString()); } + @Transactional + public void updateModel(final Long modelId, ModelUpdateRequest modelUpdateRequest) { + Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION)); + + UserUpdateDto userUpdateDto = new UserUpdateDto(modelUpdateRequest.name(), modelUpdateRequest.gender(), model.getPhoneNumber(), model.getIsMarketingAgree()); + updateUserInfos(modelId, userUpdateDto); + model.update(modelUpdateRequest.year()); + modelJpaRepository.save(model); + deleteModelPreferRegions(modelId); + createModelPreferRegions(modelId, modelUpdateRequest.preferRegions()); + } + private void updateUserInfos(final Long userId, final UserUpdateDto userUpdateDto) { final User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); user.update(userUpdateDto.name(), userUpdateDto.gender(), userUpdateDto.phoneNumber(), userUpdateDto.isMarketingAgree(), s3Service.getDefaultProfileImageUrl(), Role.MODEL); From bc5cda73c87a13eb18ae2a64ead2de95a3656739 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 22:09:23 +0900 Subject: [PATCH 17/23] =?UTF-8?q?#275=20[feat]=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/common/exception/enums/SuccessCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 aab685ec..f46a77cf 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 @@ -32,7 +32,8 @@ public enum SuccessCode { APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"), FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"), FIND_MODEL_INFO_SUCCESS(HttpStatus.OK, "모델 정보 조회 성공"), - MODEL_UPDATE_SUCCESS(HttpStatus.OK,"모델 정보 수정 성공"); + MODEL_UPDATE_SUCCESS(HttpStatus.OK,"모델 정보 수정 성공"), + DESIGNER_UPDATE_SUCCESS(HttpStatus.OK,"디자이너 정보 수정 성공"); private final HttpStatus httpStatus; private final String message; From 106e59e3981b58e6234b600252229e933df229d7 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 23:15:30 +0900 Subject: [PATCH 18/23] =?UTF-8?q?#275=20[feat]=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/dto/request/OfferImageUrlRequestDto.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java 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 deleted file mode 100644 index 6dccba06..00000000 --- a/src/main/java/com/moddy/server/controller/designer/dto/request/OfferImageUrlRequestDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.moddy.server.controller.designer.dto.request; - -public record OfferImageUrlRequestDto(String offerImageUrl) { -} From c92aecd613e6514e2688b26daf35ae57e90c75c4 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 23:15:53 +0900 Subject: [PATCH 19/23] =?UTF-8?q?#275=20[feat]=20designer=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/moddy/server/domain/designer/Designer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moddy/server/domain/designer/Designer.java b/src/main/java/com/moddy/server/domain/designer/Designer.java index ef8d8074..16b9f1b8 100644 --- a/src/main/java/com/moddy/server/domain/designer/Designer.java +++ b/src/main/java/com/moddy/server/domain/designer/Designer.java @@ -1,12 +1,12 @@ package com.moddy.server.domain.designer; +import com.moddy.server.controller.designer.dto.request.DesignerUpdateRequest; import com.moddy.server.domain.user.User; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import lombok.experimental.SuperBuilder; @Entity @@ -27,4 +27,11 @@ public class Designer extends User { @NotNull private String kakaoOpenChatUrl; + + public void update(HairShop hairShop, Portfolio portfolio, String introduction, String kakaoOpenChatUrl){ + this.hairShop = hairShop; + this.portfolio = portfolio; + this.introduction = introduction; + this.kakaoOpenChatUrl = kakaoOpenChatUrl; + } } From ba4ecb9f7d8486edd0e4c6009540e33ae8d128aa Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 23:16:15 +0900 Subject: [PATCH 20/23] =?UTF-8?q?#275=20[feat]=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=A0=20request=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/DesignerUpdateRequest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/moddy/server/controller/designer/dto/request/DesignerUpdateRequest.java diff --git a/src/main/java/com/moddy/server/controller/designer/dto/request/DesignerUpdateRequest.java b/src/main/java/com/moddy/server/controller/designer/dto/request/DesignerUpdateRequest.java new file mode 100644 index 00000000..ef2638e2 --- /dev/null +++ b/src/main/java/com/moddy/server/controller/designer/dto/request/DesignerUpdateRequest.java @@ -0,0 +1,43 @@ +package com.moddy.server.controller.designer.dto.request; + +import com.moddy.server.common.validation.unique_dayofweek.UniqueDayOfWeek; +import com.moddy.server.controller.designer.dto.HairShopDto; +import com.moddy.server.controller.designer.dto.PortfolioDto; +import com.moddy.server.domain.day_off.DayOfWeek; +import com.moddy.server.domain.designer.HairShop; +import com.moddy.server.domain.designer.Portfolio; +import com.moddy.server.domain.user.Gender; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.util.List; + +@NotNull +public record DesignerUpdateRequest( + @Schema(example = "introduction") + @NotNull + @Size(min = 0, max = 200, message = "introduction은 1~200 글자수 사이의 글자입니다.") + String introduction, + @Schema(example = "안현주") + @NotNull + @Size(min = 0, max = 5, message = "name은 1~5 글자수 사이의 글자입니다.") + String name, + @Schema(example = "MALE") + @NotNull + @Enumerated(EnumType.STRING) + Gender gender, + @Valid + HairShopDto hairShop, + @UniqueDayOfWeek + List dayOffs, + @Valid + PortfolioDto portfolio, + @Schema(example = "http://.kakao") + @NotNull + String kakaoOpenChatUrl +) { +} From 6a741ebed1d8732a09b71f258ee6a07229cb6855 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 23:18:01 +0900 Subject: [PATCH 21/23] =?UTF-8?q?#275=20[feat]=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A4=84=EC=9D=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moddy/server/service/model/ModelRegisterService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/moddy/server/service/model/ModelRegisterService.java b/src/main/java/com/moddy/server/service/model/ModelRegisterService.java index e706b6f7..31fead11 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRegisterService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRegisterService.java @@ -50,8 +50,7 @@ public UserCreateResponse createModel(final Long userId, ModelCreateRequest requ public void updateModel(final Long modelId, ModelUpdateRequest modelUpdateRequest) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.MODEL_NOT_FOUND_EXCEPTION)); - UserUpdateDto userUpdateDto = new UserUpdateDto(modelUpdateRequest.name(), modelUpdateRequest.gender(), model.getPhoneNumber(), model.getIsMarketingAgree()); - updateUserInfos(modelId, userUpdateDto); + updateUserInfos(modelId, new UserUpdateDto(modelUpdateRequest.name(), modelUpdateRequest.gender(), model.getPhoneNumber(), model.getIsMarketingAgree())); model.update(modelUpdateRequest.year()); modelJpaRepository.save(model); deleteModelPreferRegions(modelId); From 9ea06daf19afc8c5c919a7384c92fc769a9bb4ce Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Sun, 21 Apr 2024 23:18:19 +0900 Subject: [PATCH 22/23] =?UTF-8?q?#275=20[feat]=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/DesignerRegisterController.java | 20 +++++++ .../designer/DesignerRegisterService.java | 56 ++++++++++++++----- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/designer/DesignerRegisterController.java b/src/main/java/com/moddy/server/controller/designer/DesignerRegisterController.java index 396387b9..1c337065 100644 --- a/src/main/java/com/moddy/server/controller/designer/DesignerRegisterController.java +++ b/src/main/java/com/moddy/server/controller/designer/DesignerRegisterController.java @@ -1,10 +1,12 @@ package com.moddy.server.controller.designer; import com.moddy.server.common.dto.ErrorResponse; +import com.moddy.server.common.dto.SuccessNonDataResponse; import com.moddy.server.common.dto.SuccessResponse; import com.moddy.server.common.exception.enums.SuccessCode; import com.moddy.server.config.resolver.user.UserId; import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest; +import com.moddy.server.controller.designer.dto.request.DesignerUpdateRequest; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; import com.moddy.server.service.designer.DesignerRegisterService; import io.swagger.v3.oas.annotations.Operation; @@ -19,6 +21,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -44,4 +47,21 @@ SuccessResponse createDesigner( @Valid @RequestPart("designerInfo") DesignerCreateRequest designerInfo) { return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerRegisterService.createDesigner(designerId, designerInfo, profileImg)); } + + @Operation(summary = "[JWT] 디자이너 마이페이지 수정 API", description = "디자이너 마이페이지 수정 API입니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "디자이너 마이페이지 수정 성공"), + @ApiResponse(responseCode = "401", description = "인증오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", description = "유효하지 않은 값을 입력했습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @PutMapping(consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) + @SecurityRequirement(name = "JWT Auth") + public SuccessNonDataResponse updateModel( + @Parameter(hidden = true) @UserId Long designerId, + @RequestPart(value = "profileImg", required = false) MultipartFile profileImg, + @RequestPart(value = "designerUpdateInfo") @Valid DesignerUpdateRequest designerUpdateInfo){ + designerRegisterService.updateDesigner(designerId, profileImg, designerUpdateInfo); + return SuccessNonDataResponse.success(SuccessCode.DESIGNER_UPDATE_SUCCESS); + } } diff --git a/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java b/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java index 4f941c43..5f403d66 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java @@ -3,8 +3,12 @@ import com.moddy.server.common.exception.enums.ErrorCode; import com.moddy.server.common.exception.model.ConflictException; import com.moddy.server.common.exception.model.NotFoundException; +import com.moddy.server.controller.designer.dto.HairShopDto; import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest; +import com.moddy.server.controller.designer.dto.request.DesignerUpdateRequest; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; +import com.moddy.server.controller.user.dto.request.UserUpdateDto; +import com.moddy.server.domain.day_off.DayOfWeek; import com.moddy.server.domain.day_off.DayOff; import com.moddy.server.domain.day_off.repository.DayOffJpaRepository; import com.moddy.server.domain.designer.Designer; @@ -21,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + import static com.moddy.server.common.exception.enums.ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION; import static com.moddy.server.common.exception.enums.ErrorCode.USER_NOT_FOUND_EXCEPTION; @@ -42,29 +48,51 @@ public UserCreateResponse createDesigner(final Long designerId, final DesignerCr if (designerJpaRepository.existsById(designerId)) throw new ConflictException(ErrorCode.ALREADY_EXIST_USER_EXCEPTION); user.update(request.name(), request.gender(), request.phoneNumber(), request.isMarketingAgree(), profileImgUrl, Role.HAIR_DESIGNER); - HairShop hairShop = new HairShop(request.hairShop().name(), request.hairShop().address(),request.hairShop().detailAddress()); - Portfolio portfolio = new Portfolio(request.portfolio().instagramUrl(),request.portfolio().naverPlaceUrl()); + HairShop hairShop = new HairShop(request.hairShop().name(), request.hairShop().address(), request.hairShop().detailAddress()); + Portfolio portfolio = new Portfolio(request.portfolio().instagramUrl(), request.portfolio().naverPlaceUrl()); designerJpaRepository.designerRegister(user.getId(), hairShop.getAddress(), hairShop.getDetailAddress(), hairShop.getName(), portfolio.getInstagramUrl(), portfolio.getNaverPlaceUrl(), request.introduction(), request.kakaoOpenChatUrl()); - createDesignerDayoffs(designerId,request); + createDesignerDayoffs(designerId, request.dayOffs()); return authService.createUserToken(designerId.toString()); } + + @Transactional + public void updateDesigner(final Long designerId, final MultipartFile profileImg, final DesignerUpdateRequest designerUpdateRequest) { + Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); + s3Service.deleteS3Image(designer.getProfileImgUrl()); + String updatedProfileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); + + updateUserInfos(designerId, new UserUpdateDto(designerUpdateRequest.name(), designerUpdateRequest.gender(), designer.getPhoneNumber(), designer.getIsMarketingAgree()), updatedProfileImgUrl); + designer.update(new HairShop(designerUpdateRequest.hairShop().name(), designerUpdateRequest.hairShop().address(), designerUpdateRequest.hairShop().detailAddress()), new Portfolio(designerUpdateRequest.portfolio().instagramUrl(), designer.getPortfolio().getNaverPlaceUrl()), designerUpdateRequest.introduction(), designerUpdateRequest.kakaoOpenChatUrl()); + designerJpaRepository.save(designer); + deleteDesignerDayoffs(designerId); + createDesignerDayoffs(designerId, designerUpdateRequest.dayOffs()); + } + public void deleteDesignerInfo(final User designer) { - dayOffJpaRepository.deleteAllByDesignerId(designer.getId()); + deleteDesignerDayoffs(designer.getId()); s3Service.deleteS3Image(designer.getProfileImgUrl()); designerJpaRepository.deleteById(designer.getId()); } - private void createDesignerDayoffs(final Long designerId, final DesignerCreateRequest request){ - Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); - request.dayOffs().stream() - .forEach(d -> { - DayOff dayOff = DayOff.builder() - .dayOfWeek(d) - .designer(designer) - .build(); - dayOffJpaRepository.save(dayOff); + private void updateUserInfos(final Long userId, final UserUpdateDto userUpdateDto, final String profilImgUrl) { + final User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); + user.update(userUpdateDto.name(), userUpdateDto.gender(), userUpdateDto.phoneNumber(), userUpdateDto.isMarketingAgree(), profilImgUrl, Role.HAIR_DESIGNER); + } - }); + private void deleteDesignerDayoffs(final Long designerId) { + dayOffJpaRepository.deleteAllByDesignerId(designerId); } + + private void createDesignerDayoffs(final Long designerId, final List dayOffs) { + Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); + dayOffs.forEach(dayOffId -> { + DayOff dayOff = DayOff.builder() + .dayOfWeek(dayOffId) + .designer(designer) + .build(); + dayOffJpaRepository.save(dayOff); + }); + } + } From 63ddc9af853199de080267911472ba072d6f3fc2 Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 24 Apr 2024 10:21:09 +0900 Subject: [PATCH 23/23] =?UTF-8?q?#280=20[feat]=20null=EB=A1=9C=20=EC=98=AC?= =?UTF-8?q?=20=EA=B2=BD=EC=9A=B0=EB=8A=94=20=EC=88=98=EC=A0=95=20=EC=95=88?= =?UTF-8?q?=ED=96=88=EB=8B=A4=EB=8A=94=20=EC=9D=98=EB=AF=B8=EC=9D=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=95=8C=EB=AC=B8=EC=97=90=20=EA=B8=B0=EC=A1=B4?= =?UTF-8?q?=EC=9D=98=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EC=95=88=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/designer/DesignerRegisterService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java b/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java index 5f403d66..6b0150a4 100644 --- a/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java +++ b/src/main/java/com/moddy/server/service/designer/DesignerRegisterService.java @@ -59,10 +59,14 @@ public UserCreateResponse createDesigner(final Long designerId, final DesignerCr @Transactional public void updateDesigner(final Long designerId, final MultipartFile profileImg, final DesignerUpdateRequest designerUpdateRequest) { Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION)); - s3Service.deleteS3Image(designer.getProfileImgUrl()); - String updatedProfileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); - updateUserInfos(designerId, new UserUpdateDto(designerUpdateRequest.name(), designerUpdateRequest.gender(), designer.getPhoneNumber(), designer.getIsMarketingAgree()), updatedProfileImgUrl); + String profileImgUrl = designer.getProfileImgUrl(); + if (profileImg != null) { + s3Service.deleteS3Image(profileImgUrl); + profileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER); + } + + updateUserInfos(designerId, new UserUpdateDto(designerUpdateRequest.name(), designerUpdateRequest.gender(), designer.getPhoneNumber(), designer.getIsMarketingAgree()), profileImgUrl); designer.update(new HairShop(designerUpdateRequest.hairShop().name(), designerUpdateRequest.hairShop().address(), designerUpdateRequest.hairShop().detailAddress()), new Portfolio(designerUpdateRequest.portfolio().instagramUrl(), designer.getPortfolio().getNaverPlaceUrl()), designerUpdateRequest.introduction(), designerUpdateRequest.kakaoOpenChatUrl()); designerJpaRepository.save(designer); deleteDesignerDayoffs(designerId);