2024-12-02 11:13:48 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
<!DOCTYPE mapper
|
2024-12-04 14:49:38 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2024-12-02 11:13:48 +08:00
|
|
|
<mapper namespace="com.bonus.system.basic.dao.SysUserMapper">
|
|
|
|
|
<insert id="insertUser" keyColumn="user_id" useGeneratedKeys="true" keyProperty="userId">
|
|
|
|
|
insert into sys_user(
|
|
|
|
|
<if test="userName != null and userName != ''">user_name,</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
|
|
|
<if test="idNumber != null and idNumber != ''">id_number,</if>
|
2024-12-04 14:49:38 +08:00
|
|
|
<if test="password != null and password != ''">password,</if>
|
2024-12-02 11:13:48 +08:00
|
|
|
<if test="createBy != null and createBy != ''">create_user_id,</if>
|
|
|
|
|
<if test="isCadre != null and isCadre != ''">is_cadre,</if>
|
|
|
|
|
create_time
|
|
|
|
|
)values(
|
|
|
|
|
<if test="userName != null and userName != ''">#{userName},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
|
|
|
<if test="idNumber != null and idNumber != ''">#{idNumber},</if>
|
|
|
|
|
<if test="password != null and password != ''">#{password},</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
<if test="isCadre != null and isCadre != ''">#{isCadre},</if>
|
|
|
|
|
sysdate()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="insertUserPost">
|
|
|
|
|
insert into sys_user_post(user_id, post_id) values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.userId},#{item.postId})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertUserRole">
|
|
|
|
|
insert into sys_user_role(user_id, role_id) values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.userId},#{item.roleId})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertUserOrg">
|
|
|
|
|
insert into sys_user_org(user_id, org_id) values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.userId},#{item.orgId})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
<delete id="deleteUserOrgByUserId">
|
|
|
|
|
delete from sys_user_org where user_id = #{userId}
|
|
|
|
|
</delete>
|
|
|
|
|
<delete id="deleteUserPostByUserId">
|
|
|
|
|
delete from sys_user_post where user_id = #{userId}
|
|
|
|
|
</delete>
|
|
|
|
|
<delete id="deleteUserRoleByUserId">
|
|
|
|
|
delete from sys_user_role where user_id = #{userId}
|
|
|
|
|
</delete>
|
|
|
|
|
<update id="deleteUserById">
|
|
|
|
|
update sys_user
|
|
|
|
|
set is_active = 0
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateUser">
|
|
|
|
|
update sys_user
|
|
|
|
|
<set>
|
|
|
|
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
|
|
|
<if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
|
|
|
|
|
<if test="password != null and password != ''">password = #{password},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_user_id = #{updateBy},</if>
|
|
|
|
|
<if test="isCadre != null and isCadre != ''">is_cadre = #{isCadre},</if>
|
2024-12-04 14:49:38 +08:00
|
|
|
update_time = sysdate()
|
2024-12-02 11:13:48 +08:00
|
|
|
</set>
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2024-12-04 16:30:27 +08:00
|
|
|
<update id="updateIsFace">
|
|
|
|
|
update sys_user set is_face = #{isFace} where user_id = #{userId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2024-12-09 19:36:44 +08:00
|
|
|
<!-- 改两次sys_user是为了第一次录入人脸时多次录入需要审核但又未更新时间的问题-->
|
2024-12-04 16:30:27 +08:00
|
|
|
<update id="checkPersonAssignment">
|
2024-12-06 23:01:30 +08:00
|
|
|
UPDATE sys_user_face SET
|
|
|
|
|
`is_check` = #{isCheck},
|
|
|
|
|
`examine_opinion` = #{examineOpinion}
|
|
|
|
|
WHERE `user_id` = #{userId};
|
|
|
|
|
<if test='isCheck == 1'>
|
2024-12-09 19:36:44 +08:00
|
|
|
update sys_user set is_face = 1 where user_id = #{userId};
|
|
|
|
|
update sys_user set is_face = 0 where user_id = #{userId};
|
2024-12-06 23:01:30 +08:00
|
|
|
</if>
|
2024-12-04 16:30:27 +08:00
|
|
|
</update>
|
2024-12-11 17:28:51 +08:00
|
|
|
<update id="updateAttOrgByUserId">
|
|
|
|
|
update att_group_person_relation set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId};
|
|
|
|
|
</update>
|
2024-12-04 16:30:27 +08:00
|
|
|
|
2024-12-02 11:13:48 +08:00
|
|
|
<select id="selectUserByUserName" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
select * from sys_user su
|
|
|
|
|
where su.is_active = 1 and su.phone = #{userName}
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-12-04 14:49:38 +08:00
|
|
|
<select id="selectUserById" resultType="com.bonus.system.api.domain.SysUser">
|
2024-12-02 11:13:48 +08:00
|
|
|
select * from sys_user su
|
|
|
|
|
where su.user_id = #{userId}
|
|
|
|
|
</select>
|
2024-12-04 14:49:38 +08:00
|
|
|
<select id="getOrgByUserId" resultType="com.bonus.system.api.domain.MapVo">
|
2024-12-02 11:13:48 +08:00
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
`org_name` AS `name`
|
|
|
|
|
FROM
|
|
|
|
|
sys_organization
|
|
|
|
|
WHERE
|
2024-12-04 14:49:38 +08:00
|
|
|
id IN (
|
2024-12-02 11:13:48 +08:00
|
|
|
SELECT
|
|
|
|
|
org_id
|
|
|
|
|
FROM
|
|
|
|
|
sys_user_org
|
|
|
|
|
WHERE
|
|
|
|
|
user_id = #{userId})
|
|
|
|
|
</select>
|
2024-12-04 14:49:38 +08:00
|
|
|
<select id="selectUserList" resultType="com.bonus.system.api.domain.SysUser">
|
2024-12-02 11:13:48 +08:00
|
|
|
SELECT
|
|
|
|
|
su.user_id AS userId,
|
|
|
|
|
su.user_name as userName,
|
|
|
|
|
su.id_number as idNumber,
|
|
|
|
|
GROUP_CONCAT(DISTINCT so.org_name ORDER BY so.id SEPARATOR ', ') as orgName,
|
|
|
|
|
GROUP_CONCAT(DISTINCT sdd.dict_label ORDER BY sdd.dict_code SEPARATOR ', ') as postName,
|
|
|
|
|
GROUP_CONCAT(DISTINCT sr.role_name ORDER BY sr.role_id SEPARATOR ', ') as roleName,
|
2024-12-04 16:30:27 +08:00
|
|
|
su.phone,su.is_cadre as isCadre,
|
|
|
|
|
su.is_face as isFace,
|
|
|
|
|
case when suf.new_face is not null then suf.new_face else suf.applied_face end new_face,
|
|
|
|
|
suf.is_check,
|
|
|
|
|
suf.examine_opinion as examineOpinion,
|
|
|
|
|
suf.collection_time
|
2024-12-02 11:13:48 +08:00
|
|
|
FROM
|
|
|
|
|
sys_user su
|
|
|
|
|
LEFT JOIN sys_user_post sup on sup.user_id=su.user_id and sup.is_active=1
|
|
|
|
|
LEFT JOIN sys_dict_data sdd on sdd.dict_code=sup.post_id and sdd.`status`=0
|
|
|
|
|
LEFT JOIN sys_user_role sur on sur.user_id=su.user_id and sur.is_active=1
|
|
|
|
|
LEFT JOIN sys_role sr on sr.role_id=sur.role_id and sr.del_flag=0
|
|
|
|
|
LEFT JOIN sys_user_org suo on suo.user_id=su.user_id and suo.is_active=1
|
|
|
|
|
LEFT JOIN sys_organization so on so.id=suo.org_id and so.is_active=1
|
2024-12-04 16:30:27 +08:00
|
|
|
LEFT JOIN sys_user_face suf ON suf.user_id = su.user_id
|
2024-12-02 11:13:48 +08:00
|
|
|
WHERE
|
|
|
|
|
su.is_active =1
|
|
|
|
|
<if test="userName != null and userName != ''">
|
|
|
|
|
AND su.user_name like concat('%', #{userName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="orgId != null and orgId != ''">
|
|
|
|
|
AND suo.org_id = #{orgId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="phone != null and phone != ''">
|
|
|
|
|
AND su.phone = #{phone}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="userId != null">
|
|
|
|
|
AND su.user_id = #{userId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY su.user_id
|
|
|
|
|
order by su.update_time desc
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getSelectRole" resultType="com.bonus.system.api.domain.SysRole">
|
|
|
|
|
SELECT role_id,
|
|
|
|
|
role_name
|
|
|
|
|
FROM sys_role
|
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
and status = '0'
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getSelectPost" resultType="com.bonus.system.api.domain.SysDictData">
|
|
|
|
|
SELECT dict_code,
|
|
|
|
|
dict_label
|
|
|
|
|
FROM sys_dict_data
|
|
|
|
|
WHERE dict_type = 'post_list'
|
|
|
|
|
and status = '0'
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getRoleIdsByUserId">
|
|
|
|
|
SELECT
|
|
|
|
|
role_id as roleId
|
|
|
|
|
FROM
|
|
|
|
|
sys_user_role
|
|
|
|
|
WHERE
|
|
|
|
|
user_id = #{userId}
|
|
|
|
|
and is_active=1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getOrgIdsByUserId">
|
|
|
|
|
SELECT
|
|
|
|
|
org_id as orgId
|
|
|
|
|
FROM
|
|
|
|
|
sys_user_org
|
|
|
|
|
WHERE
|
|
|
|
|
user_id = #{userId}
|
|
|
|
|
and is_active=1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getPostIdsByUserId">
|
|
|
|
|
SELECT
|
|
|
|
|
sdd.dict_value as postId
|
|
|
|
|
FROM
|
|
|
|
|
sys_dict_data sdd
|
|
|
|
|
LEFT JOIN sys_user_post sup on sup.post_id=sdd.dict_code and sup.is_active=1
|
|
|
|
|
WHERE
|
|
|
|
|
sup.user_id=#{userId}
|
|
|
|
|
and sdd.`status`=0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="checkPhoneUnique" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
select user_id as userId, phone
|
|
|
|
|
from sys_user
|
|
|
|
|
where phone = #{phone}
|
|
|
|
|
and is_active = '1' limit 1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectPostIdById" resultType="java.lang.String">
|
|
|
|
|
select dict_code as postId from sys_dict_data where dict_value = #{postId} and dict_type = 'post_list' and status = '0' limit 1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getOrgList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
org_name as `name`
|
|
|
|
|
FROM
|
|
|
|
|
`sys_organization`
|
|
|
|
|
WHERE
|
|
|
|
|
is_active=1
|
|
|
|
|
and org_name is not null
|
|
|
|
|
GROUP BY org_name
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getRoleList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
|
|
|
|
|
SELECT
|
|
|
|
|
role_id as id,
|
|
|
|
|
role_name as `name`
|
|
|
|
|
FROM
|
|
|
|
|
sys_role
|
|
|
|
|
WHERE
|
|
|
|
|
del_flag = '0'
|
|
|
|
|
and status = '0'
|
|
|
|
|
and role_name is not null
|
|
|
|
|
GROUP BY role_name
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getPostList" resultType="com.bonus.system.holiday.entity.HolidayKeyBean">
|
|
|
|
|
SELECT
|
|
|
|
|
dict_code as id,
|
|
|
|
|
dict_label as `name`
|
|
|
|
|
FROM
|
|
|
|
|
sys_dict_data
|
|
|
|
|
WHERE
|
|
|
|
|
dict_type = 'post_list'
|
|
|
|
|
and status = '0'
|
|
|
|
|
and dict_label is not null
|
|
|
|
|
GROUP BY dict_label
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getSelectUser" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
SELECT
|
|
|
|
|
user_id AS userIds,
|
|
|
|
|
user_name AS userName,
|
|
|
|
|
id_number AS idNumber,
|
|
|
|
|
phone
|
|
|
|
|
FROM
|
|
|
|
|
sys_user
|
|
|
|
|
WHERE
|
|
|
|
|
is_active = 1
|
|
|
|
|
AND user_name IS NOT NULL
|
|
|
|
|
</select>
|
|
|
|
|
<select id="checkIdNumberUnique" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
select user_id as userId, id_number as idNumber
|
|
|
|
|
from sys_user
|
|
|
|
|
where id_number = #{idNumber}
|
|
|
|
|
and is_active = '1' limit 1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectUserByUserNames" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
SELECT suo.org_id AS orgId
|
|
|
|
|
FROM sys_user su
|
|
|
|
|
LEFT JOIN sys_user_org suo ON suo.user_id = su.user_id
|
|
|
|
|
AND suo.is_active = 1
|
|
|
|
|
WHERE su.is_active = 1
|
|
|
|
|
AND su.user_name = #{userName}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getSelectUserCurrent" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
SELECT
|
|
|
|
|
user_id AS userIds,
|
|
|
|
|
user_name AS userName,
|
|
|
|
|
id_number AS idNumber,
|
|
|
|
|
phone
|
|
|
|
|
FROM
|
|
|
|
|
sys_user
|
|
|
|
|
WHERE
|
|
|
|
|
is_active = 1
|
2024-12-16 15:08:46 +08:00
|
|
|
AND user_name IS NOT NULL
|
2024-12-02 11:13:48 +08:00
|
|
|
</select>
|
2024-12-04 14:49:38 +08:00
|
|
|
<select id="checkUserNameUnique" resultType="com.bonus.system.api.domain.SysUser">
|
|
|
|
|
select user_id as userId, id_number as idNumber
|
|
|
|
|
from sys_user
|
|
|
|
|
where user_name = #{userName}
|
|
|
|
|
and is_active = '1' limit 1
|
2024-12-02 18:04:19 +08:00
|
|
|
</select>
|
2024-12-04 17:42:41 +08:00
|
|
|
|
|
|
|
|
<select id="getAttGroupByUserId" resultType="com.bonus.system.api.domain.MapVo">
|
|
|
|
|
SELECT
|
|
|
|
|
ag.id,
|
|
|
|
|
ag.group_name AS `name`
|
|
|
|
|
FROM
|
|
|
|
|
att_group_person_relation agpr
|
|
|
|
|
LEFT JOIN att_group ag ON agpr.group_id = ag.id
|
|
|
|
|
AND ag.is_active = '1'
|
|
|
|
|
WHERE
|
|
|
|
|
agpr.user_id = #{userId} and agpr.is_active = '1' and ag.id is not null
|
|
|
|
|
LIMIT 1
|
|
|
|
|
</select>
|
2024-12-11 17:28:51 +08:00
|
|
|
<select id="getUserAttGroupByUserId" resultType="java.lang.Long">
|
|
|
|
|
select org_id from att_group_person_relation where user_id=#{userId} and is_active = 1 limit 1
|
|
|
|
|
|
|
|
|
|
</select>
|
2024-12-13 21:04:06 +08:00
|
|
|
<select id="getRoleListById" resultType="java.lang.String">
|
|
|
|
|
select role_id from sys_user_role
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
</select>
|
2024-12-02 11:13:48 +08:00
|
|
|
</mapper>
|