7-29 修改用户查询的Mapper层查询SQL语句,去除岗位和角色的重复显示
This commit is contained in:
parent
7dbadc7378
commit
35fdcf14f6
|
@ -197,6 +197,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
if(CollUtil.isNotEmpty(req.getPostIds())){
|
if(CollUtil.isNotEmpty(req.getPostIds())){
|
||||||
userPostService.bindUserPost(userId, req.getPostIds());
|
userPostService.bindUserPost(userId, req.getPostIds());
|
||||||
}
|
}
|
||||||
|
if(CollUtil.isNotEmpty(req.getRoleIds())){
|
||||||
|
userRoleService.bindUserRole(new UserRoleReq().setUserId(userId).setRoleIds(req.getRoleIds()));
|
||||||
|
}
|
||||||
this.updateById(entity);
|
this.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,38 +8,55 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
|
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
|
||||||
SELECT u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time,
|
SELECT
|
||||||
GROUP_CONCAT(r.role_name) AS role_name,GROUP_CONCAT(p.post_name) AS post_name
|
u.user_id,
|
||||||
|
u.account,
|
||||||
|
u.status,
|
||||||
|
u.name,
|
||||||
|
u.user_code,
|
||||||
|
u.user_type,
|
||||||
|
u.user_status,
|
||||||
|
d.dept_name,
|
||||||
|
u.mobile,
|
||||||
|
u.create_time,
|
||||||
|
(
|
||||||
|
SELECT GROUP_CONCAT(DISTINCT r.role_name)
|
||||||
|
FROM user_role ur
|
||||||
|
JOIN role r ON ur.role_id = r.role_id
|
||||||
|
WHERE ur.user_id = u.user_id
|
||||||
|
) AS role_name,
|
||||||
|
(
|
||||||
|
SELECT GROUP_CONCAT(DISTINCT p.post_name)
|
||||||
|
FROM user_post up
|
||||||
|
JOIN post p ON up.post_id = p.post_id
|
||||||
|
WHERE up.user_id = u.user_id
|
||||||
|
) AS post_name
|
||||||
FROM user u
|
FROM user u
|
||||||
LEFT JOIN dept d ON u.dept_id = d.dept_id
|
LEFT JOIN dept d ON u.dept_id = d.dept_id
|
||||||
LEFT JOIN user_role ur ON u.user_id = ur.user_id
|
|
||||||
LEFT JOIN role r ON ur.role_id = r.role_id
|
|
||||||
LEFT JOIN user_post up ON up.user_id = u.user_id
|
|
||||||
LEFT JOIN post p ON p.post_id = up.post_id
|
|
||||||
<where>
|
<where>
|
||||||
<if test="userCode != null and userCode != ''">
|
<if test="userCode != null and userCode != ''">
|
||||||
AND u.user_code LIKE concat ('%', #{userCode}, '%')
|
AND u.user_code LIKE CONCAT('%', #{userCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="account != null and account != ''">
|
<if test="account != null and account != ''">
|
||||||
AND u.account LIKE concat ('%', #{account}, '%')
|
AND u.account LIKE CONCAT('%', #{account}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="name != null and name != ''">
|
<if test="name != null and name != ''">
|
||||||
AND u.name LIKE concat ('%', #{name}, '%')
|
AND u.name LIKE CONCAT('%', #{name}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="mobile != null and mobile != ''">
|
<if test="mobile != null and mobile != ''">
|
||||||
AND u.mobile LIKE concat ('%', #{mobile}, '%')
|
AND u.mobile LIKE CONCAT('%', #{mobile}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="deptId != null and deptId != ''">
|
<if test="deptId != null and deptId != ''">
|
||||||
AND d.dept_id = #{deptId}
|
AND d.dept_id = #{deptId}
|
||||||
</if>
|
</if>
|
||||||
<if test="userStatus != null and userStatus!=''">
|
<if test="userStatus != null and userStatus != ''">
|
||||||
AND u.user_status = #{userStatus}
|
AND u.user_status = #{userStatus}
|
||||||
</if>
|
</if>
|
||||||
<if test="userType != null and userType!=''">
|
<if test="userType != null and userType != ''">
|
||||||
AND u.user_Type = #{userType}
|
AND u.user_Type = #{userType}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time
|
<!-- 移除了 GROUP BY -->
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue