2021-09-13

总价

完成内容

1.搜索店铺以及其排序

页面:

2021-09-13

代码:


    @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

上一篇:el-table底部出现白框


下一篇:MyBatis-Plus,看这一篇就够了!