<?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.dg.core.db.gen.mapper.SysUserMapper">
|
<resultMap type="com.dg.core.db.gen.entity.SysUser" id="SysUserResult">
|
<id property="id" column="id" />
|
<id property="userId" column="user_id" />
|
<result property="loginName" column="login_name" />
|
<result property="userName" column="user_name" />
|
<result property="userType" column="user_type" />
|
<result property="phonenumber" column="phonenumber" />
|
<result property="sex" column="sex" />
|
<result property="avatar" column="avatar" />
|
<result property="password" column="password" />
|
<result property="salt" column="salt" />
|
<result property="status" column="status" />
|
<result property="delFlag" column="del_flag" />
|
<result property="loginIp" column="login_ip" />
|
<result property="loginDate" column="login_date" />
|
<result property="pwdUpdateDate" column="pwd_update_date" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="roleIds" column="role_ids" />
|
<result property="dataPermission" column="data_permission" />
|
<result property="departmentId" column="department_id" />
|
<result property="stairId" column="stair_id" />
|
<result property="secondLevelId" column="second_level_id" />
|
<result property="departmentName" column="department_name" />
|
<result property="departmentArea" column="department_area" />
|
<result property="leisureState" column="leisure_state" />
|
<result property="masterIds" column="master_ids" />
|
<result property="masterNames" column="master_names" />
|
<result property="transactionIds" column="transaction_ids" />
|
<result property="transactionNames" column="transaction_names" />
|
<result property="openid" column="openid" />
|
<result property="transactionNum" column="transaction_num" />
|
<result property="isDivisionHead" column="is_division_head" />
|
<result property="mattersIds" column="matters_ids" />
|
<result property="departmentIds" column="department_ids" />
|
<result property="moreDepartmentIds" column="more_department_ids" />
|
<result property="departmentIdStr" column="department_id_str" />
|
</resultMap>
|
|
<sql id="selectSysUserVo">
|
SELECT
|
id,
|
user_id,
|
login_name,
|
user_name,
|
user_type,
|
phonenumber,
|
sex,
|
avatar,
|
password,
|
salt,
|
status,
|
del_flag,
|
login_ip,
|
login_date,
|
pwd_update_date,
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
remark,
|
role_ids,
|
data_permission,
|
department_id,
|
stair_id,
|
second_level_id,
|
matters_ids,
|
department_ids,
|
more_department_ids,
|
department_id_str,
|
(SELECT GROUP_CONCAT(matter_name) FROM automessage_transaction_event WHERE id in (SELECT
|
substring_index(substring_index(matters_ids,',', b.help_topic_id + 1), ',', -1) result
|
FROM
|
mysql.help_topic b
|
where
|
b.help_topic_id < (LENGTH(matters_ids) - LENGTH(REPLACE(matters_ids, ',', '')) + 1))) as mattersNames,
|
|
concat(
|
IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select city from automessage_organization_chart
|
where automessage_organization_chart.id=department_id)),''),
|
IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select district from automessage_organization_chart
|
where automessage_organization_chart.id=department_id)),''),
|
IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select village from automessage_organization_chart
|
where automessage_organization_chart.id=department_id)),'')
|
) AS department_area,
|
leisure_state,
|
master_ids,
|
(SELECT GROUP_CONCAT(classify_name) FROM automessage_classify_administration WHERE id in (SELECT
|
substring_index(substring_index(master_ids,',', b.help_topic_id + 1), ',', -1) result
|
FROM
|
mysql.help_topic b
|
where
|
b.help_topic_id < (LENGTH(master_ids) - LENGTH(REPLACE(master_ids, ',', '')) + 1))) as master_names,
|
is_division_head,
|
transaction_ids,
|
transaction_names,
|
openid,
|
(select user_name from automessage_sys_user as asu where asu.user_id=automessage_sys_user.create_by) as createName,
|
transaction_num,
|
(select count(id) from automessage_guide_repair_order where automessage_guide_repair_order.state='3'
|
and automessage_guide_repair_order.guide_user_id=user_id and
|
automessage_guide_repair_order.guide_department_id=automessage_sys_user.department_id) as transactionEndNum,
|
(select role_name from automessage_role_management where automessage_role_management.id=role_ids) as roleName,
|
(select permission from automessage_role_management where automessage_role_management.id=role_ids) as permission,
|
(SELECT GROUP_CONCAT(organization_name) FROM automessage_organization_chart WHERE id in (SELECT
|
substring_index(substring_index(more_department_ids,',', b.help_topic_id + 1), ',', -1) result
|
FROM
|
mysql.help_topic b
|
where
|
b.help_topic_id < (LENGTH(more_department_ids) - LENGTH(REPLACE(more_department_ids, ',', '')) + 1)))
|
as department_name
|
FROM
|
automessage_sys_user
|
</sql>
|
|
<select id="selectNum" parameterType="string" resultType="integer">
|
select count(user_id) from automessage_sys_user
|
<where>
|
<if test="userType != null and userType != ''">
|
AND user_type=#{userType}
|
</if>
|
<if test="ids != null">
|
and department_id IN
|
<foreach collection="ids" item="param" open="(" close=")" separator=",">
|
#{param}
|
</foreach>
|
</if>
|
<if test="isDivisionHead != null and isDivisionHead != ''">
|
AND is_division_head=#{isDivisionHead}
|
</if>
|
<if test="userName != null and userName != ''">
|
AND (user_name like concat('%', #{userName}, '%') or
|
(department_id in (SELECT id FROM automessage_organization_chart
|
WHERE organization_name like concat('%', #{userName}, '%'))) or
|
phonenumber like concat('%', #{userName}, '%'))
|
</if>
|
|
</where>
|
</select>
|
|
<select id="queryList" resultMap="SysUserResult">
|
<include refid="selectSysUserVo"/>
|
<where>
|
user_type=#{userType}
|
<if test="keyWord!=null and keyWord!=''">
|
and (transaction_names like concat('%',#{keyWord}, '%') or user_name like concat('%',#{keyWord}, '%'))
|
</if>
|
</where>
|
ORDER BY department_id
|
</select>
|
|
<select id="selectConfigList" parameterType="string" resultMap="SysUserResult">
|
<include refid="selectSysUserVo"/>
|
<where>
|
<if test="userType != null and userType != ''">
|
AND user_type=#{userType}
|
</if>
|
<if test="ids != null">
|
AND
|
<foreach collection="ids" item="param" open="(" close=")" separator="or">
|
locate(#{param},more_department_ids)>0
|
</foreach>
|
</if>
|
|
<if test="isDivisionHead != null and isDivisionHead != ''">
|
and is_division_head=#{isDivisionHead}
|
</if>
|
<if test="userName != null and userName != ''">
|
AND (user_name like concat('%', #{userName}, '%') or
|
(department_id in (SELECT id FROM automessage_organization_chart
|
WHERE organization_name like concat('%', #{userName}, '%'))) or
|
phonenumber like concat('%', #{userName}, '%'))
|
</if>
|
</where>
|
order by create_time desc
|
</select>
|
|
<select id="selectData" parameterType="string" resultMap="SysUserResult">
|
<include refid="selectSysUserVo"/>
|
<where>
|
<if test="userId!=null and userId!='' ">
|
AND user_id= #{userId}
|
</if>
|
|
<if test="phonenumber!=null and phonenumber!='' ">
|
AND phonenumber= #{phonenumber}
|
</if>
|
|
<if test="loginName!=null and loginName!='' ">
|
AND login_name= #{loginName}
|
</if>
|
|
</where>
|
</select>
|
|
<select id="getUserByAccount" parameterType="string" resultMap="SysUserResult">
|
<include refid="selectSysUserVo"/>
|
<where>
|
<if test="account!=null and account!='' ">
|
login_name= #{account}
|
</if>
|
</where>
|
</select>
|
|
<select id="selectListByDepartmentId" resultMap="SysUserResult">
|
<include refid="selectSysUserVo"/>
|
<where>
|
user_type=2 and status=0 and leisure_state=0
|
<if test="list!=null">
|
and department_id in
|
<foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
</if>
|
<if test="classifyIdFront!=null and classifyIdFront!='' and classifyIdAfter!=null and classifyIdAfter!=''">
|
and (concat(',',matters_ids, ',') like concat('%',#{classifyIdFront}, '%') or concat(',',matters_ids, ',') like concat('%',#{classifyIdAfter}, '%'))
|
</if>
|
|
</where>
|
order by transaction_num
|
</select>
|
|
<insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.SysUser">
|
insert ignore into automessage_sys_user (
|
create_time
|
<if test="userId != null and userId != '' ">,user_id</if>
|
<if test="loginName != null and loginName != '' ">,login_name</if>
|
<if test="userName != null and userName != '' ">,user_name</if>
|
<if test="userType != null and userType != '' ">,user_type</if>
|
<if test="phonenumber != null and phonenumber != '' ">,phonenumber</if>
|
<if test="sex != null and sex != '' ">,sex</if>
|
<if test="avatar != null and avatar != '' ">,avatar</if>
|
<if test="password != null and password != '' ">,password</if>
|
<if test="salt != null and salt != '' ">,salt</if>
|
<if test="status != null and status != '' ">,status</if>
|
<if test="delFlag != null and delFlag != '' ">,del_flag</if>
|
<if test="loginIp != null and loginIp != '' ">,login_ip</if>
|
<if test="loginDate != null ">,login_date</if>
|
<if test="pwdUpdateDate != null ">,pwd_update_date</if>
|
<if test="createBy != null and createBy != '' ">,create_by</if>
|
<if test="updateBy != null and updateBy != '' ">,update_by</if>
|
<if test="updateTime != null ">,update_time</if>
|
<if test="remark != null and remark != '' ">,remark</if>
|
<if test="roleIds != null and roleIds != '' ">,role_ids</if>
|
<if test="dataPermission != null and dataPermission != '' ">,data_permission</if>
|
<if test="departmentId != null and departmentId != '' ">,department_id</if>
|
<if test="stairId != null and stairId != '' ">,stair_id</if>
|
<if test="secondLevelId != null and secondLevelId != '' ">,second_level_id</if>
|
<if test="departmentName != null and departmentName != '' ">,department_name</if>
|
<if test="departmentArea != null and departmentArea != '' ">,department_area</if>
|
<if test="leisureState != null and leisureState != '' ">,leisure_state</if>
|
<if test="masterIds != null">,master_ids</if>
|
<if test="masterNames != null">,master_names</if>
|
<if test="transactionIds != null and transactionIds != '' ">,transaction_ids</if>
|
<if test="transactionNames != null and transactionNames != '' ">,transaction_names</if>
|
<if test="openid != null and openid != '' ">,openid</if>
|
<if test="isDivisionHead != null and isDivisionHead != '' ">,is_division_head</if>
|
<if test="mattersIds != null ">,matters_ids</if>
|
<if test="departmentIds != null ">,department_ids</if>
|
<if test="moreDepartmentIds != null ">,more_department_ids</if>
|
<if test="departmentIdStr != null ">,department_id_str</if>
|
)values(
|
sysdate()
|
<if test="userId != null and userId != '' ">,#{userId}</if>
|
<if test="loginName != null and loginName != '' ">,#{loginName}</if>
|
<if test="userName != null and userName != '' ">,#{userName}</if>
|
<if test="userType != null and userType != '' ">,#{userType}</if>
|
<if test="phonenumber != null and phonenumber != '' ">,#{phonenumber}</if>
|
<if test="sex != null and sex != '' ">,#{sex}</if>
|
<if test="avatar != null and avatar != '' ">,#{avatar}</if>
|
<if test="password != null and password != '' ">,#{password}</if>
|
<if test="salt != null and salt != '' ">,#{salt}</if>
|
<if test="status != null and status != '' ">,#{status}</if>
|
<if test="delFlag != null and delFlag != '' ">,#{delFlag}</if>
|
<if test="loginIp != null and loginIp != '' ">,#{loginIp}</if>
|
<if test="loginDate != null ">,#{loginDate}</if>
|
<if test="pwdUpdateDate != null and pwdUpdateDate != '' ">,#{pwdUpdateDate}</if>
|
<if test="createBy != null and createBy != '' ">,#{createBy}</if>
|
<if test="updateBy != null and updateBy != '' ">,#{updateBy}</if>
|
<if test="updateTime != null ">,#{updateTime}</if>
|
<if test="remark != null and remark != '' ">,#{remark}</if>
|
<if test="roleIds != null and roleIds != '' ">,#{roleIds}</if>
|
<if test="dataPermission != null and dataPermission != '' ">,#{dataPermission}</if>
|
<if test="departmentId != null and departmentId != '' ">,#{departmentId}</if>
|
<if test="stairId != null and stairId != '' ">,#{stairId}</if>
|
<if test="secondLevelId != null and secondLevelId != '' ">,#{secondLevelId}</if>
|
<if test="departmentName != null and departmentName != '' ">,#{departmentName}</if>
|
<if test="departmentArea != null and departmentArea != '' ">,#{departmentArea}</if>
|
<if test="leisureState != null and leisureState != '' ">,#{leisureState}</if>
|
<if test="masterIds != null">,#{masterIds}</if>
|
<if test="masterNames != null">,#{masterNames}</if>
|
<if test="transactionIds != null and transactionIds != '' ">,#{transactionIds}</if>
|
<if test="transactionNames != null and transactionNames != '' ">,#{transactionNames}</if>
|
<if test="openid != null and openid != '' ">,#{openid}</if>
|
<if test="isDivisionHead != null and isDivisionHead != '' ">,#{isDivisionHead}</if>
|
<if test="mattersIds != null">,#{mattersIds}</if>
|
<if test="departmentIds != null ">,#{departmentIds}</if>
|
<if test="moreDepartmentIds != null ">,#{moreDepartmentIds}</if>
|
<if test="departmentIdStr != null ">,#{departmentIdStr}</if>
|
)
|
</insert>
|
|
<update id="updateConfig" parameterType="com.dg.core.db.gen.entity.SysUser">
|
update automessage_sys_user
|
<set>
|
<if test="userId != null and userId != '' ">user_id=#{userId}</if>
|
<if test="loginName != null and loginName != '' ">,login_name=#{loginName}</if>
|
<if test="userName != null and userName != '' ">,user_name=#{userName}</if>
|
<if test="userType != null and userType != '' ">,user_type=#{userType}</if>
|
<if test="phonenumber != null and phonenumber != '' ">,phonenumber=#{phonenumber}</if>
|
<if test="sex != null and sex != '' ">,sex=#{sex}</if>
|
<if test="avatar != null and avatar != '' ">,avatar=#{avatar}</if>
|
<if test="password != null and password != '' ">,password=#{password}</if>
|
<if test="salt != null and salt != '' ">,salt=#{salt}</if>
|
<if test="status != null and status != '' ">,status=#{status}</if>
|
<if test="delFlag != null and delFlag != '' ">,del_flag=#{delFlag}</if>
|
<if test="loginIp != null and loginIp != '' ">,login_ip=#{loginIp}</if>
|
<if test="loginDate != null ">,login_date=#{loginDate}</if>
|
<if test="pwdUpdateDate != null ">,pwd_update_date=#{pwdUpdateDate}</if>
|
<if test="createBy != null and createBy != '' ">,create_by=#{createBy}</if>
|
<if test="createTime != null ">,create_time=#{createTime}</if>
|
<if test="updateBy != null and updateBy != '' ">,update_by=#{updateBy}</if>
|
<if test="remark != null and remark != '' ">,remark=#{remark}</if>
|
<if test="roleIds != null and roleIds != '' ">,role_ids=#{roleIds}</if>
|
<if test="dataPermission != null and dataPermission != '' ">,data_permission=#{dataPermission}</if>
|
<if test="departmentId != null and departmentId != '' ">,department_id=#{departmentId}</if>
|
<if test="stairId != null and stairId != '' ">,stair_id=#{stairId}</if>
|
<if test="secondLevelId != null and secondLevelId != '' ">,second_level_id=#{secondLevelId}</if>
|
<if test="departmentName != null and departmentName != '' ">,department_name=#{departmentName}</if>
|
<if test="departmentArea != null and departmentArea != '' ">,department_area=#{departmentArea}</if>
|
<if test="leisureState != null and leisureState != '' ">,leisure_state=#{leisureState}</if>
|
<if test="masterIds != null">,master_ids=#{masterIds}</if>
|
<if test="masterNames != null">,master_names=#{masterNames}</if>
|
<if test="transactionIds != null and transactionIds != '' ">,transaction_ids=#{transactionIds}</if>
|
<if test="transactionNames != null and transactionNames != '' ">,transaction_names=#{transactionNames}</if>
|
<if test="openid != null and openid != '' ">,openid=#{openid}</if>
|
<if test="isDivisionHead != null and isDivisionHead != '' ">,is_division_head=#{isDivisionHead}</if>
|
<if test="mattersIds != null">,matters_ids=#{mattersIds}</if>
|
<if test="departmentIds != null ">,department_ids=#{departmentIds}</if>
|
<if test="moreDepartmentIds != null ">,more_department_ids=#{moreDepartmentIds}</if>
|
<if test="departmentIdStr != null ">,department_id_str=#{departmentIdStr}</if>
|
,update_time=sysdate()
|
</set>
|
where user_id= #{userId}
|
</update>
|
|
<delete id="deleteConfigById" parameterType="string">
|
delete from automessage_sys_user where user_id= #{id}
|
</delete>
|
|
<select id="setGroup">
|
SET SESSION group_concat_max_len=10240
|
</select>
|
|
|
</mapper>
|