上代码
现在要查一些数据,准备展示到前端表格列表中
需要当前页; 页大小; 数据分类type;数据存活状态;
Query对象可以精准查询
Example中的Criteria (标准)用来加一些模糊查询和条件查询
在ServiceUtil中,把bs “并入” criteria中, 相当于丰富了example对象
然后Mapper中的 selectByExample方法传入example ,就可以查到了!
public Page findBsIntoBound4ListByCondition(String search, int currentPage, int pageSize, byte type) {
BsIntoBoundQuery bs = new BsIntoBoundQuery();
bs.setCurrentPage(currentPage);
bs.setPageSize(pageSize);
bs.setInType(type);
bs.setStatus((byte) 0);
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String materialParam = StringUtil.getInfo(search, "materialParam");
String number = StringUtil.getInfo(search, "number");
Example example = new Example(BsIntoBound.class);
Example.Criteria criteria = example.createCriteria();
if (beginTime != null && endTime != null){
criteria.andBetween("inBillTime",beginTime,endTime);
}
if (null != materialParam){
criteria.andLike("inSerial","%" + materialParam + "%");
}
BsIntoBoundServiceUtil.initFindBsIntoBoundParam(criteria,bs);
List<BsIntoBound> bsIntoBounds = bsIntoBoundMapper.selectByExample(example);
Page page = new Page(currentPage,pageSize,bsIntoBounds);
page.setTotal(bsIntoBounds.size());
return page;
}