假分页操作

实体类:

@Data
@Component
public class Page<T> {

private Integer total;
private Integer prevent;
private List<T> list;

}



controller层:
@PostMapping("/sortFind")
public RespResult<Page<GoodsInfo>> selectSort(@RequestBody SortGoods sortGoods){

System.out.println(sortGoods.getGoodsType().equals(""));
/*
* PriceRange
* 0 不进行价格分类 >0 进行价格分类
* */
if(!sortGoods.getGoodsType().equals("") && sortGoods.getPriceRange()>0){
/*两者皆为true*/
List<GoodsInfo> goodsInfos = sortGoodsMapper.selectType(sortGoods.getGoodsType());
String text=GoodsPage.priceJudge(sortGoods.getPriceRange());
int min=Integer.parseInt(text.split("-")[0]);
int max=Integer.parseInt(text.split("-")[1]);
List<GoodsInfo> goodsInfos01 = sortGoodsMapper.selectPrice(min, max);
goodsInfos.retainAll(goodsInfos01);
return GoodsPage.sortPage(goodsInfos,sortGoods.getPageNum());

}else if(!sortGoods.getGoodsType().equals("") && sortGoods.getPriceRange()==0){
/*类型为true 价格为false*/
List<GoodsInfo> goodsInfos = sortGoodsMapper.selectType(sortGoods.getGoodsType());
System.out.println("类型为true 价格为false");
return GoodsPage.sortPage(goodsInfos,sortGoods.getPageNum());


}else if(sortGoods.getGoodsType().equals("") && sortGoods.getPriceRange()>0){
/*类型为false 价格为true*/
String text=GoodsPage.priceJudge(sortGoods.getPriceRange());
int min=Integer.parseInt(text.split("-")[0]);
int max=Integer.parseInt(text.split("-")[1]);
List<GoodsInfo> goodsInfos = sortGoodsMapper.selectPrice(min, max);
return GoodsPage.sortPage(goodsInfos,sortGoods.getPageNum());

}else{
return null;
}

}
posted @ 2021-10-14 22:02  吴大叔  阅读(20)  评论(0编辑  收藏  举报