From 35f38d24361209ab556b50d8b564b8064cd3e7de Mon Sep 17 00:00:00 2001 From: imdh Date: Sun, 20 Aug 2023 15:24:50 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=EA=B2=AC=EC=A0=81=EC=84=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20Port,=20Adaptor=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get_estimate/GetEstimateAdaptor.java | 26 +++++++++++++++++++ .../usecase/get_estimate/GetEstimatePort.java | 13 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java create mode 100644 BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimatePort.java diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java new file mode 100644 index 00000000..8d0b2995 --- /dev/null +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java @@ -0,0 +1,26 @@ +package softeer.be_my_car_master.api.estimate.usecase.get_estimate; + +import java.util.Optional; +import java.util.UUID; + +import org.springframework.transaction.annotation.Transactional; + +import lombok.RequiredArgsConstructor; +import softeer.be_my_car_master.domain.estimate.Estimate; +import softeer.be_my_car_master.global.annotation.Adaptor; +import softeer.be_my_car_master.infrastructure.jpa.estimate.entity.EstimateEntity; +import softeer.be_my_car_master.infrastructure.jpa.estimate.repository.EstimateJpaRepository; + +@Adaptor +@RequiredArgsConstructor +public class GetEstimateAdaptor implements GetEstimatePort{ + + private final EstimateJpaRepository estimateJpaRepository; + + @Override + @Transactional(readOnly = true) + public Optional findFullEstimateByUuid(UUID estimateUuid) { + return estimateJpaRepository.findFullEstimateByUuid(estimateUuid) + .map(EstimateEntity::toEstimate); + } +} diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimatePort.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimatePort.java new file mode 100644 index 00000000..40d3eb12 --- /dev/null +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimatePort.java @@ -0,0 +1,13 @@ +package softeer.be_my_car_master.api.estimate.usecase.get_estimate; + +import java.util.Optional; +import java.util.UUID; + +import softeer.be_my_car_master.domain.estimate.Estimate; +import softeer.be_my_car_master.global.annotation.Port; + +@Port +public interface GetEstimatePort { + + Optional findFullEstimateByUuid(UUID estimateUuid); +} From 9416c64f614cee9d7f52c659eff8139ccd89912a Mon Sep 17 00:00:00 2001 From: imdh Date: Sun, 20 Aug 2023 15:26:28 +0900 Subject: [PATCH 2/7] =?UTF-8?q?chore:=20=EA=B2=AC=EC=A0=81=EC=84=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=B3=80=EC=88=98=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EB=B0=8F=20=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EstimateController.java | 6 ++--- .../get_estimate/GetEstimateAdaptor.java | 2 +- .../GetEstimateUseCase.java | 9 +++---- .../controller/EstimateControllerTest.java | 2 +- .../usecase/GetEstimateUseCaseTest.java | 27 ++++++++++--------- 5 files changed, 23 insertions(+), 23 deletions(-) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/{ => get_estimate}/GetEstimateUseCase.java (64%) diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/controller/EstimateController.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/controller/EstimateController.java index b9a19e81..b2cb0281 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/controller/EstimateController.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/controller/EstimateController.java @@ -17,7 +17,7 @@ import softeer.be_my_car_master.api.estimate.dto.response.CreateEstimateResponse; import softeer.be_my_car_master.api.estimate.dto.response.GetEstimateResponse; import softeer.be_my_car_master.api.estimate.usecase.CreateEstimateUseCase; -import softeer.be_my_car_master.api.estimate.usecase.GetEstimateUseCase; +import softeer.be_my_car_master.api.estimate.usecase.get_estimate.GetEstimateUseCase; import softeer.be_my_car_master.global.response.Response; @RestController @@ -37,7 +37,7 @@ public Response createEstimate(@RequestBody @Valid CreateEstimateRequest createE @GetMapping("/estimates/{estimateId}") @Operation(summary = "견적서 조회") public Response getEstimate(@PathVariable UUID estimateId) { - GetEstimateResponse getEstimateResponse = getEstimateUseCase.execute(estimateId); - return Response.createSuccessResponse(getEstimateResponse); + GetEstimateResponse response = getEstimateUseCase.execute(estimateId); + return Response.createSuccessResponse(response); } } diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java index 8d0b2995..bf065ae8 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateAdaptor.java @@ -13,7 +13,7 @@ @Adaptor @RequiredArgsConstructor -public class GetEstimateAdaptor implements GetEstimatePort{ +public class GetEstimateAdaptor implements GetEstimatePort { private final EstimateJpaRepository estimateJpaRepository; diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCase.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateUseCase.java similarity index 64% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCase.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateUseCase.java index 85b41cb5..4297d822 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCase.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/get_estimate/GetEstimateUseCase.java @@ -1,11 +1,10 @@ -package softeer.be_my_car_master.api.estimate.usecase; +package softeer.be_my_car_master.api.estimate.usecase.get_estimate; import java.util.UUID; import lombok.RequiredArgsConstructor; import softeer.be_my_car_master.api.estimate.dto.response.GetEstimateResponse; import softeer.be_my_car_master.api.estimate.exception.InvalidEstimationException; -import softeer.be_my_car_master.api.estimate.usecase.port.EstimatePort; import softeer.be_my_car_master.domain.estimate.Estimate; import softeer.be_my_car_master.global.annotation.UseCase; @@ -13,10 +12,10 @@ @RequiredArgsConstructor public class GetEstimateUseCase { - private final EstimatePort estimatePort; + private final GetEstimatePort port; - public GetEstimateResponse execute(UUID estimateId) { - Estimate estimate = estimatePort.findFullEstimateByUuid(estimateId) + public GetEstimateResponse execute(UUID estimateUuid) { + Estimate estimate = port.findFullEstimateByUuid(estimateUuid) .orElseThrow(() -> InvalidEstimationException.EXCEPTION); return GetEstimateResponse.from(estimate); } diff --git a/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/controller/EstimateControllerTest.java b/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/controller/EstimateControllerTest.java index c89a64f8..9716de92 100644 --- a/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/controller/EstimateControllerTest.java +++ b/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/controller/EstimateControllerTest.java @@ -27,7 +27,7 @@ import softeer.be_my_car_master.api.estimate.dto.response.SimpleTrimDto; import softeer.be_my_car_master.api.estimate.dto.response.SimpleWheelDriveDto; import softeer.be_my_car_master.api.estimate.usecase.CreateEstimateUseCase; -import softeer.be_my_car_master.api.estimate.usecase.GetEstimateUseCase; +import softeer.be_my_car_master.api.estimate.usecase.get_estimate.GetEstimateUseCase; import softeer.be_my_car_master.global.response.Response; @WebMvcTest(EstimateController.class) diff --git a/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCaseTest.java b/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCaseTest.java index 0c62943b..c5362ade 100644 --- a/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCaseTest.java +++ b/BE-MyCarMaster/src/test/java/softeer/be_my_car_master/api/estimate/usecase/GetEstimateUseCaseTest.java @@ -22,7 +22,8 @@ import softeer.be_my_car_master.api.estimate.dto.response.SimpleOptionDto; import softeer.be_my_car_master.api.estimate.dto.response.SimpleTrimDto; import softeer.be_my_car_master.api.estimate.dto.response.SimpleWheelDriveDto; -import softeer.be_my_car_master.api.estimate.usecase.port.EstimatePort; +import softeer.be_my_car_master.api.estimate.usecase.get_estimate.GetEstimatePort; +import softeer.be_my_car_master.api.estimate.usecase.get_estimate.GetEstimateUseCase; import softeer.be_my_car_master.domain.body_type.BodyType; import softeer.be_my_car_master.domain.color_exterior.ExteriorColor; import softeer.be_my_car_master.domain.color_interior.InteriorColor; @@ -37,10 +38,10 @@ public class GetEstimateUseCaseTest { @InjectMocks - private GetEstimateUseCase getEstimateUseCase; + private GetEstimateUseCase useCase; @Mock - private EstimatePort estimatePort; + private GetEstimatePort port; @Test @DisplayName("견적서를 조회합니다") @@ -91,21 +92,21 @@ void execute() { .considerOptions(List.of(option)) .build(); - given(estimatePort.findFullEstimateByUuid(any())).willReturn(Optional.ofNullable(estimate)); + given(port.findFullEstimateByUuid(any())).willReturn(Optional.ofNullable(estimate)); // when - GetEstimateResponse getEstimateResponse = getEstimateUseCase.execute(UUID.randomUUID()); + GetEstimateResponse response = useCase.execute(UUID.randomUUID()); // then - SimpleTrimDto trimExpected = getEstimateResponse.getTrim(); - SimpleEngineDto engineExpected = getEstimateResponse.getEngine(); - SimpleWheelDriveDto wheelDriveExpected = getEstimateResponse.getWheelDrive(); - SimpleBodyTypeDto bodyTypeExpected = getEstimateResponse.getBodyType(); - SimpleExteriorColorDto exteriorColorExpected = getEstimateResponse.getExteriorColor(); - SimpleInteriorColorDto interiorColorExpected = getEstimateResponse.getInteriorColor(); - List additionOptionDtos = getEstimateResponse.getAdditionalOptions(); + SimpleTrimDto trimExpected = response.getTrim(); + SimpleEngineDto engineExpected = response.getEngine(); + SimpleWheelDriveDto wheelDriveExpected = response.getWheelDrive(); + SimpleBodyTypeDto bodyTypeExpected = response.getBodyType(); + SimpleExteriorColorDto exteriorColorExpected = response.getExteriorColor(); + SimpleInteriorColorDto interiorColorExpected = response.getInteriorColor(); + List additionOptionDtos = response.getAdditionalOptions(); SimpleOptionDto additionalOptionExpected = additionOptionDtos.get(0); - List considerOptionDtos = getEstimateResponse.getConsiderOptions(); + List considerOptionDtos = response.getConsiderOptions(); SimpleOptionDto considerOptionExpected = considerOptionDtos.get(0); SoftAssertions.assertSoftly(softAssertions -> { From a4e333129be9e09a1972626ff079c202385bdbaf Mon Sep 17 00:00:00 2001 From: imdh Date: Sun, 20 Aug 2023 16:15:03 +0900 Subject: [PATCH 3/7] =?UTF-8?q?chore:=20Dto=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?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 Simple -> Estimate로 변경 --- .../{SimpleBodyTypeDto.java => EstimateBodyTypeDto.java} | 6 +++--- .../{SimpleEngineDto.java => EstimateEngineDto.java} | 6 +++--- ...eExteriorColorDto.java => EstimateExteriorColorDto.java} | 6 +++--- ...eInteriorColorDto.java => EstimateInteriorColorDto.java} | 6 +++--- .../{SimpleOptionDto.java => EstimateOptionDto.java} | 6 +++--- .../response/{SimpleTrimDto.java => EstimateTrimDto.java} | 6 +++--- ...{SimpleWheelDriveDto.java => EstimateWheelDriveDto.java} | 6 +++--- .../infrastructure/jpa/estimate/entity/EstimateEntity.java | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleBodyTypeDto.java => EstimateBodyTypeDto.java} (82%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleEngineDto.java => EstimateEngineDto.java} (83%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleExteriorColorDto.java => EstimateExteriorColorDto.java} (86%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleInteriorColorDto.java => EstimateInteriorColorDto.java} (83%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleOptionDto.java => EstimateOptionDto.java} (85%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleTrimDto.java => EstimateTrimDto.java} (84%) rename BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/{SimpleWheelDriveDto.java => EstimateWheelDriveDto.java} (81%) diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleBodyTypeDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateBodyTypeDto.java similarity index 82% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleBodyTypeDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateBodyTypeDto.java index d574ea5d..7d0beeab 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleBodyTypeDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateBodyTypeDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleBodyTypeDto { +public class EstimateBodyTypeDto { @Schema(description = "바디타입 이름", example = "바디타입 이름") private String name; @@ -20,8 +20,8 @@ public class SimpleBodyTypeDto { @Schema(description = "추가 비용", example = "10000") private Integer price; - public static SimpleBodyTypeDto from(BodyType bodyType) { - return SimpleBodyTypeDto.builder() + public static EstimateBodyTypeDto from(BodyType bodyType) { + return EstimateBodyTypeDto.builder() .name(bodyType.getName()) .price(bodyType.getPrice()) .build(); diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleEngineDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateEngineDto.java similarity index 83% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleEngineDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateEngineDto.java index d8c5a1c7..f76912d6 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleEngineDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateEngineDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleEngineDto { +public class EstimateEngineDto { @Schema(description = "엔진 이름", example = "엔진 이름") private String name; @@ -20,8 +20,8 @@ public class SimpleEngineDto { @Schema(description = "추가 비용", example = "10000") private Integer price; - public static SimpleEngineDto from(Engine engine) { - return SimpleEngineDto.builder() + public static EstimateEngineDto from(Engine engine) { + return EstimateEngineDto.builder() .name(engine.getName()) .price(engine.getPrice()) .build(); diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleExteriorColorDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateExteriorColorDto.java similarity index 86% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleExteriorColorDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateExteriorColorDto.java index b3eeffb3..2ef08701 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleExteriorColorDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateExteriorColorDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleExteriorColorDto { +public class EstimateExteriorColorDto { @Schema(description = "외장색상명", example = "그라파이트 그레이 메탈릭") private String name; @@ -26,8 +26,8 @@ public class SimpleExteriorColorDto { @Schema(description = "외장색상이 적용된 차량 이미지", example = "coloredImgUrl") private String coloredImgUrl; - public static SimpleExteriorColorDto from(ExteriorColor exteriorColor) { - return SimpleExteriorColorDto.builder() + public static EstimateExteriorColorDto from(ExteriorColor exteriorColor) { + return EstimateExteriorColorDto.builder() .name(exteriorColor.getName()) .price(exteriorColor.getPrice()) .colorImgUrl(exteriorColor.getColorImgUrl()) diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleInteriorColorDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateInteriorColorDto.java similarity index 83% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleInteriorColorDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateInteriorColorDto.java index f45a5015..3438b571 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleInteriorColorDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateInteriorColorDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleInteriorColorDto { +public class EstimateInteriorColorDto { @Schema(description = "내장색상명", example = "그라파이트 그레이 메탈릭") private String name; @@ -23,8 +23,8 @@ public class SimpleInteriorColorDto { @Schema(description = "내장색상 이미지", example = "colorImgUrl") private String colorImgUrl; - public static SimpleInteriorColorDto from(InteriorColor interiorColor) { - return SimpleInteriorColorDto.builder() + public static EstimateInteriorColorDto from(InteriorColor interiorColor) { + return EstimateInteriorColorDto.builder() .name(interiorColor.getName()) .price(interiorColor.getPrice()) .colorImgUrl(interiorColor.getColorImgUrl()) diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleOptionDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateOptionDto.java similarity index 85% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleOptionDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateOptionDto.java index b4ec8fca..1e6f0e63 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleOptionDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateOptionDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleOptionDto { +public class EstimateOptionDto { @Schema(description = "옵션명", example = "주차보조 시스템||") private String name; @@ -23,8 +23,8 @@ public class SimpleOptionDto { @Schema(description = "옵션 이미지", example = "null") private String imgUrl; - public static SimpleOptionDto from(Option option) { - return SimpleOptionDto.builder() + public static EstimateOptionDto from(Option option) { + return EstimateOptionDto.builder() .name(option.getName()) .price(option.getPrice()) .imgUrl(option.getImgUrl()) diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleTrimDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateTrimDto.java similarity index 84% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleTrimDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateTrimDto.java index 6ffdec98..4482640c 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleTrimDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateTrimDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleTrimDto { +public class EstimateTrimDto { @Schema(description = "트림 이름", example = "트림 이름") private String name; @@ -20,8 +20,8 @@ public class SimpleTrimDto { @Schema(description = "트림 기본 비용", example = "40000000") private Integer price; - public static SimpleTrimDto from(Trim trim) { - return SimpleTrimDto.builder() + public static EstimateTrimDto from(Trim trim) { + return EstimateTrimDto.builder() .name(trim.getName()) .price(trim.getPrice()) .build(); diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleWheelDriveDto.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateWheelDriveDto.java similarity index 81% rename from BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleWheelDriveDto.java rename to BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateWheelDriveDto.java index af27bcd7..b945efc1 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/SimpleWheelDriveDto.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/EstimateWheelDriveDto.java @@ -12,7 +12,7 @@ @Setter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SimpleWheelDriveDto { +public class EstimateWheelDriveDto { @Schema(description = "구동방식 이름", example = "구동방식 이름") private String name; @@ -20,8 +20,8 @@ public class SimpleWheelDriveDto { @Schema(description = "추가 비용", example = "10000") private Integer price; - public static SimpleWheelDriveDto from(WheelDrive wheelDrive) { - return SimpleWheelDriveDto.builder() + public static EstimateWheelDriveDto from(WheelDrive wheelDrive) { + return EstimateWheelDriveDto.builder() .name(wheelDrive.getName()) .price(wheelDrive.getPrice()) .build(); diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/infrastructure/jpa/estimate/entity/EstimateEntity.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/infrastructure/jpa/estimate/entity/EstimateEntity.java index f3568418..26157d06 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/infrastructure/jpa/estimate/entity/EstimateEntity.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/infrastructure/jpa/estimate/entity/EstimateEntity.java @@ -163,7 +163,7 @@ public Estimate toEstimate() { .bodyType(bodyType.toBodyType()) .exteriorColor(exteriorColor.toExteriorColor(trim.getId())) .interiorColor(interiorColor.toInteriorColor(trim.getId())) - .additionalOptions(additionalOptions) + .selectedOptions(additionalOptions) .considerOptions(considerOptions) .build(); } From 9291656d119d6c6616a672d7c2d0370b182cc63a Mon Sep 17 00:00:00 2001 From: imdh Date: Sun, 20 Aug 2023 17:26:16 +0900 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=EA=B2=AC=EC=A0=81=EC=84=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20Port,=20Adaptor=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateEstimateAdaptor.java | 212 ++++++++++++++++++ .../create_estimate/CreateEstimatePort.java | 52 +++++ 2 files changed, 264 insertions(+) create mode 100644 BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/create_estimate/CreateEstimateAdaptor.java create mode 100644 BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/create_estimate/CreateEstimatePort.java diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/create_estimate/CreateEstimateAdaptor.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/create_estimate/CreateEstimateAdaptor.java new file mode 100644 index 00000000..7e8dfe01 --- /dev/null +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/create_estimate/CreateEstimateAdaptor.java @@ -0,0 +1,212 @@ +package softeer.be_my_car_master.api.estimate.usecase.create_estimate; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.springframework.transaction.annotation.Transactional; + +import lombok.RequiredArgsConstructor; +import softeer.be_my_car_master.api.estimate.dto.request.CreateEstimateRequest; +import softeer.be_my_car_master.api.estimate.dto.request.EstimateOptionDto; +import softeer.be_my_car_master.domain.body_type.BodyType; +import softeer.be_my_car_master.domain.color_exterior.ExteriorColor; +import softeer.be_my_car_master.domain.color_interior.InteriorColor; +import softeer.be_my_car_master.domain.engine.Engine; +import softeer.be_my_car_master.domain.model.Model; +import softeer.be_my_car_master.domain.option.Option; +import softeer.be_my_car_master.domain.trim.Trim; +import softeer.be_my_car_master.domain.wheel_dirve.WheelDrive; +import softeer.be_my_car_master.global.annotation.Adaptor; +import softeer.be_my_car_master.infrastructure.jpa.body_type.entity.BodyTypeEntity; +import softeer.be_my_car_master.infrastructure.jpa.body_type.repository.BodyTypeJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.color_exterior.entity.ExteriorColorEntity; +import softeer.be_my_car_master.infrastructure.jpa.color_exterior.entity.TrimExteriorColorEntity; +import softeer.be_my_car_master.infrastructure.jpa.color_exterior.repository.ExteriorColorJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.color_exterior.repository.TrimExteriorColorJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.color_interior.entity.InteriorColorEntity; +import softeer.be_my_car_master.infrastructure.jpa.color_interior.entity.TrimInteriorColorEntity; +import softeer.be_my_car_master.infrastructure.jpa.color_interior.repository.ExteriorUnselectableInteriorJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.color_interior.repository.InteriorColorJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.color_interior.repository.TrimInteriorColorJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.engine.entity.EngineEntity; +import softeer.be_my_car_master.infrastructure.jpa.engine.entity.TrimEngineEntity; +import softeer.be_my_car_master.infrastructure.jpa.engine.repository.EngineJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.engine.repository.TrimEngineJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.estimate.entity.EstimateEntity; +import softeer.be_my_car_master.infrastructure.jpa.estimate.repository.EstimateJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.model.entity.ModelEntity; +import softeer.be_my_car_master.infrastructure.jpa.model.repository.ModelJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.entity.OptionEntity; +import softeer.be_my_car_master.infrastructure.jpa.option.entity.TrimAdditionalOptionEntity; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.BodyTypeUnselectableOptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.EngineUnselectableOptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.InteriorColorUnselectableOptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.OptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.TrimAdditionalOptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.option.repository.WheelDriveUnselectableOptionJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.trim.entity.TrimEntity; +import softeer.be_my_car_master.infrastructure.jpa.trim.repository.TrimJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.wheel_drive.entity.TrimWheelDriveEntity; +import softeer.be_my_car_master.infrastructure.jpa.wheel_drive.entity.WheelDriveEntity; +import softeer.be_my_car_master.infrastructure.jpa.wheel_drive.repository.EngineUnselectableWheelDriveJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.wheel_drive.repository.TrimWheelDriveJpaRepository; +import softeer.be_my_car_master.infrastructure.jpa.wheel_drive.repository.WheelDriveJpaRepository; + +@Adaptor +@RequiredArgsConstructor +public class CreateEstimateAdaptor implements CreateEstimatePort { + + private final EstimateJpaRepository estimateRepository; + private final ModelJpaRepository modelJpaRepository; + private final TrimJpaRepository trimJpaRepository; + private final EngineJpaRepository engineJpaRepository; + private final WheelDriveJpaRepository wheelDriveJpaRepository; + private final BodyTypeJpaRepository bodyTypeJpaRepository; + private final ExteriorColorJpaRepository exteriorColorJpaRepository; + private final InteriorColorJpaRepository interiorColorJpaRepository; + private final OptionJpaRepository optionJpaRepository; + private final TrimEngineJpaRepository trimEngineJpaRepository; + private final TrimWheelDriveJpaRepository trimWheelDriveJpaRepository; + private final EngineUnselectableWheelDriveJpaRepository engineUnselectableWheelDriveJpaRepository; + private final TrimExteriorColorJpaRepository trimExteriorColorJpaRepository; + private final TrimInteriorColorJpaRepository trimInteriorColorJpaRepository; + private final ExteriorUnselectableInteriorJpaRepository exteriorUnselectableInteriorJpaRepository; + private final TrimAdditionalOptionJpaRepository trimAdditionalOptionJpaRepository; + private final EngineUnselectableOptionJpaRepository engineUnselectableOptionJpaRepository; + private final WheelDriveUnselectableOptionJpaRepository wheelDriveUnselectableOptionJpaRepository; + private final BodyTypeUnselectableOptionJpaRepository bodyTypeUnselectableOptionJpaRepository; + private final InteriorColorUnselectableOptionJpaRepository interiorColorUnselectableOptionJpaRepository; + + @Override + public List findModels() { + return modelJpaRepository.findAll().stream() + .map(ModelEntity::toModel) + .collect(Collectors.toList()); + } + + @Override + public List findTrimsByModel(Long modelId) { + return trimJpaRepository.findAllByModelId(modelId).stream() + .map(TrimEntity::toTrim) + .collect(Collectors.toList()); + } + + @Override + public List findEnginesByTrim(Long trimId) { + return trimEngineJpaRepository.findAllByTrimId(trimId).stream() + .map(TrimEngineEntity::toEngine) + .collect(Collectors.toList()); + } + + @Override + public List findBodyTypesByModel(Long modelId) { + return bodyTypeJpaRepository.findAllByModelId(modelId).stream() + .map(BodyTypeEntity::toBodyType) + .collect(Collectors.toList()); + } + + @Override + public List findWheelDrivesByTrim(Long trimId) { + return trimWheelDriveJpaRepository.findAllByTrimId(trimId).stream() + .map(TrimWheelDriveEntity::toWheelDrive) + .collect(Collectors.toList()); + } + + @Override + public List findUnselectableWheelDriveIdsByEngine(Long engineId) { + return engineUnselectableWheelDriveJpaRepository + .findUnselectableWheelDriveIdsByEngineId(engineId); + } + + @Override + public List findExteriorColorsByTrim(Long trimId) { + return trimExteriorColorJpaRepository.findAllByTrimId(trimId).stream() + .map(TrimExteriorColorEntity::toExteriorColor) + .collect(Collectors.toList()); + } + + @Override + public List findInteriorColorsByTrim(Long trimId) { + return trimInteriorColorJpaRepository.findAllByTrimId(trimId).stream() + .map(TrimInteriorColorEntity::toInteriorColor) + .collect(Collectors.toList()); + } + + @Override + public List findUnselectableInteriorColorIdsByExteriorColor(Long exteriorColorId) { + return exteriorUnselectableInteriorJpaRepository + .findUnselectableInteriorColorIdsByExteriorColorId(exteriorColorId); + } + + @Override + @Transactional(readOnly = true) + public List