开始
service
和分页查询有关的
复制一段之前写的
/**
* 获取分页的订单流向
* @param userId
* @param page
* @param pageSize
* @return
*/
public PagedGridResult getMyOrdersTrend(String userId
,Integer page
,Integer pageSize);
实现类
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public PagedGridResult getMyOrdersTrend(String userId, Integer page, Integer pageSize) {
Map<String,Object> map=new HashMap<>();
map.put("userId",userId);
PageHelper.startPage(page,pageSize);
List<OrderStatus> list = ordersMapperCustom.getMyOrderTrend(map);
return setterPagedGrid(list,page);
}
确保当前MyOrdersServiceImpl继承了BaseService要不然无法调用setterPagedGrid方法。
public class MyOrderServiceImpl extends BaseService implements MyOrderService {}
controller
前端
循环展示数据
根据状态查询
这里发现前端一个小bug修改后。
后端
MyOrdersController
@ApiOperation(value = "查询订单动向",notes = "查询订单动向",httpMethod ="POST" )
@PostMapping("/trend")
public IMOOCJSONResult trend(
@ApiParam(name = "userId",value = "用户id",required = true)
@RequestParam String userId,
@ApiParam(name = "page",value = "查询下一页的第几页",required = false)
@RequestParam Integer page,
@ApiParam(name = "pageSize",value = "分页的每一页显示的条数",required = false)
@RequestParam Integer pageSize){
if(StringUtils.isBlank(userId)){
return IMOOCJSONResult.errorMsg(null);
}
if(page==null){
page=1;
}
if(pageSize==null){
pageSize=COMMON_PAGE_SIZE;
}
PagedGridResult grid = myOrderService.getMyOrdersTrend(userId,
page,
pageSize);
return IMOOCJSONResult.ok(grid);
}
测试
maven install