gs_sub_evaluate/src/main/resources/mappers/evaluate/PersonMapper.xml

165 lines
6.4 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="com.bonus.gs.sub.evaluate.evaluate.dao.PersonDao">
<insert id="addPersonInfo" keyProperty="userId" useGeneratedKeys="true">
INSERT INTO sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">username,</if>
<if test="password != null and password != ''">password,</if>
<if test="name != null and name != ''">nickname,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="sex != null">sex,</if>
<if test="deptId != null and deptId != ''">org_id,</if>
status
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="sex != null">#{sex},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
'1'
</trim>
</insert>
<insert id="addPersonRole">
insert into sys_role_user(userId, roleId) values
<foreach collection="list" item="item" separator=",">
(#{item.userId}, #{item.roleId})
</foreach>
</insert>
<insert id="addPersonRoleById">
insert into sys_role_user(userId, roleId) values (#{id}, #{roleId})
</insert>
<update id="updatePerson">
UPDATE sys_user
<set>
<if test="name != null and name != ''">
username = #{name},
nickname = #{name},
</if>
<if test="idCard != null and idCard != ''">
id_card = #{idCard},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="deptId != null and deptId != ''">
org_id = #{deptId}
</if>
</set>
WHERE id = #{id}
</update>
<update id="updateOldUser">
<foreach collection="list" item="item" separator=";">
update gs_exam.pm_user
set evaluate_pass_word = #{item.evaluatePassWord}
where TELPHONE = #{item.phone}
</foreach>
</update>
<delete id="deletePersonRole">
delete from sys_role_user where userId = #{id}
</delete>
<delete id="deletePersonById">
delete from sys_user where id = #{id}
</delete>
<select id="getDeptTree" resultType="com.bonus.gs.sub.evaluate.evaluate.beans.NodeBean">
select ID as id,
PARENT_ID as parentId,
NAME as title,
NAME as name
from gs_exam.pm_dept
</select>
<select id="getUserList" resultType="com.bonus.gs.sub.evaluate.evaluate.beans.PersonBean">
select
pu.ID as id,
pu.NAME as name,
pu.DEPT_ID as deptId,
pd.NAME as deptName,
GROUP_CONCAT(pnr.NAME) as roleName,
pu.TELPHONE as phone,
pu.LOGIN_NAME as idCard,
if(pu.SEX = '1', '男','女') as sex,
pu.CREATE_TIME as createTime
from gs_exam.pm_user pu
left join gs_exam.pm_dept pd on pu.DEPT_ID = pd.ID and pd.IS_ACTIVE = '1'
left join gs_exam.pm_new_role_user pnru on pu.ID = pnru.user_id and pnru.del_flag = '0'
left join gs_exam.pm_new_role pnr on pnru.ROLE_ID = pnr.id and pnr.del_flag = '0'
where pu.IS_ACTIVE = '1' and pu.if_active = '1' and evaluate_pass_word is null
<if test="bean.type == 'team'">
and pu.LOGIN_NAME not in (select id_card from sys_user where status = '1' and id_card is not null)
</if>
<if test="bean.type == 'evaluate'">
and pu.LOGIN_NAME not in (select id_card from pm_org_info where status = '1' and id_card is not null)
</if>
and pu.id != 1
<if test="bean.id != null and bean.id != ''">
and pu.dept_id in
<foreach collection="arr" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="bean.keyWord != null and bean.keyWord != ''">
and (
pu.NAME like concat('%',#{bean.keyWord},'%') or
pu.TELPHONE like concat('%',#{bean.keyWord},'%') or
pu.LOGIN_NAME like concat('%',#{bean.keyWord},'%')
)
</if>
GROUP BY pu.ID
</select>
<select id="getRoleSelect" resultType="com.bonus.gs.sub.evaluate.manager.model.Role">
select id as id,
NAME as name
from sys_role
</select>
<select id="getDeptSelect" resultType="com.bonus.gs.sub.evaluate.manager.model.Role">
select ID as id,
NAME as name
from pm_org_info
where status = '1'
and level = '2'
</select>
<select id="getPersonList" resultType="com.bonus.gs.sub.evaluate.evaluate.beans.PersonBean">
select
su.id,
su.username as name,
poi.name as deptName,
su.phone,
if(su.sex = '1', '男','女') as sex,
su.id_card as idCard,
sr.name as roleName,
su.org_id as deptId,
sr.id as roleId
from sys_user su
left join pm_org_info poi on su.org_id = poi.id
left join sys_role_user sru on su.id = sru.userId
left join sys_role sr on sru.roleId = sr.id
where su.status = '1'
<if test="keyWord != null and keyWord != ''">
and (
su.username like concat('%',#{keyWord},'%') or
su.phone like concat('%',#{keyWord},'%') or
poi.name like concat('%',#{keyWord},'%') or
su.id_card like concat('%',#{keyWord},'%')
)
</if>
order by su.username
</select>
<select id="getPerSonByPhone" resultType="java.lang.Integer">
select count(1)
from sys_user
where phone = #{phone}
</select>
</mapper>