1.接口文档
2.修改SkuInfoController的list方法
/**
* 列表(sku检索)
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
// PageUtils page = skuInfoService.queryPage(params);
PageUtils page = skuInfoService.queryPageByCondition(params);
return R.ok().put("page", page);
}
3.SkuInfoService中添加queryPageByCondition方法
PageUtils queryPageByCondition(Map<String, Object> params);
4.SkuInfoServiceImpl中添加queryPageByCondition方法实现
@Override
public PageUtils queryPageByCondition(Map<String, Object> params){
QueryWrapper<SkuInfoEntity> queryWrapper = new QueryWrapper<>();
/**
* key:
* catelogId: 0
* brandId: 0
* min: 0
* max: 0
*/
String key = (String) params.get("key");
if(!StringUtils.isEmpty(key)){
queryWrapper.and((wrapper)->{
wrapper.eq("sku_id",key).or().like("sku_name",key);
});
}
String catelogId = (String) params.get("catelogId");
if(!StringUtils.isEmpty(catelogId)&&!"0".equalsIgnoreCase(catelogId)){
queryWrapper.eq("catalog_id",catelogId);
}
String brandId = (String) params.get("brandId");
if(!StringUtils.isEmpty(brandId)&&!"0".equalsIgnoreCase(catelogId)){
queryWrapper.eq("brand_id",brandId);
}
String min = (String) params.get("min");
if(!StringUtils.isEmpty(min)){
queryWrapper.ge("price",min);
}
String max = (String) params.get("max");
if(!StringUtils.isEmpty(max) ){
try{
BigDecimal bigDecimal = new BigDecimal(max);
if(bigDecimal.compareTo(new BigDecimal("0"))==1){
queryWrapper.le("price",max);
}
}catch (Exception e){
}
}
IPage<SkuInfoEntity> page = this.page(
new Query<SkuInfoEntity>().getPage(params),
queryWrapper
);
return new PageUtils(page);
}