第二种返回类型是PageResult,用于分页返回。
public class PageResult<T> implements Serializable {
@Schema(description = "平台-返回结构类型 表明是千里马架构返回体")
private String flag;
@Schema(description = "平台-返回码")
private int retCode;//返回码
@Schema(description = "平台-返回消息")
private String msg;//返回消息
@Schema(description = "平台-返回服务的时间戳")
private String timestamp;
@Schema(description = "平台-请求者")
private String consumer;//请求者 标识发出请求的系统
@Schema(description = "平台-返回提供服务的名字")
private String server; //返回该消息的服务
@Schema(description = "平台-返回该消息的服务路径")
private String path; //返回该消息的服务路径
@Schema(description = "平台-请求流水")
private String serialNo;//请求流水
@Schema(description = "平台-总记录数")
private long total;
@Schema(description = "平台-总页码")
private long totalPage;
@Schema(description = "平台-当前页码")
private long curPage;
@Schema(description = "平台-每页显示条数")
private long pageSize;
@Schema(description = "平台-数据")
private List<T> rows;
分页返回在controller层类似这样:
@Operation(summary ="查询简历(分页) 用于管理端 查所有数据")
@PostMapping("/zRecruit/resume/getListForPage")
public PageResult<ResumeBasicDTO> getListForPage(@RequestBody ResumeQueryDTO requestDTO) {
PageResult<ResumeBasicDTO> page = new PageResult<ResumeBasicDTO>(BaseController.getURI(),requestDTO);
try {
//封装返回数据到前端
Page<ResumeBO> result = this.resumeService.getListForPage(requestDTO);
page.from(result);
//bo 转 dto
if (result.getContent() != null && result.getContent().size() > 0) {
List<ResumeBasicDTO> list=ResumeBO.toDtoList(result.getContent());
this.resumeService.transResumeCode(list,new Hashtable());
page.setRows(list);
}
}
catch (Exception e){
CommonsUtil.recordLog(e);
page.setException(e);
}
return page;
}