Skip to content

Commit

Permalink
[BUG FIX] #411: builder 패턴 내부에서 sort안되는 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tank3a committed Aug 22, 2023
1 parent be29c34 commit e333a98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand All @@ -27,12 +28,11 @@ public HistorySearchDto(int carId, int powerTrainId, int bodyTypeId, int operati
this.optionIds = new ArrayList<>();

this.optionIds.addAll(optionIds);
optionIds.sort(null);
}

public void addAllOption(List<Integer> optionId) {
optionIds.addAll(optionId);
optionIds.sort(null);
Collections.sort(optionIds);
}

public String getOptionIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -26,6 +27,7 @@ public class QuoteService {

public HistoryShortDto findMyQuote(QuoteDataDto quoteDataDto) {
List<Integer> optionIds = quoteDataDto.getOptionIdList();
Collections.sort(optionIds);

HistorySearchDto historyData = HistorySearchDto.builder()
.carId(quoteDataDto.getCarId())
Expand All @@ -40,6 +42,7 @@ public HistoryShortDto findMyQuote(QuoteDataDto quoteDataDto) {
public List<HistoryShortDto> findTopHistory(QuoteDataDto quoteDataDto) {

List<Integer> optionIds = quoteDataDto.getOptionIdList();
Collections.sort(optionIds);

if(optionIds.isEmpty()) {
throw new InvalidDataException(ErrorCode.INVALID_PARAMETER);
Expand Down

0 comments on commit e333a98

Please sign in to comment.