Skip to content

Commit

Permalink
[refactor] : 옷장 전체 조회 많이 입은 순,적게 입은 순 미설정 옷장 맨 뒤로 정렬 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
choidongkuen committed Aug 24, 2023
1 parent cf4cbb2 commit 5fc0d85
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/com/umc/refit/web/service/ClotheService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,20 @@ public List<GetClotheListResponseDto> showClotheMain(Integer category, Integer s
return new ArrayList<>();
}

List<Clothe> sortedClothes = sortClothes(clothes);


return sortClothes(sortedClothes).stream()
return sortClothes(clothes).stream()
.map(clothe -> clothe.from(this.calculateRemainedDay(clothe)))
.collect(Collectors.toList());


} else if (sort.equals("most-worn")) {
return this.closetRepository.findAllByCategoryAndSeasonAndMemberOrderByCountDesc(category, season, member)
.stream()
List<Clothe> clothes = this.closetRepository.findAllByCategoryAndSeasonAndMemberOrderByCountDesc(category, season, member);

return checkSorting(clothes).stream()
.map(clothe -> clothe.from(this.calculateRemainedDay(clothe)))
.collect(Collectors.toList());
} else {
return this.closetRepository.findAllByCategoryAndSeasonAndMemberOrderByCountAsc(category, season, member)
.stream()
List<Clothe> clothes = this.closetRepository.findAllByCategoryAndSeasonAndMemberOrderByCountAsc(category, season, member);
return checkSorting(clothes).stream()
.map(clothe -> clothe.from(this.calculateRemainedDay(clothe)))
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -165,6 +163,7 @@ private List<Clothe> sortClothes(List<Clothe> clothes) {
return checkSorting(clothes);
}


private List<Clothe> checkSorting(List<Clothe> clothes) {

ArrayList<Clothe> resultClothes = new ArrayList<>();
Expand Down

0 comments on commit 5fc0d85

Please sign in to comment.