Mybatis-plus的配置文件
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
2.Controller的编写
@RequestMapping("/selectListAll")
@ResponseBody
public String selectListAll(String page,String limit) {
Map<String, Object> result =
new HashMap<String, Object>(2);
IPage<CollegeEntity> collegeEntityPage =
new Page<>(Long.parseLong(page),Long.parseLong(limit));
IPage<CollegeEntity> collegeList = collegeService.page(collegeEntityPage);
int count = collegeService.count();
result.put("data", collegeList.getRecords());
result.put("count", count);
result.put("code", 0);
result.put("msg", "暂无数据");
return JSON.toJSONString(result);
}