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