@Configuration public class MyBatisConfiguration { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor(){ //构建mp拦截器对象 MybatisPlusInterceptor plugs = new MybatisPlusInterceptor(); //添加一个拦截器 plugs.addInnerInterceptor(new PaginationInnerInterceptor()); return plugs; } }
#controller层
@RestController @RequestMapping("/tcinfo") public class TcinfosCtrl { @Resource private TcinfoStoreService tcinfoStoreService;/** *4 塔机信息分页查询 * @param page * @return */ @GetMapping(value ="/findTowerCrane") public IPagefind(@RequestParam(value ="page",required= false,defaultValue="1") Integer page){ IPage result = tcinfoStoreService.findTc(page); return result; } }
# service层 接口
public interface TcinfoStoreService { /** * 按照前端要去获取对应页上的塔吊信息数据 * @param page 页码编号 * @return */ IPagefindTc(Integer page); }
# service层 实现类
@Service public class TcinfoStoreServiceImpl implements TcinfoStoreService { @Resource private TCinfosMapper tCinfosMapper;@Override public IPagefindTc(Integer page) { IPage ip= new Page<>(1,page); IPage }result = tCinfosMapper.selectPage(ip, null); return result; }
#mapper层
@Mapper //使用mybatis-plus实现crud public interface TCinfosMapper extends BaseMapper{ }