zn-cloud/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml
aikai 079bdaa6a4 refactor(消息模板): 重构微信小程序和公众号消息发送逻辑- 重新组织了消息模板代码,分离小程序和公众号消息发送功能
- 优化了消息发送API接口,增加了单独的公众号消息发送方法
- 调整了消息发送实现类,支持小程序和公众号分别发送消息
- 更新了消息发送调用逻辑,根据不同社交类型选择对应的消息发送方法
- 重构查询用户下属部门逻辑,根据用户所负责的部门递归获取所有子部门
- 重构获取用户列表信息方法,增加通过用户状态查询,根据菜单查询
2024-11-29 19:39:00 +08:00

205 lines
8.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<update id="emptyOpenId">
update system_users
set open_id = null
where open_id = #{openId}
</update>
<select id="selectByDeptIds" resultType="cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO">
select a.*, b.name deptName FROM system_users a, system_dept b
where
a.dept_id = b.id
and a.status = 0
and a.user_type = 1
and a.dept_id in
<foreach collection="list" item="deptIds" open="(" close=")" separator=",">
#{deptIds}
</foreach>
</select>
<select id="selectUserByBoss" resultType="java.lang.Long">
SELECT DISTINCT
a.id
FROM
system_users AS a,
system_dept AS b
WHERE
( LOCATE( '7', a.post_ids ) OR LOCATE( '8', a.post_ids ) )
OR ((
b.`level` = 2
OR b.`level` = 3
)
AND b.leader_user_id = a.id)
</select>
<select id="selectByDeptIdsFilterGroupUser"
resultType="cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO">
select a.*, b.name deptName FROM system_users a, system_dept b
where
a.dept_id = b.id
and a.status = 0
and a.user_type = 1
and a.dept_id in
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
and not exists(select id from kq_attendance_group_user where user_id = a.id and attendance_group_id != #{groupId} and deleted = 0)
</select>
<select id="getAllUserListByGroupIds"
resultType="cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSimpleRespVO">
select a.id,
a.nickname,
a.avatar,
a.dept_id,
c.name deptName
from system_users as a
left join kq_attendance_group_user b on a.id = b.user_id
left join system_dept as c on a.dept_id = c.id
<where>
a.deleted = 0 and b.deleted = 0
<if test="dto.groupIds != null and dto.groupIds.size() > 0">
and b.attendance_group_id in
<foreach collection="dto.groupIds" item="groupId" open="(" close=")" separator=",">
#{groupId}
</foreach>
</if>
<if test="dto.deptId != null">
and a.dept_id = #{dto.deptId}
</if>
<if test="dto.name != null and dto.name != ''">
and a.nickname like concat('%', #{dto.name}, '%')
</if>
<if test="dto.status != null">
and a.status = #{dto.status}
</if>
</where>
</select>
<select id="getAllList" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
select
a.*
from system_users as a
<if test="dto.groupIds != null and dto.groupIds.size() > 0">
left join kq_attendance_group_user b on a.id = b.user_id
</if>
<where>
a.deleted = 0
<if test="dto.status != null">
and a.status = #{dto.status}
</if>
<if test="dto.userType != null">
and a.user_type = #{dto.userType}
</if>
<if test="dto.userIds != null and dto.userIds.size() > 0">
and a.id in
<foreach collection="dto.userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() > 0">
and a.dept_id in
<foreach collection="dto.deptIds" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
</if>
<if test="dto.groupIds != null and dto.groupIds.size() > 0">
and b.deleted = 0
and b.attendance_group_id in
<foreach collection="dto.groupIds" item="groupId" open="(" close=")" separator=",">
#{groupId}
</foreach>
</if>
</where>
</select>
<select id="getUserBringDeptPage"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
select a.*,b.name as deptName
from system_users as a
left join system_dept as b on a.dept_id = b.id
<if test="vo.groupIds != null and vo.groupIds.size() > 0">
left join kq_attendance_group_user c on a.id = c.user_id
</if>
<where>
a.deleted = 0
and a.user_type = 1
and a.status = 0
<if test="vo.username != null and vo.username != ''">
and a.username like concat('%', #{vo.username}, '%')
</if>
<if test="vo.nickName != null and vo.nickName != ''">
and a.nickname like concat('%', #{vo.nickName}, '%')
</if>
<if test="vo.mobile != null and vo.mobile != ''">
and a.mobile like concat('%', #{vo.mobile}, '%')
</if>
<if test="vo.status != null">
and a.status = #{vo.status}
</if>
<if test="vo.createTime != null and vo.createTime.length > 0">
<if test="vo.createTime[0] != null">
and a.create_time &gt;= #{vo.createTime[0]}
</if>
<if test="vo.createTime[1] != null">
and a.create_time &lt;= #{vo.createTime[1]}
</if>
</if>
<if test="vo.deptIds != null and vo.deptIds.size() > 0">
and a.dept_id in
<foreach collection="vo.deptIds" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
</if>
<if test="vo.groupIds != null and vo.groupIds.size() > 0">
and c.deleted = 0
and c.attendance_group_id in
<foreach collection="vo.groupIds" item="groupId" open="(" close=")" separator=",">
#{groupId}
</foreach>
</if>
</where>
</select>
<select id="selectListByCondition"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
select
a.*
<if test="menuList != null and menuList.size() > 0">
LEFT JOIN system_user_role AS b ON a.id = b.user_id
AND b.deleted = 0
LEFT JOIN system_role_menu AS c ON b.role_id = c.role_id
AND c.deleted = 0
LEFT JOIN system_menu AS d ON c.menu_id = d.id
AND c.deleted = 0
</if>
<where>
a.deleted = 0
<if test="userType != null">
and a.user_type = #{userType}
</if>
<if test="deptIds != null and deptIds.size()>0">
and a.dept_id in
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
</if>
<if test="status != null">
and a.status = #{status}
</if>
<if test="menuList != null and menuList.size() > 0">
and d.permission in
<foreach collection="menuList" item="menu" open="(" close=")" separator=",">
#{menu}
</foreach>
</if>
</where>
</select>
</mapper>