123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?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.platform.dao.mapper.upms.SysUserMapper">
- <!-- <select id="selectVOByKeyword" resultType="com.platform.dao.vo.SysUserVO"-->
- <!-- parameterType="com.platform.dao.dto.upms.SysUserDTO">-->
- <!-- select u.* from t_sys_user u-->
- <!-- join t_sys_user_role role-->
- <!-- on u.user_id=role.user_id-->
- <!-- where 1=1-->
- <!-- <if test="keyword !=null and keyword !=''">-->
- <!-- and (u.username like CONCAT('%',#{keyword},'%')-->
- <!-- or u.real_name like CONCAT('%',#{keyword},'%'))-->
- <!-- </if>-->
- <!-- <if test="deptId !=null and deptId !=''">-->
- <!-- and exists (select 1 from t_sys_user_dept t where t.user_id = u.user_id and t.dept_id = #{deptId}-->
- <!-- union select 1 from t_sys_dept t where t.dept_id = #{deptId} and t.parent_id = '0')-->
- <!-- </if>-->
- <!-- <if test="phone !=null and phone !=''">-->
- <!-- and u.phone = #{phone}-->
- <!-- </if>-->
- <!-- <if test="username !=null and username !=''">-->
- <!-- and u.username = #{username}-->
- <!-- </if>-->
- <!-- <if test="teamId !=null and teamId !=''">-->
- <!-- and exists (select 1 from t_sys_user_team t where t.user_id = u.user_id and t.team_id = #{teamId})-->
- <!-- </if>-->
- <!-- <if test="identityType !=null">-->
- <!-- and u.identity_type = #{identityType}-->
- <!-- </if>-->
- <!-- <if test="roleId!=null and roleId!=''">-->
- <!-- and role.role_id=#{roleId}-->
- <!-- </if>-->
- <!-- order by u.update_time desc-->
- <!-- </select>-->
- <select id="selectVOByKeyword" resultType="com.platform.dao.vo.SysUserVO"
- parameterType="com.platform.dao.dto.upms.SysUserDTO">
- select distinct u.* from t_sys_user u
- join t_sys_user_role role
- on u.user_id=role.user_id left join t_sys_role srole on role.role_id=srole.role_id
- left join t_sys_user_dept ud on ud.user_id = u.user_id
- left join t_sys_dept dept on dept.dept_id = ud.dept_id
- where 1=1
- <if test="keyword !=null and keyword !=''">
- and (u.username like CONCAT('%',#{keyword},'%')
- or u.real_name like CONCAT('%',#{keyword},'%'))
- </if>
- <if test="deptId !=null and deptId !=''">
- and exists (select 1 from t_sys_user_dept t where t.user_id = u.user_id and t.dept_id = #{deptId}
- union select 1 from t_sys_dept t where t.dept_id = #{deptId} and t.parent_id = '0')
- </if>
- <if test="phone !=null and phone !=''">
- and u.phone = #{phone}
- </if>
- <if test="username !=null and username !=''">
- and u.username = #{username}
- </if>
- <if test="teamId !=null and teamId !=''">
- and exists (select 1 from t_sys_user_team t where t.user_id = u.user_id and t.team_id = #{teamId})
- </if>
- <if test="identityType !=null">
- and u.identity_type = #{identityType}
- </if>
- <if test="roleId!=null and roleId!=''">
- and role.role_id=#{roleId}
- </if>
- <if test="roleCode!=null and roleCode!=''">
- and srole.role_code=#{roleCode}
- </if>
- <if test="deptIds !=null and deptIds.size>0">
- and dept.dept_id in
- <foreach collection="deptIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- order by u.update_time desc
- </select>
- <select id="selectByDept" resultType="com.platform.dao.vo.SysUserVO"
- parameterType="com.platform.dao.dto.upms.SysUserDTO">
- select u.* from t_sys_user u
- left join t_sys_user_dept ud on u.user_id = ud.user_id
- where 1=1
- <if test="deptIds != null and deptIds.size >0">
- AND ud.dept_id in
- <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- order by u.update_time desc
- </select>
- <!-- <select id="selectByDept" resultType="com.platform.dao.vo.SysUserVO"-->
- <!-- parameterType="com.platform.dao.dto.upms.SysUserDTO">-->
- <!-- select u.* from t_sys_user u-->
- <!-- left join t_sys_user_dept ud on u.user_id = ud.user_id-->
- <!-- where 1=1-->
- <!-- <if test="deptIds != null and deptIds.size >0">-->
- <!-- AND ud.dept_id in-->
- <!-- <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">-->
- <!-- #{item}-->
- <!-- </foreach>-->
- <!-- </if>-->
- <!-- order by u.update_time desc-->
- <!-- </select>-->
- <select id="selectDeptRoleUser" resultType="com.platform.dao.vo.SysUserVO"
- parameterType="com.platform.dao.dto.upms.SysUserDTO">
- select distinct u.* from t_sys_user u, t_sys_user_dept ud, t_sys_user_role ur, t_sys_role r
- where u.user_id = ud.user_id and u.user_id = ur.user_id and ur.role_id = r.role_id
- <if test="deptIds != null and deptIds.size >0">
- AND ud.dept_id in
- <foreach item="item" index="index" collection="deptIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="roleId !=null and roleId !=''">
- and r.role_id = #{roleId}
- </if>
- <if test="roleIds != null and roleIds.size >0">
- AND r.role_id in
- <foreach item="item" index="index" collection="roleIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="roleCode !=null and roleCode !=''">
- and r.role_code = #{roleCode}
- </if>
- <if test="roleCodes != null and roleCodes.size >0">
- AND r.role_code in
- <foreach item="item" index="index" collection="roleCodes" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptId != null">
- and ud.dept_id = #{deptId}
- </if>
- <if test="userId != null and userId != ''">
- and u.user_id = #{userId}
- </if>
- <choose>
- <when test="orderByFlag != null and orderByFlag == 1">
- order by u.created_time asc
- </when>
- <otherwise>
- order by u.update_time desc
- </otherwise>
- </choose>
- </select>
- <select id="selectUserNameById" resultType="java.lang.String" parameterType="java.lang.Object">
- select real_name
- from t_sys_user
- where user_id = #{value}
- </select>
- <select id="getSysUserList" parameterType="com.platform.dao.dto.upms.SysUserDeptDTO"
- resultType="com.platform.dao.vo.SysUserVO">
- select distinct user.username as username,user.real_name realName, user.user_id userId from t_sys_user user
- join t_sys_user_role urole on urole.user_id = user.user_id
- join t_sys_role role on urole.role_id = role.role_id
- join t_sys_user_dept dept on user.user_id = dept.user_id
- where role.role_name = '维修人员' and user.status = 1
- <if test="deptId != null and deptId != ''">
- and dept.dept_id = #{deptId}
- </if>
- </select>
- <select id="getRepairUsers" parameterType="com.platform.dao.dto.upms.SysUserDTO"
- resultType="com.platform.dao.vo.SysUserVO">
- select distinct user.username as username,user.real_name realName, user.user_id userId from t_sys_user user
- join t_sys_user_role urole on urole.user_id = user.user_id
- join t_sys_role role on urole.role_id = role.role_id
- join t_sys_user_dept dept on user.user_id = dept.user_id
- where user.status = 1
- <if test="roleCode != null">
- and role.role_code = #{roleCode}
- </if>
- <if test="deptId != null and deptId != ''">
- and dept.dept_id = #{deptId}
- </if>
- <if test="roleCodes != null and roleCodes.size >0">
- AND role.role_code in
- <foreach item="item" index="index" collection="roleCodes" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getSysUserVO" parameterType="com.platform.dao.dto.upms.SysUserDTO"
- resultType="com.platform.dao.vo.SysUserVO">
- SELECT user.*,dept.name as dept, GROUP_CONCAT(role.role_name) as roless
- FROM t_sys_user USER LEFT JOIN t_sys_user_role ur
- ON user.`user_id`=ur.`user_id`
- LEFT JOIN t_sys_role role
- ON ur.`role_id`=role.`role_id`
- LEFT JOIN t_sys_user_dept ud
- ON user.`user_id`=ud.user_id
- LEFT JOIN t_sys_dept dept
- ON ud.`dept_id`=dept.`dept_id`
- where 1=1
- <if test="keyword !=null and keyword !=''">
- and (user.username like CONCAT('%',#{keyword},'%')
- or user.real_name like CONCAT('%',#{keyword},'%'))
- </if>
- <if test="deptId !=null and deptId !=''">
- and exists (select 1 from t_sys_user_dept ud where ud.user_id = user.user_id and ud.dept_id = #{deptId}
- union select 1 from t_sys_dept dept where ud.dept_id = #{deptId} and ud.parent_id = '0')
- </if>
- <if test="phone !=null and phone !=''">
- and user.phone = #{phone}
- </if>
- <if test="username !=null and username !=''">
- and user.username = #{username}
- </if>
- <if test="teamId !=null and teamId !=''">
- and exists (select 1 from t_sys_user_team t where t.user_id = user.user_id and t.team_id = #{teamId})
- </if>
- <if test="identityType !=null">
- and user.identity_type = #{identityType}
- </if>
- <if test="roleId!=null and roleId!=''">
- and role.role_id=#{roleId}
- </if>
- GROUP BY user.`user_id`
- order by user.update_time desc
- </select>
- </mapper>
|