¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="org.jeecg.modules.system.mapper.SysUserMapper"> |
| | | |
| | | <!-- æ ¹æ®ç¨æ·åæ¥è¯¢ --> |
| | | <select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where username = #{username} and del_flag = 0 |
| | | </select> |
| | | |
| | | <!-- æ ¹æ®é¨é¨Idæ¥è¯¢ --> |
| | | <select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where dep_id=#{departId}) |
| | | <if test="username!=null and username!=''"> |
| | | and username = #{username} |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- æ¥è¯¢ç¨æ·çæå±é¨é¨åç§°ä¿¡æ¯ --> |
| | | <select id="getDepNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserDepVo"> |
| | | select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in |
| | | <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <!-- éè¿å¤ä¸ªé¨é¨IDSï¼æ¥è¯¢é¨é¨ä¸çç¨æ·ä¿¡æ¯ --> |
| | | <select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where del_flag = 0 |
| | | <if test="departIds!=null and departIds.size()>0"> |
| | | and id in (select user_id from sys_user_depart where dep_id in |
| | | <foreach collection="departIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="username!=null and username!=''"> |
| | | and username = #{username} |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- æ ¹æ®è§è²Idæ¥è¯¢ --> |
| | | <select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_role where role_id=#{roleId}) |
| | | <if test="username!=null and username!=''"> |
| | | and username = #{username} |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- ä¿®æ¹ç¨æ·é¨é¨code --> |
| | | <update id="updateUserDepart"> |
| | | UPDATE sys_user SET org_code = #{orgCode} where username = #{username} |
| | | </update> |
| | | |
| | | <!-- æ ¹æ®ææºå·æ¥è¯¢ --> |
| | | <select id="getUserByPhone" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where phone = #{phone} and del_flag = 0 |
| | | </select> |
| | | |
| | | <!-- æ ¹æ®é®ç®±æ¥è¯¢ç¨æ·ä¿¡æ¯ --> |
| | | <select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where email = #{email} and del_flag = 0 |
| | | </select> |
| | | |
| | | <!-- SQLçæ®µï¼getUserByOrgCode ç FROM å WHERE é¨å --> |
| | | <sql id="getUserByOrgCodeFromSql"> |
| | | FROM |
| | | sys_depart |
| | | INNER JOIN sys_user_depart ON sys_user_depart.dep_id = sys_depart.id |
| | | INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id |
| | | WHERE |
| | | <if test="orgCode == null"> |
| | | <bind name="bindOrgCode" value="'%'"/> |
| | | </if> |
| | | <if test="orgCode != null"> |
| | | <bind name="bindOrgCode" value="orgCode+'%'"/> |
| | | </if> |
| | | sys_user.del_flag = 0 AND sys_depart.org_code LIKE #{bindOrgCode} |
| | | |
| | | <if test="userParams != null"> |
| | | <if test="userParams.realname != null and userParams.realname != ''"> |
| | | AND sys_user.realname LIKE concat(concat('%',#{userParams.realname}),'%') |
| | | </if> |
| | | <if test="userParams.workNo != null and userParams.workNo != ''"> |
| | | AND sys_user.work_no LIKE concat(concat('%',#{userParams.workNo}),'%') |
| | | </if> |
| | | </if> |
| | | </sql> |
| | | |
| | | <!-- æ ¹æ® orgCode æ¥è¯¢ç¨æ·ï¼å
æ¬åé¨é¨ä¸çç¨æ· --> |
| | | <select id="getUserByOrgCode" resultType="org.jeecg.modules.system.model.SysUserSysDepartModel"> |
| | | SELECT |
| | | sys_user.id AS id, |
| | | sys_user.realname AS realname, |
| | | sys_user.avatar AS avatar, |
| | | sys_user.sex AS sex, |
| | | sys_user.birthday AS birthday, |
| | | sys_user.work_no AS workNo, |
| | | sys_user.post AS post, |
| | | sys_user.telephone AS telephone, |
| | | sys_user.email AS email, |
| | | sys_user.phone AS phone, |
| | | sys_depart.id AS departId, |
| | | sys_depart.depart_name AS departName |
| | | <include refid="getUserByOrgCodeFromSql"/> |
| | | ORDER BY |
| | | sys_depart.org_code ASC |
| | | </select> |
| | | |
| | | <!-- æ¥è¯¢ getUserByOrgCode çæ»æ°--> |
| | | <select id="getUserByOrgCodeTotal" resultType="java.lang.Integer"> |
| | | SELECT COUNT(1) <include refid="getUserByOrgCodeFromSql"/> |
| | | </select> |
| | | |
| | | <!-- æ¹éå é¤è§è²çä¸ç¨æ·å
³ç³»--> |
| | | <update id="deleteBathRoleUserRelation"> |
| | | delete from sys_user_role |
| | | where role_id in |
| | | <foreach item="id" collection="roleIdArray" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </update> |
| | | <!-- æ¹éå é¤è§è²ç䏿éå
³ç³»--> |
| | | <update id="deleteBathRolePermissionRelation"> |
| | | delete from sys_role_permission |
| | | where role_id in |
| | | <foreach item="id" collection="roleIdArray" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </update> |
| | | |
| | | <!-- æ¥è¯¢è¢«é»è¾å é¤çç¨æ· --> |
| | | <select id="selectLogicDeleted" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | SELECT * FROM sys_user ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | <!-- æ´æ°è¢«é»è¾å é¤çç¨æ· --> |
| | | <update id="revertLogicDeleted"> |
| | | UPDATE |
| | | sys_user |
| | | SET |
| | | del_flag = 0, |
| | | update_by = #{entity.updateBy}, |
| | | update_time = #{entity.updateTime} |
| | | WHERE |
| | | del_flag = 1 |
| | | AND id IN |
| | | <foreach collection="userIds" item="userId" open="(" close=")" separator="," > |
| | | #{userId} |
| | | </foreach> |
| | | </update> |
| | | |
| | | <!-- å½»åºå é¤è¢«é»è¾å é¤çç¨æ· --> |
| | | <delete id="deleteLogicDeleted"> |
| | | DELETE FROM sys_user WHERE del_flag = 1 AND id IN |
| | | <foreach collection="userIds" item="userId" open="(" close=")" separator="," > |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <!-- æ´æ°ç©ºå符串为null --> |
| | | <update id="updateNullByEmptyString"> |
| | | UPDATE sys_user |
| | | <if test="fieldName == 'email'"> |
| | | SET email = NULL WHERE email = '' |
| | | </if> |
| | | <if test="fieldName == 'phone'"> |
| | | SET phone = NULL WHERE phone = '' |
| | | </if> |
| | | </update> |
| | | |
| | | <!-- éè¿å¤ä¸ªé¨é¨IDSï¼æ¥è¯¢é¨é¨ä¸çç¨æ·ä¿¡æ¯ --> |
| | | <select id="queryByDepIds" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where del_flag = 0 |
| | | <if test="departIds!=null and departIds.size()>0"> |
| | | and id in (select user_id from sys_user_depart where dep_id in |
| | | <foreach collection="departIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="username!=null and username!=''"> |
| | | and username != #{username} |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- æ¥è¯¢ç¨æ·çæå±äº§çº¿åç§°ä¿¡æ¯ --> |
| | | <select id="getProNamesByUserIds" resultType="org.jeecg.modules.system.vo.MdcUserProVo"> |
| | | SELECT p.production_name, up.user_id FROM mdc_user_production up, mdc_production p WHERE p.id = up.pro_id AND up.user_id IN |
| | | <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <!-- æ ¹æ®è§è²Idæ¥è¯¢è¯¥è§è²ä¸çææç¨æ·ä¿¡æ¯ --> |
| | | <select id="getAllUsersByRoleId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_role where role_id=#{roleId}) |
| | | </select> |
| | | <!--æ ¹æ®è§è²ç¼ç æ¥è¯¢ç¨æ·idéåæ ¹æ®è§è²ç¼ç æ¥è¯¢ç¨æ·idéå--> |
| | | <select id="getUserByRoleCode" resultType="java.lang.String"> |
| | | SELECT |
| | | su.id |
| | | FROM |
| | | sys_user su |
| | | LEFT JOIN sys_user_role sur ON su.id = sur.user_id |
| | | LEFT JOIN sys_role sr ON sur.role_id = sr.id |
| | | WHERE |
| | | sr.role_code = #{ roleCode } |
| | | </select> |
| | | <!--æ ¹æ®è§è²ç¼ç å设å¤ç¼å·æ¥è¯¢ç¨æ·--> |
| | | <select id="getEquipmentAdmin" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | sys_user t1 |
| | | LEFT JOIN sys_user_role t2 ON t1.id = t2.user_id |
| | | LEFT JOIN sys_role t3 ON t2.role_id = t3.id |
| | | WHERE |
| | | t3.role_code = #{roleCode} AND equipment_ids LIKE concat(concat('%',#{equipmentId}),'%') |
| | | </select> |
| | | <select id="selectUsersByNames" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | SELECT |
| | | username, |
| | | realname |
| | | FROM sys_user |
| | | WHERE |
| | | username IN |
| | | <foreach item="name" collection="userNames" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </select> |
| | | </mapper> |