加入配置
package com.ly.remind.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
* 新增分页拦截器,并设置数据库类型为mysql
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
Page<TestEntity> rpage =
baseMapper.selectPage(
new Page<>(pageBean.getPageSize(), pageBean.getPageNum()),
new QueryWrapper<TestEntity>()
.eq("siteid", siteid)
.and(
wrapper ->
wrapper
.or()
.lt("createtime", updatetime)
.or()
.lt("deletetime", updatetime)
.or()
.lt("operatetime", updatetime)
.or()
.lt("updatetime", updatetime)));
and or 拼完后的结果是这样的:
new QueryWrapper<TestEntity>()
.eq("siteid", siteid)
.and(
wrapper ->
wrapper
.or()
.lt("createtime", updatetime)
.or()
.lt("deletetime", updatetime)
.or()
.lt("operatetime", updatetime)
.or()
.lt("updatetime", updatetime)))
–>
SELECT
*
FROM
t
WHERE
useflag = 1
AND (
siteid =?
AND (
createtime < ?
OR deletetime < ?
OR operatetime < ?
OR updatetime < ?))