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

[BE] Quote 관련 리팩토링 #436

Merged
merged 8 commits into from
Aug 24, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import autoever2.cartag.cars.dto.CarInfoDto;
import autoever2.cartag.cars.dto.CarTypeDto;
import autoever2.cartag.cars.dto.TrimInfoDto;
import autoever2.cartag.cars.dto.TrimDataDto;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
Expand Down Expand Up @@ -53,7 +53,7 @@ public List<CarTypeDto> findAllCarType() {
return template.query(sql, carTypeDtoRowMapper());
}

public Optional<TrimInfoDto> findTrimInfoByCarId(int carId) {
public Optional<TrimDataDto> findTrimInfoByCarId(int carId) {
String sql = "select car_id, trim, car_default_price " +
"from Car " +
"where car_id = :carId";
Expand Down Expand Up @@ -91,8 +91,8 @@ private RowMapper<Integer> intMapper() {
return (rs, rowNum) -> rs.getInt("car_default_price");
}

private RowMapper<TrimInfoDto> trimInfoRowMapper() {
return BeanPropertyRowMapper.newInstance(TrimInfoDto.class);
private RowMapper<TrimDataDto> trimInfoRowMapper() {
return BeanPropertyRowMapper.newInstance(TrimDataDto.class);
}

}
7 changes: 3 additions & 4 deletions backend/src/main/java/autoever2/cartag/cars/CarService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package autoever2.cartag.cars;

import autoever2.cartag.cars.dto.*;
import autoever2.cartag.domain.color.InnerColorDto;
import autoever2.cartag.domain.color.OuterColorDto;
import autoever2.cartag.domain.color.ColorDto;
import autoever2.cartag.models.dto.ModelDefaultDto;
import autoever2.cartag.exception.EmptyDataException;
import autoever2.cartag.exception.ErrorCode;
Expand Down Expand Up @@ -44,8 +43,8 @@ public List<CarVo> getCarDtoByCarType(int carType) {
}

public CarDefaultDto getCarDefaultDtoByCarId(int carId) {
List<OuterColorDto> outerColorList = colorRepository.findOuterColorCarByCarId(carId);
List<InnerColorDto> innerColorList = colorRepository.findInnerColorCarByCarId(carId);
List<ColorDto> outerColorList = colorRepository.findOuterColorCarByCarId(carId);
List<ColorDto> innerColorList = colorRepository.findInnerColorCarByCarId(carId);
List<ModelDefaultDto> modelList = modelRepository.findDefaultModelListByCarId(carId);
if (outerColorList.isEmpty() || innerColorList.isEmpty() || modelList.isEmpty()) {
throw new EmptyDataException(ErrorCode.DATA_NOT_EXISTS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package autoever2.cartag.cars.dto;

import autoever2.cartag.domain.color.InnerColorDto;
import autoever2.cartag.domain.color.OuterColorDto;
import autoever2.cartag.domain.color.ColorDto;
import autoever2.cartag.models.dto.ModelDefaultDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand Down Expand Up @@ -61,7 +60,7 @@ public class CarDefaultDto {
@Schema(description = "기본 내장색상 이름")
private String colorInnerImageName;

public static CarDefaultDto toDefault(OuterColorDto outerColorDto, InnerColorDto innerColorDto, List<ModelDefaultDto> modelDefaultDto, String colorCarOuterImage) {
public static CarDefaultDto toDefault(ColorDto outerColorDto, ColorDto innerColorDto, List<ModelDefaultDto> modelDefaultDto, String colorCarOuterImage) {
return CarDefaultDto.builder()
.powerTrainId(modelDefaultDto.get(0).getModelId())
.powerTrainName(modelDefaultDto.get(0).getModelName())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package autoever2.cartag.cars.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TrimInfoDto {
public class TrimDataDto {

@Schema(description = "트림 ID", example = "1")
private int carId;
@Schema(description = "트림명", example = "Le Blanc")
private String trim;
@Schema(description = "차량 기본 가격")
private int carDefaultPrice;

@Builder
public TrimInfoDto(int carId, String trim, int carDefaultPrice) {
public TrimDataDto(int carId, String trim, int carDefaultPrice) {
this.carId = carId;
this.trim = trim;
this.carDefaultPrice = carDefaultPrice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package autoever2.cartag.controller;

import autoever2.cartag.domain.color.InnerColorDto;
import autoever2.cartag.domain.color.InnerColorPercentDto;
import autoever2.cartag.domain.color.OuterColorDto;
import autoever2.cartag.domain.color.OuterColorPercentDto;
import autoever2.cartag.service.ColorService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down

This file was deleted.

37 changes: 37 additions & 0 deletions backend/src/main/java/autoever2/cartag/domain/color/ColorDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package autoever2.cartag.domain.color;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Schema(description = "차량 내부 색상 반환 DTO")
public class ColorDto {

@Schema(description = "색상 ID")
private int colorId;
@Schema(description = "색상 이름", example = "문라이트 블루 펄")
private String colorName;
@Schema(description = "색상 이미지 주소")
private String colorImage;
@Schema(description = "색상타입명", example = "외장색명")
private String colorType;
@Schema(description = "색상 추가금액")
private Long colorPrice;
@Schema(description = "판매된 내부 색상 이미지")
private Long colorBoughtCount;
@Schema(description = "색상이 적용된 차량 이미지 주소")
private String colorCarImage;

@Builder
public ColorDto(int colorId, String colorName, String colorImage, String colorType, Long colorPrice, Long colorBoughtCount, String colorCarImage) {
this.colorId = colorId;
this.colorName = colorName;
this.colorImage = colorImage;
this.colorType = colorType;
this.colorPrice = colorPrice;
this.colorBoughtCount = colorBoughtCount;
this.colorCarImage = colorCarImage;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InnerColorPercentDto(int colorId, String colorName, String colorImage, Lo
this.colorCarImage = colorCarImage;
}

public static InnerColorPercentDto toPercent(InnerColorDto innerColorDto, int colorBoughtPercent) {
public static InnerColorPercentDto toPercent(ColorDto innerColorDto, int colorBoughtPercent) {
return InnerColorPercentDto.builder()
.colorId(innerColorDto.getColorId())
.colorName(innerColorDto.getColorName())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Schema(description = "차량 외부 색상 반환 DTO")
Expand Down Expand Up @@ -32,7 +30,7 @@ public OuterColorPercentDto(int colorId, String colorName, String colorImage, Lo
this.colorCarImage = colorCarImage;
}

public static OuterColorPercentDto toPercent(OuterColorDto outerColorDto, int colorBoughtPercent, String imageUrl) {
public static OuterColorPercentDto toPercent(ColorDto outerColorDto, int colorBoughtPercent, String imageUrl) {
return OuterColorPercentDto.builder()
.colorId(outerColorDto.getColorId())
.colorName(outerColorDto.getColorName())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package autoever2.cartag.domain.option;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SubOptionIdAndPriceDto {

private int optionId;
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading