分页代码

    @Override
    public IPage queryStudentList(StudentQueryVI studentQueryVI) {
        if(StringUtil.isNull(studentQueryVI.getUserId())){
            return null;
        }
        Page<StudentVO> page = new Page();
        Integer current = studentQueryVI.getCurrent();
        Integer size = studentQueryVI.getSize();
        if(current == null || current <= 0){
            current = 1;
        }
        page.setCurrent(current);
        if(size != null){
            if(size <= 0 || size > 20){
                size = 5;
            }
        }else{
            size = 5;
        }
        page.setSize(size);
        List<StudentVO> studentVOList = studentMapper.selectStudentListBySelective(page, studentQueryVI);
        return page.setRecords(studentVOList);
    }
public interface StudentMapper extends BaseMapper<Student> {

    @Select({
            "select user_id, user_name, age, address " +
            "from student" +
            "where user_id = #{userQueryVI.userId} " +
            "order by create_time desc"
    })
    List<StudentVO> selectStudentListBySelective(Page<StudentVO> page, @Param("studentQueryVI") StudentQueryVI studentQueryVI);

}

解决:

检查是不是没有加分页插件

package com.company.base.common.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Properties;


@EnableTransactionManagement
@Configuration
@MapperScan({"com.company.pay.repository.mysql.mapper", "com.company.account.repository.mysql.mapper"})
public class MybatisPlusConfig {

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * 打印 sql
     */
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        //格式化sql语句
        Properties properties = new Properties();
        properties.setProperty("format", "true");
        performanceInterceptor.setProperties(properties);
        return performanceInterceptor;
    }
}

 

结束