if (list.isEmpty()) {
productSearch.setHistorysearch(productSearch.getMast());
productSearch.setHotsearch_count(productSearch.getHotsearch_count() + 1);
if(productSearch.getHotsearch_count()>=3){
productSearch.setHotsearch(productSearch.getMast());
}
list.add(productSearch);
} else {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getMast().equals(productSearch.getMast())) {
// productSearch.setHistorysearch(productSearch.getMast());
// productSearch.setHotsearch(productSearch.getMast());
list.get(i).setHotsearch_count(list.get(i).getHotsearch_count() + 1);
if( list.get(i).getHotsearch_count()>=3){
list.get(i).setHotsearch(list.get(i).getMast());
}
break;
} else {
while (i == list.size() - 1) {
productSearch.setHistorysearch(productSearch.getMast());
productSearch.setHotsearch_count(productSearch.getHotsearch_count());
if(productSearch.getHotsearch_count()>=3){
productSearch.setHotsearch(productSearch.getMast());
}
list.add(productSearch);
break;
}
}
}
}
ProductResult productResult = null;
try {
productResult = this.productSearch.search(productSearch.getMast(), page, rows);
System.out.println(productResult);
} catch (Exception e) {
e.printStackTrace();
}
//把结果传递给页面
model.addAttribute("query", mast);
model.addAttribute("totalPages", productResult.getTotalPages());
model.addAttribute("itemList", productResult.getProductSearchList());
model.addAttribute("page", page);
model.addAttribute("query", productResult);
model.addAttribute("search", list);
return "result";
}