
- 更新了 AchievementService 接口,移除了相关方法 - 重构了 AchievementServiceImpl 中的业绩相关方法,使用 UserLiveTreeService 替代原有的 AdminUserApi- 更新了 CustomerServiceImpl 中的客户相关方法,使用 UserLiveTreeService 替代原有的 AdminUserApi- 调整了 UserLiveTreeController 的接口设计,改为使用 UserLiveTreeService - 重构了 UserLiveTreeService 接口,增加了新的方法 - 实现了 UserLiveTreeServiceImpl 中的新的方法,包括获取用户列表和分页查询 - 更新了数据库查询,使用 user_id 替代 id 在 CRM 用户结构树表中进行查询
241 lines
9.6 KiB
XML
241 lines
9.6 KiB
XML
<?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.deleted = 0
|
||
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>
|
||
<if test="vo.roleCode != null and vo.roleCode != ''">
|
||
left join system_user_role as d on a.id = d.user_id AND d.deleted = 0
|
||
left join system_role as e on d.role_id = e.id AND e.deleted = 0
|
||
</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 >= #{vo.createTime[0]}
|
||
</if>
|
||
<if test="vo.createTime[1] != null">
|
||
and a.create_time <= #{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>
|
||
<if test="vo.roleCode != null and vo.roleCode != ''">
|
||
and e.code = #{vo.roleCode}
|
||
</if>
|
||
</where>
|
||
</select>
|
||
<select id="selectListByCondition"
|
||
resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
||
select
|
||
DISTINCT a.*
|
||
from system_users AS a
|
||
<if test="roleCodeList != null and roleCodeList.size() > 0">
|
||
LEFT JOIN system_user_role AS b ON a.id = b.user_id
|
||
AND b.deleted = 0
|
||
LEFT JOIN system_role AS c ON b.role_id = c.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="roleCodeList != null and roleCodeList.size() > 0">
|
||
and c.code in
|
||
<foreach collection="roleCodeList" item="roleCode" open="(" close=")" separator=",">
|
||
#{roleCode}
|
||
</foreach>
|
||
</if>
|
||
<if test="filterCrmUserFlag != null and filterCrmUserFlag == 1">
|
||
and not exists (SELECT user_id from crm_user_live_tree where a.id = user_id)
|
||
</if>
|
||
</where>
|
||
</select>
|
||
|
||
<select id="selectUserPageByRole" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
||
select
|
||
DISTINCT a.*
|
||
from system_users AS a
|
||
<if test="roleCodeList != null and roleCodeList.size() > 0">
|
||
LEFT JOIN system_user_role AS b ON a.id = b.user_id
|
||
AND b.deleted = 0
|
||
LEFT JOIN system_role AS c ON b.role_id = c.id
|
||
AND c.deleted = 0
|
||
</if>
|
||
<where>
|
||
a.deleted = 0
|
||
and a.user_type = 1
|
||
and a.status = 0
|
||
<if test="pageReqVO.nickname != null and pageReqVO.nickname != ''">
|
||
and a.nickname LIKE concat('%', #{pageReqVO.nickname}, '%')
|
||
</if>
|
||
<if test="roleCodeList != null and roleCodeList.size() > 0">
|
||
and c.code in
|
||
<foreach collection="roleCodeList" item="roleCode" open="(" close=")" separator=",">
|
||
#{roleCode}
|
||
</foreach>
|
||
</if>
|
||
</where>
|
||
</select>
|
||
</mapper>
|