@Override
public Page<OcrFilePO> findOcrList(int pageNo, int pageSize, Long userId) {
//Sort.Direction是个枚举有ASC(升序)和DESC(降序)
Sort.Direction sort = Sort.Direction.DESC;
//PageRequest继承于AbstractPageRequest并且实现了Pageable
//获取PageRequest对象 index:页码 从0开始 size每页容量 sort排序方式 "id"->properties 以谁为准排序
Pageable pageable = PageRequest.of(pageNo - 1, pageSize, sort, "top", "createdAt");
//要匹配的实例对象
OcrFilePO ocrFilePO = new OcrFilePO();
ocrFilePO.setUserId(userId);
ocrFilePO.setCreatedAt(null);
ocrFilePO.setUpdatedAt(null);
ocrFilePO.setNoTraceMode(0);
//它是通过对象的属性来进行匹配的,
//所以此时如果对象中含有其他有值的属性,那么就会变成查询条件进行查询,
//如果你不想让他们变成你的查询条件,那么你就需要将值赋空,或者调用 .withIgnorePaths("createdAt")来进行忽略此条件!
//定义匹配规则 匹配"vendorId"这个属性 exact 精准匹配
ExampleMatcher exampleMatcher = ExampleMatcher.matching().withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact());
// .withIgnorePaths("createdAt").withIgnorePaths("updatedAt");
Example<OcrFilePO> example = Example.of(ocrFilePO, exampleMatcher);
// Page<OcrFilePO> page = dao.findAll(example, pageable);
// //获取总页数
// page.getTotalPages();
// //获取总元素个数
// page.getTotalElements();
// //获取该分页的列表
// page.getContent();
return dao.findAll(example, pageable);
}