Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] estimate 패키지 구조 변경 및 usecase 단위 port, adapter 추가 #325

Merged
merged 7 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<GetEstimateResponse> getEstimate(@PathVariable UUID estimateId) {
GetEstimateResponse getEstimateResponse = getEstimateUseCase.execute(estimateId);
return Response.createSuccessResponse(getEstimateResponse);
GetEstimateResponse response = getEstimateUseCase.execute(estimateId);
return Response.createSuccessResponse(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleBodyTypeDto {
public class EstimateBodyTypeDto {

@Schema(description = "바디타입 이름", example = "바디타입 이름")
private String name;

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleEngineDto {
public class EstimateEngineDto {

@Schema(description = "엔진 이름", example = "엔진 이름")
private String name;

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleExteriorColorDto {
public class EstimateExteriorColorDto {

@Schema(description = "외장색상명", example = "그라파이트 그레이 메탈릭")
private String name;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleInteriorColorDto {
public class EstimateInteriorColorDto {

@Schema(description = "내장색상명", example = "그라파이트 그레이 메탈릭")
private String name;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleOptionDto {
public class EstimateOptionDto {

@Schema(description = "옵션명", example = "주차보조 시스템||")
private String name;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleTrimDto {
public class EstimateTrimDto {

@Schema(description = "트림 이름", example = "트림 이름")
private String name;

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SimpleWheelDriveDto {
public class EstimateWheelDriveDto {

@Schema(description = "구동방식 이름", example = "구동방식 이름")
private String name;

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SimpleOptionDto> additionalOptions;
private List<SimpleOptionDto> considerOptions;
private EstimateTrimDto trim;
private EstimateEngineDto engine;
private EstimateWheelDriveDto wheelDrive;
private EstimateBodyTypeDto bodyType;
private EstimateExteriorColorDto exteriorColor;
private EstimateInteriorColorDto interiorColor;
private List<EstimateOptionDto> selectOptions;
private List<EstimateOptionDto> considerOptions;

public static GetEstimateResponse from(Estimate estimate) {
List<SimpleOptionDto> additionalOptionDtos = estimate.getAdditionalOptions().stream()
.map(SimpleOptionDto::from)
List<EstimateOptionDto> selectOptionDtos = estimate.getSelectOptions().stream()
.map(EstimateOptionDto::from)
.collect(toList());
List<SimpleOptionDto> considerOptionDtos = estimate.getConsiderOptions().stream()
.map(SimpleOptionDto::from)

List<EstimateOptionDto> 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
);
}
Expand Down
Loading
Loading