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..cf82af7c 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 @@ -16,8 +16,8 @@ import softeer.be_my_car_master.api.estimate.dto.request.CreateEstimateRequest; 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.create_estimate.CreateEstimateUseCase; +import softeer.be_my_car_master.api.estimate.usecase.get_estimate.GetEstimateUseCase; import softeer.be_my_car_master.global.response.Response; @RestController @@ -29,15 +29,16 @@ public class EstimateController { private final GetEstimateUseCase getEstimateUseCase; @PostMapping("/estimates") - public Response createEstimate(@RequestBody @Valid CreateEstimateRequest createEstimateRequest) { - CreateEstimateResponse createEstimateResponse = createEstimateUseCase.execute(createEstimateRequest); - return Response.createSuccessResponse(createEstimateResponse); + @Operation(summary = "선택한 내용들로 견적서를 생성합니다.") + public Response createEstimate(@RequestBody @Valid CreateEstimateRequest request) { + CreateEstimateResponse response = createEstimateUseCase.execute(request); + return Response.createSuccessResponse(response); } @GetMapping("/estimates/{estimateId}") - @Operation(summary = "견적서 조회") + @Operation(summary = "견적서 ID로 견적서를 조회합니다.") 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/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/api/estimate/dto/response/GetEstimateResponse.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/GetEstimateResponse.java index d656e1d2..5240a9b7 100644 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/GetEstimateResponse.java +++ b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/dto/response/GetEstimateResponse.java @@ -17,30 +17,32 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) public class GetEstimateResponse { - private SimpleTrimDto trim; - private SimpleEngineDto engine; - private SimpleWheelDriveDto wheelDrive; - private SimpleBodyTypeDto bodyType; - private SimpleExteriorColorDto exteriorColor; - private SimpleInteriorColorDto interiorColor; - private List additionalOptions; - private List considerOptions; + private EstimateTrimDto trim; + private EstimateEngineDto engine; + private EstimateWheelDriveDto wheelDrive; + private EstimateBodyTypeDto bodyType; + private EstimateExteriorColorDto exteriorColor; + private EstimateInteriorColorDto interiorColor; + private List selectOptions; + private List considerOptions; public static GetEstimateResponse from(Estimate estimate) { - List additionalOptionDtos = estimate.getAdditionalOptions().stream() - .map(SimpleOptionDto::from) + List selectOptionDtos = estimate.getSelectOptions().stream() + .map(EstimateOptionDto::from) .collect(toList()); - List considerOptionDtos = estimate.getConsiderOptions().stream() - .map(SimpleOptionDto::from) + + List considerOptionDtos = estimate.getConsiderOptions().stream() + .map(EstimateOptionDto::from) .collect(toList()); + return new GetEstimateResponse( - SimpleTrimDto.from(estimate.getTrim()), - SimpleEngineDto.from(estimate.getEngine()), - SimpleWheelDriveDto.from(estimate.getWheelDrive()), - SimpleBodyTypeDto.from(estimate.getBodyType()), - SimpleExteriorColorDto.from(estimate.getExteriorColor()), - SimpleInteriorColorDto.from(estimate.getInteriorColor()), - additionalOptionDtos, + EstimateTrimDto.from(estimate.getTrim()), + EstimateEngineDto.from(estimate.getEngine()), + EstimateWheelDriveDto.from(estimate.getWheelDrive()), + EstimateBodyTypeDto.from(estimate.getBodyType()), + EstimateExteriorColorDto.from(estimate.getExteriorColor()), + EstimateInteriorColorDto.from(estimate.getInteriorColor()), + selectOptionDtos, considerOptionDtos ); } diff --git a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/CreateEstimateUseCase.java b/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/CreateEstimateUseCase.java deleted file mode 100644 index ebe4cbff..00000000 --- a/BE-MyCarMaster/src/main/java/softeer/be_my_car_master/api/estimate/usecase/CreateEstimateUseCase.java +++ /dev/null @@ -1,221 +0,0 @@ -package softeer.be_my_car_master.api.estimate.usecase; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.springframework.transaction.annotation.Transactional; - -import lombok.RequiredArgsConstructor; -import softeer.be_my_car_master.api.body_type.usecase.port.BodyTypePort; -import softeer.be_my_car_master.api.color_exterior.usecase.port.ExteriorColorPort; -import softeer.be_my_car_master.api.color_interior.usecase.port.InteriorColorPort; -import softeer.be_my_car_master.api.engine.usecase.port.EnginePort; -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.api.estimate.dto.response.CreateEstimateResponse; -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.api.model.usecase.get_models.GetModelsPort; -import softeer.be_my_car_master.api.option.usecase.port.OptionPort; -import softeer.be_my_car_master.api.trim.usecase.port.TrimPort; -import softeer.be_my_car_master.api.wheeldrive.usecase.port.WheelDrivePort; -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.UseCase; - -@UseCase -@RequiredArgsConstructor -public class CreateEstimateUseCase { - - private final GetModelsPort modelPort; - private final TrimPort trimPort; - private final EnginePort enginePort; - private final BodyTypePort bodyTypePort; - private final WheelDrivePort wheelDrivePort; - private final ExteriorColorPort exteriorColorPort; - private final InteriorColorPort interiorColorPort; - private final OptionPort optionPort; - private final EstimatePort estimatePort; - - @Transactional - public CreateEstimateResponse execute(CreateEstimateRequest createEstimateRequest) { - Long modelId = createEstimateRequest.getModelId(); - List models = modelPort.findModels(); - validateModel(modelId, models); - - List trims = trimPort.findTrimsByModel(modelId); - validateTrim(createEstimateRequest, trims); - - List engines = enginePort.findSelectableEnginesByTrimId(createEstimateRequest.getTrimId()); - validateEngine(createEstimateRequest, engines); - - List bodyTypes = bodyTypePort.findSelectableBodyTypesByModelId(modelId); - validateBodyType(createEstimateRequest, bodyTypes); - - List wheelDrives = - wheelDrivePort.findSelectableWheelDrivesByTrimId(createEstimateRequest.getTrimId()); - List unselectableWheelDriveIds = - wheelDrivePort.findUnselectableWheelDriveIdsByEngineId(createEstimateRequest.getEngineId()); - List selectableWheelDrives = wheelDrives.stream() - .filter(wheelDrive -> wheelDrive.isSelectable(unselectableWheelDriveIds)) - .collect(Collectors.toList()); - validateWheelDrive(createEstimateRequest, selectableWheelDrives); - - List exteriorColors = - exteriorColorPort.findSelectableExteriorColorsByTrimId(createEstimateRequest.getTrimId()); - validateExteriorColor(createEstimateRequest, exteriorColors); - - List interiorColors = - interiorColorPort.findSelectableInteriorColorsByTrimId(createEstimateRequest.getTrimId()); - List unselectableInteriorColorIds = - interiorColorPort.findUnselectableInteriorColorIdsByExteriorColorId( - createEstimateRequest.getExteriorColorId()); - List selectableInteriorColors = interiorColors.stream() - .filter(interiorColor -> interiorColor.isSelectable(unselectableInteriorColorIds)) - .collect(Collectors.toList()); - validateInteriorColor(createEstimateRequest, selectableInteriorColors); - - List