mybatis-plus 一对多查询分页有问题,求解决
返回数据实际只有6条
IPage<Worker> findWorkerIPage(@Param("page") Page<Worker> page, @Param("workerDto")WorkerDto workerDto);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dianli.mapper.WorkerMapper">
<resultMap id="BaseResultMap" type="com.dianli.pojo.Worker">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="workSiteId" column="work_site_id" jdbcType="INTEGER"/>
<result property="customId" column="custom_id" jdbcType="VARCHAR"/>
<result property="recordId" column="record_id" jdbcType="VARCHAR"/>
<result property="personName" column="person_name" jdbcType="VARCHAR"/>
<result property="idCard" column="id_card" jdbcType="VARCHAR"/>
<result property="pic" column="pic" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<collection property="clockInList" ofType="ClockIn">
<id property="id" column="ci_id" jdbcType="INTEGER"/>
<result property="userId" column="ci_user_id" jdbcType="INTEGER"/>
<result property="workSiteId" column="ci_work_site_id" jdbcType="INTEGER"/>
<result property="workSiteName" column="ci_work_site_name" jdbcType="VARCHAR"/>
<result property="deviceId" column="ci_device_id" jdbcType="INTEGER"/>
<result property="deviceName" column="ci_device_name" jdbcType="VARCHAR"/>
<result property="workerId" column="ci_worker_id" jdbcType="INTEGER"/>
<result property="workerName" column="ci_worker_name" jdbcType="VARCHAR"/>
<result property="clockInTime" column="ci_clock_in_time" jdbcType="TIMESTAMP"/>
<result property="status" column="ci_status" jdbcType="VARCHAR"/>
<result property="remark" column="ci_remark" jdbcType="VARCHAR"/>
<result property="createTime" column="ci_create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="ci_update_time" jdbcType="TIMESTAMP"/>
</collection>
</resultMap>
<sql id="Base_Column_List">
id,user_id
,work_site_id,custom_id,user_id
record_id,person_name,id_card,
pic,create_time,update_time
</sql>
<sql id="findWorkerIPage">
w.id ,
w.user_id,
w.work_site_id,
w.custom_id,
w.record_id,
w.person_name,
w.id_card,
w.pic,
w.create_time,
w.update_time,
ci.id as ci_id,
ci.user_id as ci_user_id,
ci.work_site_id as ci_work_site_id,
ci.work_site_name as ci_work_site_name,
ci.device_id as ci_device_id,
ci.device_name as ci_device_name,
ci.worker_id as ci_worker_id,
ci.worker_name as ci_worker_name,
ci.clock_in_time as ci_clock_in_time,
ci.status as ci_status,
ci.remark as ci_remark,
ci.create_time as ci_create_time,
ci.update_time as ci_update_time
</sql>
<select id="findWorkerIPage" resultMap="BaseResultMap">
select <include refid="findWorkerIPage"/>
from t_worker w left join t_clock_in ci on w.id = ci.worker_id and DATEDIFF(ci.clock_in_time, NOW())= 0
<where>
<if test="workerDto.userId != null and workerDto.userId != ''">
and w.user_id = #{workerDto.userId}
</if>
<if test="workerDto.workSiteId != null">
and w.work_site_id = #{workerDto.workSiteId}
</if>
<if test="workerDto.name != null and workerDto.name != ''">
and w.person_name like #{workerDto.name}
</if>
<if test="workerDto.idCard != null and workerDto.idCard != ''">
and w.id_card like #{workerDto.idCard}
</if>
</where>
</select>
</mapper>
==> Preparing: select w.id , w.user_id, w.work_site_id, w.custom_id, w.record_id, w.person_name, w.id_card, w.pic, w.create_time, w.update_time, ci.id as ci_id, ci.user_id as ci_user_id, ci.work_site_id as ci_work_site_id, ci.work_site_name as ci_work_site_name, ci.device_id as ci_device_id, ci.device_name as ci_device_name, ci.worker_id as ci_worker_id, ci.worker_name as ci_worker_name, ci.clock_in_time as ci_clock_in_time, ci.status as ci_status, ci.remark as ci_remark, ci.create_time as ci_create_time, ci.update_time as ci_update_time from t_worker w left join t_clock_in ci on w.id = ci.worker_id and DATEDIFF(ci.clock_in_time, NOW())= 0 WHERE w.user_id = ? LIMIT ?,?
==> Parameters: 1(Integer), 0(Long), 10(Long)
<== Columns: id, user_id, work_site_id, custom_id, record_id, person_name, id_card, pic, create_time, update_time, ci_id, ci_user_id, ci_work_site_id, ci_work_site_name, ci_device_id, ci_device_name, ci_worker_id, ci_worker_name, ci_clock_in_time, ci_status, ci_remark, ci_create_time, ci_update_time
<== Row: 6, 1, 5, 360121198801211410, 11, 罗文华, 360121198801211410, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/cbaf971f-a290-4e7a-8f10-3d31b5de1781.jpg?Expires=2007514020&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=ggHX1%2FZAxCQuobKdia6gU6wNe0M%3D, 2023-08-16 09:05:40, 2023-08-16 17:33:32, 37, 1, 5, 投资大厦3~4F、19~24F装修工程, 4, 投资大厦, 6, 罗文华, 2023-08-17 09:18:02, 1, {"messageId":"0sj5b6akc0g0020q","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"11","PushAckType":"2","detail":""}}, 2023-08-17 09:18:02, null
<== Row: 10, 1, 8, 360122197309302734, 11, 熊小明, 360122197309302734, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/24ce7170-d95d-454b-9c14-06d884f8d937.jpg?Expires=2007594084&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=3517A6eVmHmsn6llL9qYjvGlURc%3D, 2023-08-16 16:17:10, 2023-08-17 09:01:27, 45, 1, 8, 宝康电器设备上产基地项目, 6, 宝康电气设备生产基地项目下班, 10, 熊小明, 2023-08-17 16:01:55, 1, {"messageId":"0sj87mf8m0g00xn6","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"11","PushAckType":"2","detail":""}}, 2023-08-17 16:01:55, null
<== Row: 10, 1, 8, 360122197309302734, 11, 熊小明, 360122197309302734, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/24ce7170-d95d-454b-9c14-06d884f8d937.jpg?Expires=2007594084&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=3517A6eVmHmsn6llL9qYjvGlURc%3D, 2023-08-16 16:17:10, 2023-08-17 09:01:27, 30, 1, 8, 宝康电器设备上产基地项目, 5, 宝康电气设备生产基地项目上班, 10, 熊小明, 2023-08-17 08:44:52, 1, {"messageId":"0sj53kg3c0g00xkc","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"11","PushAckType":"2","detail":""}}, 2023-08-17 08:44:52, null
<== Row: 11, 1, 8, 360121199001216939, 12, 戴水清, 360121199001216939, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/1963a15e-3afb-4d3e-8a49-c0bdda4ab935.jpg?Expires=2007594106&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=V1GwIzebOAXsAcXYbDiX2Op1Ap8%3D, 2023-08-16 16:18:14, 2023-08-17 09:01:48, 44, 1, 8, 宝康电器设备上产基地项目, 6, 宝康电气设备生产基地项目下班, 11, 戴水清, 2023-08-17 16:01:44, 1, {"messageId":"0sj87k5hr0g005ct","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"12","PushAckType":"2","detail":""}}, 2023-08-17 16:01:44, null
<== Row: 11, 1, 8, 360121199001216939, 12, 戴水清, 360121199001216939, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/1963a15e-3afb-4d3e-8a49-c0bdda4ab935.jpg?Expires=2007594106&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=V1GwIzebOAXsAcXYbDiX2Op1Ap8%3D, 2023-08-16 16:18:14, 2023-08-17 09:01:48, 29, 1, 8, 宝康电器设备上产基地项目, 5, 宝康电气设备生产基地项目上班, 11, 戴水清, 2023-08-17 08:43:54, 1, {"messageId":"0sj53can00g000wa","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"12","PushAckType":"2","detail":""}}, 2023-08-17 08:43:54, null
<== Row: 12, 1, 8, 342721197204303217, 13, 贺保安, 342721197204303217, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/3528ed4d-fc51-4a9b-b39f-649dcda783c9.jpg?Expires=2007594128&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=uHZppTOdQzikbFc4hmUoYb4gLtE%3D, 2023-08-16 16:18:47, 2023-08-17 09:02:12, 43, 1, 8, 宝康电器设备上产基地项目, 6, 宝康电气设备生产基地项目下班, 12, 贺保安, 2023-08-17 16:01:03, 1, {"messageId":"0sj87e73r0g00y6r","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"13","PushAckType":"2","detail":""}}, 2023-08-17 16:01:03, null
<== Row: 12, 1, 8, 342721197204303217, 13, 贺保安, 342721197204303217, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/3528ed4d-fc51-4a9b-b39f-649dcda783c9.jpg?Expires=2007594128&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=uHZppTOdQzikbFc4hmUoYb4gLtE%3D, 2023-08-16 16:18:47, 2023-08-17 09:02:12, 31, 1, 8, 宝康电器设备上产基地项目, 5, 宝康电气设备生产基地项目上班, 12, 贺保安, 2023-08-17 08:45:51, 1, {"messageId":"0sj53tkum0g00316","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"13","PushAckType":"2","detail":""}}, 2023-08-17 08:45:51, null
<== Row: 13, 1, 8, 360121198310196930, 14, 龚青, 360121198310196930, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/55a0a57c-679a-450c-9c3e-f4a02dcad4ad.jpg?Expires=2007594147&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=cL5fd%2BTVhTGNwZR01H2NeQPl008%3D, 2023-08-16 16:20:17, 2023-08-17 09:02:34, 42, 1, 8, 宝康电器设备上产基地项目, 6, 宝康电气设备生产基地项目下班, 13, 龚青, 2023-08-17 15:59:16, 1, {"messageId":"0sj8712eg0g001mn","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"14","PushAckType":"2","detail":""}}, 2023-08-17 15:59:16, null
<== Row: 13, 1, 8, 360121198310196930, 14, 龚青, 360121198310196930, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/55a0a57c-679a-450c-9c3e-f4a02dcad4ad.jpg?Expires=2007594147&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=cL5fd%2BTVhTGNwZR01H2NeQPl008%3D, 2023-08-16 16:20:17, 2023-08-17 09:02:34, 32, 1, 8, 宝康电器设备上产基地项目, 5, 宝康电气设备生产基地项目上班, 13, 龚青, 2023-08-17 08:46:13, 1, {"messageId":"0sj53wc700g00e8y","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"14","PushAckType":"2","detail":""}}, 2023-08-17 08:46:13, null
<== Row: 14, 1, 8, 360121196901176916, 15, 姜爱文, 360121196901176916, http://shouhuan.oss-cn-shenzhen.aliyuncs.com/file/00143af3-4acc-40b7-afad-3cfef864be9c.jpg?Expires=2007594206&OSSAccessKeyId=LTAI5tFaGDnpAXfsFZvhUneF&Signature=b7YF36jCAXgLG%2FnFNhSPeeJc3VI%3D, 2023-08-16 16:20:49, 2023-08-17 09:03:28, 41, 1, 8, 宝康电器设备上产基地项目, 6, 宝康电气设备生产基地项目下班, 14, 姜爱文, 2023-08-17 15:59:06, 1, {"messageId":"0sj86yuu40g00v6a","operator":"PushAck","info":{"result":"ok","SnapOrRecordID":"15","PushAckType":"2","detail":""}}, 2023-08-17 15:59:06, null
<== Total: 10
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@23c5b01b]
【相关推荐】
<!-- mybatis-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
//DbType 数据库类型
PaginationInnerInterceptor page = new PaginationInnerInterceptor(DbType.MYSQL);
//单次查询最大的数量 如果我查10条,返回还是5条。
page.setMaxLimit(5L);
//溢出总页数后是否做处理(默认不做,true表示做处理,回到首页) false 继续请求
page.setOverflow(false);
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//设置数据库类型为mysql
interceptor.addInnerInterceptor(page);
return interceptor;
}
属性:
常用的数据库类型DbType.mysql等,详细请见官方文档。