网站空间太小,北京到安阳防疫政策,怎样免费建立个人网站,wordpress授权主题员工信息分页查询 前言1、配置公共分页组件2、创建接口并查看接收的参数3、使用分页构造器并添加查询条件和排序条件4、测试结果 前言 1、配置公共分页组件 package com.example.ruiji_demo.config;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;… 员工信息分页查询 前言1、配置公共分页组件2、创建接口并查看接收的参数3、使用分页构造器并添加查询条件和排序条件4、测试结果 前言 1、配置公共分页组件 package com.example.ruiji_demo.config;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** author jitwxs* date 2024年03月31日 11:40*//*** 配置Mp的分页插件*/
Configuration
public class MybatisPlusConfig {Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){MybatisPlusInterceptor mybatisPlusInterceptor new MybatisPlusInterceptor();mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mybatisPlusInterceptor;}
}
2、创建接口并查看接收的参数 GetMapping(/page)public RPage page(int page,int pageSize,String name){log.info(page{},pageSize{},name{},page,pageSize,name);return null;}3、使用分页构造器并添加查询条件和排序条件 public RPage page(int page,int pageSize,String name){log.info(page{},pageSize{},name{},page,pageSize,name);// 构造分页构造器Page pageInfo new Page(page,pageSize);
// 构造条件的构造器LambdaQueryWrapperEmployee queryWrapper new LambdaQueryWrapper();
// 添加过滤条件queryWrapper.like(StringUtils.isNotEmpty(name),Employee::getName,name);
// 添加排序条件queryWrapper.orderByDesc(Employee::getUpdateTime);// 执行查询employeeService.page(pageInfo,queryWrapper);return R.success(pageInfo);}4、测试结果