From 5fc0d859be066dd0dfdc6076ccda7d7b552e2d70 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Thu, 24 Aug 2023 10:19:57 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20:=20=EC=98=B7=EC=9E=A5=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20`=EB=A7=8E=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=85=EC=9D=80=20=EC=88=9C`,`=EC=A0=81=EA=B2=8C=20=EC=9E=85?= =?UTF-8?q?=EC=9D=80=20=EC=88=9C`=20=EB=AF=B8=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=98=B7=EC=9E=A5=20=EB=A7=A8=20=EB=92=A4=EB=A1=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/umc/refit/web/service/ClotheService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/umc/refit/web/service/ClotheService.java b/src/main/java/com/umc/refit/web/service/ClotheService.java index 2125e17..c18e4af 100644 --- a/src/main/java/com/umc/refit/web/service/ClotheService.java +++ b/src/main/java/com/umc/refit/web/service/ClotheService.java @@ -74,22 +74,20 @@ public List showClotheMain(Integer category, Integer s return new ArrayList<>(); } - List 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 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 clothes = this.closetRepository.findAllByCategoryAndSeasonAndMemberOrderByCountAsc(category, season, member); + return checkSorting(clothes).stream() .map(clothe -> clothe.from(this.calculateRemainedDay(clothe))) .collect(Collectors.toList()); } @@ -165,6 +163,7 @@ private List sortClothes(List clothes) { return checkSorting(clothes); } + private List checkSorting(List clothes) { ArrayList resultClothes = new ArrayList<>();