From 5aaa06c99c58c23732635237c04e4f3c2197d7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=8C=E1=85=A9=E1=86=BC?= =?UTF-8?q?=E1=84=8B=E1=85=AF=E1=86=AB=20Jongwon?= Date: Thu, 24 Aug 2023 14:38:56 +0900 Subject: [PATCH] =?UTF-8?q?[BUG=20FIX]=20#439:=20color=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EB=B2=84=EA=B7=B8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/autoever2/cartag/quotes/QuoteService.java | 4 ++++ .../cartag/quotes/dtos/QuoteRequestDto.java | 2 +- .../cartag/repository/ColorRepository.java | 14 ++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/autoever2/cartag/quotes/QuoteService.java b/backend/src/main/java/autoever2/cartag/quotes/QuoteService.java index 0a94e2b..e0cd2bb 100644 --- a/backend/src/main/java/autoever2/cartag/quotes/QuoteService.java +++ b/backend/src/main/java/autoever2/cartag/quotes/QuoteService.java @@ -108,6 +108,10 @@ public QuoteInfoDto getAllCarInfoByQuoteDataDto(QuoteRequestDto quoteRequestDto) ColorDto innerColor = colorRepository.findColorDataByColorId(innerColorId, false).orElseThrow(() -> new EmptyDataException(ErrorCode.DATA_NOT_EXISTS)); ColorDto outerColor = colorRepository.findColorDataByColorId(outerColorId, true).orElseThrow(() -> new EmptyDataException(ErrorCode.DATA_NOT_EXISTS)); List optionList = new ArrayList<>(); + + innerColor.setColorType("내장 색상"); + outerColor.setColorType("외장 색상"); + if (modelInfos.size() != 3) { throw new EmptyDataException(ErrorCode.DATA_NOT_EXISTS); } diff --git a/backend/src/main/java/autoever2/cartag/quotes/dtos/QuoteRequestDto.java b/backend/src/main/java/autoever2/cartag/quotes/dtos/QuoteRequestDto.java index 2d8a1a6..c96026e 100644 --- a/backend/src/main/java/autoever2/cartag/quotes/dtos/QuoteRequestDto.java +++ b/backend/src/main/java/autoever2/cartag/quotes/dtos/QuoteRequestDto.java @@ -11,8 +11,8 @@ public class QuoteRequestDto { private int carId; private int powerTrainId; - private int bodyTypeId; private int operationId; + private int bodyTypeId; private int outerColorId; private int innerColorId; private List optionIdList = new ArrayList<>(); diff --git a/backend/src/main/java/autoever2/cartag/repository/ColorRepository.java b/backend/src/main/java/autoever2/cartag/repository/ColorRepository.java index c53caa2..7e0be2f 100644 --- a/backend/src/main/java/autoever2/cartag/repository/ColorRepository.java +++ b/backend/src/main/java/autoever2/cartag/repository/ColorRepository.java @@ -3,6 +3,7 @@ import autoever2.cartag.domain.color.ColorDto; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.dao.support.DataAccessUtils; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -57,7 +58,7 @@ public Optional findOuterColorImagesByColorId(int colorId) { public Optional findColorDataByColorId(int colorId, boolean isOuterColor) { StringBuilder query = new StringBuilder(); - query.append("select c.color_id, color_name, color_image, color_car_image, color_price " + + query.append("select c.color_id, color_name, color_image, color_car_image, color_price, cm.color_bought_count " + "from ColorCarMapper as cm inner join Color as c " + "on cm.color_id = c.color_id where c.color_id = :colorId "); @@ -68,13 +69,10 @@ public Optional findColorDataByColorId(int colorId, boolean isOuterCol query.append("and c.is_outer_color = 0"); } - try { - SqlParameterSource param = new MapSqlParameterSource() - .addValue("colorId", colorId); - return Optional.of(template.queryForObject(query.toString(), param, outerColorCarMapper())); - } catch (DataAccessException e) { - return Optional.empty(); - } + SqlParameterSource param = new MapSqlParameterSource() + .addValue("colorId", colorId); + + return Optional.ofNullable(DataAccessUtils.singleResult(template.query(query.toString(), param, outerColorCarMapper()))); } private RowMapper outerColorCarMapper() {