本文主要是介绍2021-09-13,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
总价
- 完成内容
- 1.搜索店铺以及其排序
-
- 2.后台首页完善(未完成)
- 相关页面:
完成内容
1.搜索店铺以及其排序
页面:
代码:
@GetMapping("/searchShop")
public Result<?> searchShop(@RequestParam String searchItem,@RequestParam Integer currentPage,@RequestParam String orderItem){
QueryWrapper<Shop> queryWrapper=new QueryWrapper<>();
Page<Shop> objectPage=new Page<>(currentPage,10);
if(orderItem.equals("")){
queryWrapper.and(wrapper -> wrapper.like("shop_name",searchItem).or().like("shop_description",searchItem));
}else if(orderItem.equals("salesCount")){
queryWrapper.and(wrapper -> wrapper.like("shop_name",searchItem).or().like("shop_description",searchItem)).orderByDesc("sale_count");
}else if(orderItem.equals("shopCount")){
queryWrapper.and(wrapper -> wrapper.like("shop_name",searchItem).or().like("shop_description",searchItem)).orderByDesc("shop_count");
}
Page<Shop> page=shopService.page(objectPage,queryWrapper);
List<Shop> list=page.getRecords();
List<Map<String,Object>> list1=new ArrayList<>();
for(Shop shop:list){
Map<String,Object> map=new HashMap<>();
map.put("shop",shop);
QueryWrapper<Goods> goodsQueryWrapper=new QueryWrapper<>();
goodsQueryWrapper.eq("shop_id",shop.getShopId());
List<Goods> goodsList=goodsService.list(goodsQueryWrapper);
map.put("goodsList",goodsList);
list1.add(map);
}
Map<String,Object> map=new HashMap<>();
map.put("page",page);
map.put("data",list1);
return Result.success(map);
}
2.后台首页完善(未完成)
相关页面:
这篇关于2021-09-13的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!