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

[BUG FIX] #439: color 관련 버그 해결 #443

Merged
merged 1 commit into from
Aug 24, 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 @@ -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<QuoteSubOptionDto> optionList = new ArrayList<>();

innerColor.setColorType("내장 색상");
outerColor.setColorType("외장 색상");

if (modelInfos.size() != 3) {
throw new EmptyDataException(ErrorCode.DATA_NOT_EXISTS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> optionIdList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +58,7 @@ public Optional<String> findOuterColorImagesByColorId(int colorId) {

public Optional<ColorDto> 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 ");

Expand All @@ -68,13 +69,10 @@ public Optional<ColorDto> 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<ColorDto> outerColorCarMapper() {
Expand Down
Loading