<!--pagehelper:通用Mapper分页-->
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/23b2c93159e7a5ba6b9419e5b5153ae9.png)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DictionaryResult<T> {
private Long total;
private List<T> rows;
}
查询功能:Controller
@GetMapping(value = "/find")
public ResponseEntity<DictionaryResult<Dictionary>> queryStandard(Integer page, Integer rows){
try {
DictionaryResult<Dictionary> result = this.dictionaryService.queryStandardByPage(page, rows);
if(result != null){
return new ResponseEntity<>(result, HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
查询功能:Service
@Override
public DictionaryResult<Dictionary> queryStandardByPage(Integer page, Integer rows) {
PageHelper.startPage(page, rows);
List<Dictionary> userDomains = dictionaryDao.findAll();
PageInfo<Dictionary> pageInfo = new PageInfo<>(userDomains);
DictionaryResult<Dictionary> result = new DictionaryResult(pageInfo.getTotal(), userDomains);
return result;
}