import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class DeduplicationUtils {
public static <T> List<T> deduplication(final List<T> list, Function<? super T,?> key){
return list.stream().filter(deduplication(key))
.collect(Collectors.toList());
}
private static <T> Predicate<T> deduplication(Function<? super T,?> key){
final Set<Object> set = ConcurrentHashMap.newKeySet();
return predicate -> set.add(key.apply(predicate));
}
}
public ModelAndView hGymFilterList(String ggoodsname, String mgender, List<String> check) {
log.info("hGymFilterList()");
mv = new ModelAndView();
Map<String, String> fMap = new HashMap<>();
fMap.put("ggoodsname", ggoodsname);
fMap.put("mgender", mgender);
String andQuery = "";
//List<String> check =
for(String i : check){
switch (i){
case "1":
andQuery += " AND gc_cloths = 1";
break;
case "2":
andQuery = " AND gc_cloths = 1";
break;
case "3":
andQuery += " AND gc_towel = 1";
break;
case "4":
andQuery += " AND gc_wifi = 1";
break;
case "5":
andQuery += " AND gc_parking = 1";
break;
case "6":
andQuery += " AND gc_inbody = 1";
break;
}
}
fMap.put("andQuery", andQuery);
List<FillterViewDto> aList = gDao.hGymFilteraList(fMap);
List<FillterViewDto> fList = DeduplicationUtils.deduplication(aList, FillterViewDto::getGname);
mv.addObject("fList", fList);
mv.setViewName("gymSetList");
return mv;
}
'실습기록' 카테고리의 다른 글
7월 8일 project - 데이터 확인 ajax (0) | 2023.07.11 |
---|---|
7월 7일 project - 스프링부트 SQL 로그 출력하기 log4j2 (0) | 2023.07.08 |
7월 5일 project - 데이터베이스 뷰 생성(My SQL) (0) | 2023.07.08 |
7월 4일 project - AJAX (0) | 2023.07.05 |
7월 3일 project - CSS 레이아웃 (0) | 2023.07.04 |