From 5e738436fee5546bc0f681e2d56a14ca55b4b70a Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 31 Jan 2024 21:29:24 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#221=20[refactor]=20=EC=A0=9C=EC=95=88?= =?UTF-8?q?=EC=84=9C=20=EC=8A=B9=EB=82=99=ED=95=98=EA=B8=B0=20Controller?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/model/ModelController.java | 18 ------- .../controller/offer/OfferController.java | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/moddy/server/controller/offer/OfferController.java 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 a8337d72..752f7538 100644 --- a/src/main/java/com/moddy/server/controller/model/ModelController.java +++ b/src/main/java/com/moddy/server/controller/model/ModelController.java @@ -31,7 +31,6 @@ 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.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -123,23 +122,6 @@ public SuccessResponse getOpenChat( return SuccessResponse.success(SuccessCode.OPEN_CHAT_GET_SUCCESS, hairServiceOfferRetrieveService.getOpenChatInfo(userId, offerId)); } - @Tag(name = "ModelController") - @Operation(summary = "[JWT] 디자이너 제안서 승낙하기", description = "디자이너 제안서 승낙하기 API입니다.") - @ApiResponses({ - @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("/model/offer/{offerId}") - @SecurityRequirement(name = "JWT Auth") - public SuccessNonDataResponse acceptOffer( - @Parameter(hidden = true) @UserId Long userId, - @Parameter(name = "offerId", description = "제안서아이디") @PathVariable(value = "offerId") Long offerId) { - modelService.updateOfferAgreeStatus(offerId); - return SuccessNonDataResponse.success(SuccessCode.OFFER_ACCEPT_SUCCESS); - } - @Tag(name = "ModelController") @Operation(summary = "[JWT] 모델 지원서 작성", description = "모델 지원서 작성 API입니다.") @ApiResponses({ diff --git a/src/main/java/com/moddy/server/controller/offer/OfferController.java b/src/main/java/com/moddy/server/controller/offer/OfferController.java new file mode 100644 index 00000000..b34ceb8a --- /dev/null +++ b/src/main/java/com/moddy/server/controller/offer/OfferController.java @@ -0,0 +1,47 @@ +package com.moddy.server.controller.offer; + +import com.moddy.server.common.dto.ErrorResponse; +import com.moddy.server.common.dto.SuccessNonDataResponse; +import com.moddy.server.common.exception.enums.SuccessCode; +import com.moddy.server.config.resolver.user.UserId; +import com.moddy.server.service.offer.HairServiceOfferRegisterService; +import com.moddy.server.service.offer.HairServiceOfferRetrieveService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +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.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class OfferController { + + private final HairServiceOfferRetrieveService hairServiceOfferRetrieveService; + private final HairServiceOfferRegisterService hairServiceOfferRegisterService; + + @Tag(name = "ModelController") + @Operation(summary = "[JWT] 디자이너 제안서 승낙하기", description = "디자이너 제안서 승낙하기 API입니다.") + @ApiResponses({ + @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("/model/offer/{offerId}") + @SecurityRequirement(name = "JWT Auth") + public SuccessNonDataResponse acceptOffer( + @Parameter(hidden = true) @UserId Long userId, + @Parameter(name = "offerId", description = "제안서아이디") @PathVariable(value = "offerId") Long offerId) { + hairServiceOfferRegisterService.updateOfferAgreeStatus(offerId); + return SuccessNonDataResponse.success(SuccessCode.OFFER_ACCEPT_SUCCESS); + } + +} + From fa5111b19283bb28d4ab4f32e08041a80b2e18bf Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 31 Jan 2024 21:30:27 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#221=20[refactor]=20=EC=A0=9C=EC=95=88?= =?UTF-8?q?=EC=84=9C=20=EC=8A=B9=EB=82=99=20OfferRegisterService=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/model/ModelService.java | 21 ------------------- .../HairServiceOfferRegisterService.java | 9 ++++++++ 2 files changed, 9 insertions(+), 21 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 ef51f595..6a5a9696 100644 --- a/src/main/java/com/moddy/server/service/model/ModelService.java +++ b/src/main/java/com/moddy/server/service/model/ModelService.java @@ -2,18 +2,13 @@ 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.response.UserCreateResponse; import com.moddy.server.controller.model.dto.request.ModelApplicationRequest; -import com.moddy.server.controller.model.dto.request.ModelCreateRequest; import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse; -import com.moddy.server.controller.model.dto.response.DesignerInfoOpenChatResponse; import com.moddy.server.controller.model.dto.response.DesignerInfoResponse; 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.OfferResponse; -import com.moddy.server.controller.model.dto.response.OpenChatResponse; import com.moddy.server.controller.model.dto.response.StyleDetailResponse; import com.moddy.server.domain.day_off.DayOff; import com.moddy.server.domain.day_off.repository.DayOffJpaRepository; @@ -33,16 +28,9 @@ import com.moddy.server.domain.prefer_offer_condition.OfferCondition; import com.moddy.server.domain.prefer_offer_condition.PreferOfferCondition; import com.moddy.server.domain.prefer_offer_condition.repository.PreferOfferConditionJpaRepository; -import com.moddy.server.domain.prefer_region.PreferRegion; import com.moddy.server.domain.prefer_region.repository.PreferRegionJpaRepository; -import com.moddy.server.domain.region.Region; -import com.moddy.server.domain.region.repository.RegionJpaRepository; -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.s3.S3Service; -import com.moddy.server.service.auth.AuthService; -import com.moddy.server.service.designer.DesignerRetrieveService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -71,8 +59,6 @@ public class ModelService { private final PreferRegionJpaRepository preferRegionJpaRepository; private final HairServiceRecordJpaRepository hairServiceRecordJpaRepository; private final S3Service s3Service; - private final DesignerRetrieveService designerRetrieveService; - public ModelMainResponse getModelMainInfo(Long userId, int page, int size) { @@ -138,13 +124,6 @@ public DetailOfferResponse getOfferDetail(Long userId, Long offerId) { return new DetailOfferResponse(designerInfoResponseList, styleDetailResponse); } - @Transactional - public void updateOfferAgreeStatus(Long offerId) { - HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION)); - - hairServiceOffer.setIsModelAgree(true); - } - public ApplicationUserDetailResponse getUserDetailInApplication(final Long userId) { Model model = modelJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); List preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId()) diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java index 392e7529..ae2d4c32 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java @@ -1,10 +1,13 @@ package com.moddy.server.service.offer; +import com.moddy.server.common.exception.enums.ErrorCode; +import com.moddy.server.common.exception.model.NotFoundException; import com.moddy.server.domain.hair_service_offer.HairServiceOffer; import com.moddy.server.domain.hair_service_offer.repository.HairServiceOfferJpaRepository; import com.moddy.server.domain.prefer_offer_condition.repository.PreferOfferConditionJpaRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -29,4 +32,10 @@ public void deleteDesignerHairServiceOfferInfos(final Long designerId) { hairServiceOfferJpaRepository.deleteById(hairServiceOffer.getId()); }); } + + public void updateOfferAgreeStatus(final Long offerId) { + HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION)); + + hairServiceOffer.setIsModelAgree(true); + } } From 6c4e815c0de6733046ed115e6c9ea0b57bed802c Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Wed, 31 Jan 2024 21:34:54 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#221=20[feat]=20update=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EC=97=90=20@Transactional=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/offer/HairServiceOfferRegisterService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java index ae2d4c32..9ca06d7d 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java @@ -33,6 +33,7 @@ public void deleteDesignerHairServiceOfferInfos(final Long designerId) { }); } + @Transactional public void updateOfferAgreeStatus(final Long offerId) { HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION)); From 501af727d42c05a519aeab647da2db583829d8bd Mon Sep 17 00:00:00 2001 From: hellozo0 Date: Fri, 2 Feb 2024 18:31:50 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#221=20[refactor]=20=EC=A0=9C=EC=95=88?= =?UTF-8?q?=EC=84=9C=20=EC=8A=B9=EB=82=99=EC=97=AC=EB=B6=80=20true=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=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/domain/hair_service_offer/HairServiceOffer.java | 4 ++-- .../server/service/offer/HairServiceOfferRegisterService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java b/src/main/java/com/moddy/server/domain/hair_service_offer/HairServiceOffer.java index f5c2e330..15225c24 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 @@ -41,8 +41,8 @@ public class HairServiceOffer extends BaseTimeEntity { @NotNull private Boolean isClicked; - public void setIsModelAgree(final Boolean isModelAgree){ - this.isModelAgree = isModelAgree; + public void agreeOfferToModel(){ + this.isModelAgree = true; } public void updateClickStatus() { this.isClicked = true; } diff --git a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java index 9ca06d7d..03b2f33c 100644 --- a/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java +++ b/src/main/java/com/moddy/server/service/offer/HairServiceOfferRegisterService.java @@ -37,6 +37,6 @@ public void deleteDesignerHairServiceOfferInfos(final Long designerId) { public void updateOfferAgreeStatus(final Long offerId) { HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_OFFER_EXCEPTION)); - hairServiceOffer.setIsModelAgree(true); + hairServiceOffer.agreeOfferToModel(); } }