分页数量不正确

This commit is contained in:
wangliwen 2022-12-14 11:32:34 +08:00
parent f7e739ea7d
commit 5dc4b1e482
5 changed files with 46 additions and 7 deletions

View File

@ -285,6 +285,6 @@ public class SysUserController {
index.put("auditTeamName", sysAuditTeamDTOList.stream().findFirst().isPresent() ? sysAuditTeamDTOList.stream().findFirst().get().getName() : ""); index.put("auditTeamName", sysAuditTeamDTOList.stream().findFirst().isPresent() ? sysAuditTeamDTOList.stream().findFirst().get().getName() : "");
return index; return index;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return new Result<PageData<Map>>().ok(new PageData<>(temp, sysUserService.getUserByRoleListCount(roleId))); return new Result<PageData<Map>>().ok(new PageData<>(temp, sysUserService.getUserByRoleListCount(roleId, filterAuditTeam)));
} }
} }

View File

@ -59,5 +59,5 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
List<Map> getUserByRoleList(@Param("roleIds") List<Long> roleIds, @Param("pageNum") int pageNum, @Param("pageSize") int pageSize, @Param("filter") boolean filter); List<Map> getUserByRoleList(@Param("roleIds") List<Long> roleIds, @Param("pageNum") int pageNum, @Param("pageSize") int pageSize, @Param("filter") boolean filter);
Long getUserByRoleListCount(@Param("roleIds") List<Long> roleIds); Long getUserByRoleListCount(@Param("roleIds") List<Long> roleIds, @Param("filter") boolean filter);
} }

View File

@ -74,5 +74,5 @@ public interface SysUserService extends BaseService<SysUserEntity> {
*/ */
List<Map> getUserByRoleList(List<Long> roleIds, int pageNum, int pageSize, boolean filter); List<Map> getUserByRoleList(List<Long> roleIds, int pageNum, int pageSize, boolean filter);
Long getUserByRoleListCount(List<Long> roleIds); Long getUserByRoleListCount(List<Long> roleIds, boolean filter);
} }

View File

@ -568,7 +568,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
} }
@Override @Override
public Long getUserByRoleListCount(List<Long> roleIds) { public Long getUserByRoleListCount(List<Long> roleIds, boolean filter) {
return baseDao.getUserByRoleListCount(roleIds); return baseDao.getUserByRoleListCount(roleIds, filter);
} }
} }

View File

@ -261,8 +261,32 @@
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </select>
<select id="getUserByRoleListCount" resultType="java.lang.Long"> <select id="getUserByRoleListCount" resultType="java.lang.Long">
<!-- SELECT-->
<!-- COUNT(DISTINCT sys_user.id )-->
<!-- FROM-->
<!-- sys_role_user-->
<!-- LEFT JOIN sys_user ON sys_user.id = sys_role_user.user_id-->
<!-- LEFT JOIN sys_dept ON sys_dept.id = sys_user.dept_id-->
<!-- WHERE-->
<!-- 1 = 1-->
<!-- AND sys_role_user.del_flag = 0-->
<!-- AND sys_user.id IS NOT NULL-->
<!-- <if test="null != roleIds">-->
<!-- AND sys_role_user.role_id IN-->
<!-- <foreach item="roleId" collection="roleIds" open="(" separator="," close=")">-->
<!-- #{roleId}-->
<!-- </foreach>-->
<!-- </if>-->
SELECT SELECT
COUNT(DISTINCT sys_user.id ) COUNT(temp.id)
FROM
(
SELECT DISTINCT
sys_user.id,
sys_user.username,
sys_user.real_name,
sys_dept.`name`
FROM FROM
sys_role_user sys_role_user
LEFT JOIN sys_user ON sys_user.id = sys_role_user.user_id LEFT JOIN sys_user ON sys_user.id = sys_role_user.user_id
@ -270,13 +294,28 @@
WHERE WHERE
1 = 1 1 = 1
AND sys_role_user.del_flag = 0 AND sys_role_user.del_flag = 0
AND sys_user.id IS NOT NULL
<if test="null != roleIds"> <if test="null != roleIds">
AND sys_role_user.role_id IN AND sys_role_user.role_id IN
<foreach item="roleId" collection="roleIds" open="(" separator="," close=")"> <foreach item="roleId" collection="roleIds" open="(" separator="," close=")">
#{roleId} #{roleId}
</foreach> </foreach>
</if> </if>
AND sys_user.id IS NOT NULL
) temp
WHERE
1 = 1
<if test="filter">
AND NOT EXISTS (
SELECT
1
FROM
sys_audit_team
WHERE
JSON_CONTAINS(
sys_audit_team.member,
JSON_OBJECT( "id", temp.id ))
)
</if>
</select> </select>