Quellcode durchsuchen

公用方法封装

yumeng vor 2 Jahren
Ursprung
Commit
fb1c3a9741

+ 4 - 0
ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysDeptMapper.java

@@ -115,4 +115,8 @@ public interface SysDeptMapper
      * @return 结果
      */
     public int deleteDeptById(Long deptId);
+
+    Long getDeptIdByUserId(Long userId);
+
+    List<Long> getDeptUserListByDeptId(Long deptId);
 }

+ 23 - 15
ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysRoleMapper.java

@@ -1,18 +1,18 @@
 package com.ruixuan.system.mapper;
 
 import java.util.List;
+
 import com.ruixuan.common.core.domain.entity.SysRole;
 
 /**
  * 角色表 数据层
- * 
+ *
  * @author ruixuan
  */
-public interface SysRoleMapper
-{
+public interface SysRoleMapper {
     /**
      * 根据条件分页查询角色数据
-     * 
+     *
      * @param role 角色信息
      * @return 角色数据集合信息
      */
@@ -20,7 +20,7 @@ public interface SysRoleMapper
 
     /**
      * 根据用户ID查询角色
-     * 
+     *
      * @param userId 用户ID
      * @return 角色列表
      */
@@ -28,14 +28,14 @@ public interface SysRoleMapper
 
     /**
      * 查询所有角色
-     * 
+     *
      * @return 角色列表
      */
     public List<SysRole> selectRoleAll();
 
     /**
      * 根据用户ID获取角色选择框列表
-     * 
+     *
      * @param userId 用户ID
      * @return 选中角色ID列表
      */
@@ -43,7 +43,7 @@ public interface SysRoleMapper
 
     /**
      * 通过角色ID查询角色
-     * 
+     *
      * @param roleId 角色ID
      * @return 角色对象信息
      */
@@ -51,7 +51,7 @@ public interface SysRoleMapper
 
     /**
      * 根据用户ID查询角色
-     * 
+     *
      * @param userName 用户名
      * @return 角色列表
      */
@@ -59,7 +59,7 @@ public interface SysRoleMapper
 
     /**
      * 校验角色名称是否唯一
-     * 
+     *
      * @param roleName 角色名称
      * @return 角色信息
      */
@@ -67,7 +67,7 @@ public interface SysRoleMapper
 
     /**
      * 校验角色权限是否唯一
-     * 
+     *
      * @param roleKey 角色权限
      * @return 角色信息
      */
@@ -75,7 +75,7 @@ public interface SysRoleMapper
 
     /**
      * 修改角色信息
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -83,7 +83,7 @@ public interface SysRoleMapper
 
     /**
      * 新增角色信息
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -91,7 +91,7 @@ public interface SysRoleMapper
 
     /**
      * 通过角色ID删除角色
-     * 
+     *
      * @param roleId 角色ID
      * @return 结果
      */
@@ -99,11 +99,19 @@ public interface SysRoleMapper
 
     /**
      * 批量删除角色信息
-     * 
+     *
      * @param roleIds 需要删除的角色ID
      * @return 结果
      */
     public int deleteRoleByIds(Long[] roleIds);
 
     String selectRoleByUserId(Long userId);
+
+    /**
+     * 根据用户ID获取角色id
+     *
+     * @param userId
+     * @return
+     */
+    String getRoleBYUserId(Long userId);
 }

+ 37 - 16
ruixuan-system/src/main/java/com/ruixuan/system/service/ISysDeptService.java

@@ -1,27 +1,48 @@
 package com.ruixuan.system.service;
 
 import java.util.List;
+
 import com.ruixuan.common.core.domain.TreeSelect;
 import com.ruixuan.common.core.domain.entity.SysDept;
 
 /**
  * 部门管理 服务层
- * 
+ *
  * @author ruixuan
  */
-public interface ISysDeptService
-{
+public interface ISysDeptService {
+
+    /**
+     * 根据用户ID获取部门ID
+     *
+     * @param userId
+     * @return
+     */
+    Long getDeptIdByUserId(Long userId);
+
+    /**
+     * 根据部门id获取此部门下所有人员
+     *
+     * @param deptId
+     * @return
+     */
+    List<Long> getDeptUserListByDeptId(Long deptId);
+
+
+    // List<Long> selectDeptUsertListBy(SysDept dept);
+
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
+
     public List<SysDept> selectDeptList(SysDept dept);
 
     /**
      * 构建前端所需要树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 树结构列表
      */
@@ -29,7 +50,7 @@ public interface ISysDeptService
 
     /**
      * 构建前端所需要下拉树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 下拉树结构列表
      */
@@ -37,7 +58,7 @@ public interface ISysDeptService
 
     /**
      * 根据角色ID查询部门树信息
-     * 
+     *
      * @param roleId 角色ID
      * @return 选中部门列表
      */
@@ -45,7 +66,7 @@ public interface ISysDeptService
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门信息
      */
@@ -53,7 +74,7 @@ public interface ISysDeptService
 
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param deptId 部门ID
      * @return 子部门数
      */
@@ -61,7 +82,7 @@ public interface ISysDeptService
 
     /**
      * 是否存在部门子节点
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -69,7 +90,7 @@ public interface ISysDeptService
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果 true 存在 false 不存在
      */
@@ -77,7 +98,7 @@ public interface ISysDeptService
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -85,14 +106,14 @@ public interface ISysDeptService
 
     /**
      * 校验部门是否有数据权限
-     * 
+     *
      * @param deptId 部门id
      */
     public void checkDeptDataScope(Long deptId);
 
     /**
      * 新增保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -100,7 +121,7 @@ public interface ISysDeptService
 
     /**
      * 修改保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -108,7 +129,7 @@ public interface ISysDeptService
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */

+ 36 - 25
ruixuan-system/src/main/java/com/ruixuan/system/service/ISysRoleService.java

@@ -2,19 +2,30 @@ package com.ruixuan.system.service;
 
 import java.util.List;
 import java.util.Set;
+
 import com.ruixuan.common.core.domain.entity.SysRole;
 import com.ruixuan.system.domain.SysUserRole;
 
 /**
  * 角色业务层
- * 
+ *
  * @author ruixuan
  */
-public interface ISysRoleService
-{
+public interface ISysRoleService {
+
+
+    /**
+     * 根据用户ID获取用户角色
+     *
+     * @param userId
+     * @return
+     */
+    String getRoleBYUserId(Long userId);
+
+
     /**
      * 根据条件分页查询角色数据
-     * 
+     *
      * @param role 角色信息
      * @return 角色数据集合信息
      */
@@ -22,7 +33,7 @@ public interface ISysRoleService
 
     /**
      * 根据用户ID查询角色列表
-     * 
+     *
      * @param userId 用户ID
      * @return 角色列表
      */
@@ -30,7 +41,7 @@ public interface ISysRoleService
 
     /**
      * 根据用户ID查询角色权限
-     * 
+     *
      * @param userId 用户ID
      * @return 权限列表
      */
@@ -38,14 +49,14 @@ public interface ISysRoleService
 
     /**
      * 查询所有角色
-     * 
+     *
      * @return 角色列表
      */
     public List<SysRole> selectRoleAll();
 
     /**
      * 根据用户ID获取角色选择框列表
-     * 
+     *
      * @param userId 用户ID
      * @return 选中角色ID列表
      */
@@ -53,7 +64,7 @@ public interface ISysRoleService
 
     /**
      * 通过角色ID查询角色
-     * 
+     *
      * @param roleId 角色ID
      * @return 角色对象信息
      */
@@ -61,7 +72,7 @@ public interface ISysRoleService
 
     /**
      * 校验角色名称是否唯一
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -69,7 +80,7 @@ public interface ISysRoleService
 
     /**
      * 校验角色权限是否唯一
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -77,21 +88,21 @@ public interface ISysRoleService
 
     /**
      * 校验角色是否允许操作
-     * 
+     *
      * @param role 角色信息
      */
     public void checkRoleAllowed(SysRole role);
 
     /**
      * 校验角色是否有数据权限
-     * 
+     *
      * @param roleId 角色id
      */
     public void checkRoleDataScope(Long roleId);
 
     /**
      * 通过角色ID查询角色使用数量
-     * 
+     *
      * @param roleId 角色ID
      * @return 结果
      */
@@ -99,7 +110,7 @@ public interface ISysRoleService
 
     /**
      * 新增保存角色信息
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -107,7 +118,7 @@ public interface ISysRoleService
 
     /**
      * 修改保存角色信息
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -115,7 +126,7 @@ public interface ISysRoleService
 
     /**
      * 修改角色状态
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -123,7 +134,7 @@ public interface ISysRoleService
 
     /**
      * 修改数据权限信息
-     * 
+     *
      * @param role 角色信息
      * @return 结果
      */
@@ -131,7 +142,7 @@ public interface ISysRoleService
 
     /**
      * 通过角色ID删除角色
-     * 
+     *
      * @param roleId 角色ID
      * @return 结果
      */
@@ -139,7 +150,7 @@ public interface ISysRoleService
 
     /**
      * 批量删除角色信息
-     * 
+     *
      * @param roleIds 需要删除的角色ID
      * @return 结果
      */
@@ -147,7 +158,7 @@ public interface ISysRoleService
 
     /**
      * 取消授权用户角色
-     * 
+     *
      * @param userRole 用户和角色关联信息
      * @return 结果
      */
@@ -155,8 +166,8 @@ public interface ISysRoleService
 
     /**
      * 批量取消授权用户角色
-     * 
-     * @param roleId 角色ID
+     *
+     * @param roleId  角色ID
      * @param userIds 需要取消授权的用户数据ID
      * @return 结果
      */
@@ -164,8 +175,8 @@ public interface ISysRoleService
 
     /**
      * 批量选择授权用户角色
-     * 
-     * @param roleId 角色ID
+     *
+     * @param roleId  角色ID
      * @param userIds 需要删除的用户数据ID
      * @return 结果
      */

+ 10 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/impl/SysDeptServiceImpl.java

@@ -35,6 +35,16 @@ public class SysDeptServiceImpl implements ISysDeptService
     @Autowired
     private SysRoleMapper roleMapper;
 
+    @Override
+    public Long getDeptIdByUserId(Long userId) {
+        return deptMapper.getDeptIdByUserId(userId);
+    }
+
+    @Override
+    public List<Long> getDeptUserListByDeptId(Long deptId) {
+        return deptMapper.getDeptUserListByDeptId(deptId);
+    }
+
     /**
      * 查询部门管理数据
      * 

+ 7 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/impl/SysRoleServiceImpl.java

@@ -45,6 +45,13 @@ public class SysRoleServiceImpl implements ISysRoleService {
     @Autowired
     private SysRoleDeptMapper roleDeptMapper;
 
+    @Override
+    public String getRoleBYUserId(Long userId) {
+        return roleMapper.getRoleBYUserId(userId);
+    }
+
+
+
     /**
      * 根据条件分页查询角色数据
      *

+ 134 - 126
ruixuan-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -1,156 +1,164 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruixuan.system.mapper.SysDeptMapper">
 
-	<resultMap type="SysDept" id="SysDeptResult">
-		<id     property="deptId"     column="dept_id"     />
-		<result property="parentId"   column="parent_id"   />
-		<result property="ancestors"  column="ancestors"   />
-		<result property="deptName"   column="dept_name"   />
-		<result property="orderNum"   column="order_num"   />
-		<result property="leader"     column="leader"      />
-		<result property="phone"      column="phone"       />
-		<result property="email"      column="email"       />
-		<result property="status"     column="status"      />
-		<result property="delFlag"    column="del_flag"    />
-		<result property="parentName" column="parent_name" />
-		<result property="createBy"   column="create_by"   />
-		<result property="createTime" column="create_time" />
-		<result property="updateBy"   column="update_by"   />
-		<result property="updateTime" column="update_time" />
-	</resultMap>
-	
-	<sql id="selectDeptVo">
+    <resultMap type="SysDept" id="SysDeptResult">
+        <id property="deptId" column="dept_id"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="ancestors" column="ancestors"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="orderNum" column="order_num"/>
+        <result property="leader" column="leader"/>
+        <result property="phone" column="phone"/>
+        <result property="email" column="email"/>
+        <result property="status" column="status"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="parentName" column="parent_name"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectDeptVo">
         select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time 
         from sys_dept d
     </sql>
-    
-	<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
+
+    <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
         where d.del_flag = '0'
-		<if test="deptId != null and deptId != 0">
-			AND dept_id = #{deptId}
-		</if>
+        <if test="deptId != null and deptId != 0">
+            AND dept_id = #{deptId}
+        </if>
         <if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>
-		<if test="deptName != null and deptName != ''">
-			AND dept_name like concat('%', #{deptName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND status = #{status}
-		</if>
-		<!-- 数据范围过滤 -->
-		${params.dataScope}
-		order by d.parent_id, d.order_num
+            AND parent_id = #{parentId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            AND dept_name like concat('%', #{deptName}, '%')
+        </if>
+        <if test="status != null and status != ''">
+            AND status = #{status}
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+        order by d.parent_id, d.order_num
     </select>
-    
+
     <select id="selectDeptListByRoleId" resultType="Long">
-		select d.dept_id
-		from sys_dept d
-            left join sys_role_dept rd on d.dept_id = rd.dept_id
+        select d.dept_id
+        from sys_dept d
+        left join sys_role_dept rd on d.dept_id = rd.dept_id
         where rd.role_id = #{roleId}
-            <if test="deptCheckStrictly">
-              and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
-            </if>
-		order by d.parent_id, d.order_num
-	</select>
-    
+        <if test="deptCheckStrictly">
+            and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id =
+            rd.dept_id and rd.role_id = #{roleId})
+        </if>
+        order by d.parent_id, d.order_num
+    </select>
+
     <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
-		<include refid="selectDeptVo"/>
-		where dept_id = #{deptId}
-	</select>
-    
+        <include refid="selectDeptVo"/>
+        where dept_id = #{deptId}
+    </select>
+
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
 		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
 	</select>
-	
-	<select id="hasChildByDeptId" parameterType="Long" resultType="int">
+
+    <select id="hasChildByDeptId" parameterType="Long" resultType="int">
 		select count(1) from sys_dept
 		where del_flag = '0' and parent_id = #{deptId} limit 1
 	</select>
-	
-	<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
+
+    <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
 		select * from sys_dept where find_in_set(#{deptId}, ancestors)
 	</select>
-	
-	<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
+
+    <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
 		select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
 	</select>
-	
-	<select id="checkDeptNameUnique" resultMap="SysDeptResult">
-	    <include refid="selectDeptVo"/>
-		where dept_name=#{deptName} and parent_id = #{parentId} limit 1
+
+    <select id="checkDeptNameUnique" resultMap="SysDeptResult">
+        <include refid="selectDeptVo"/>
+        where dept_name=#{deptName} and parent_id = #{parentId} limit 1
+    </select>
+    <select id="getDeptIdByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
+		select  dept_id  from sys_user where user_id = #{userId}
+
+	</select>
+    <select id="getDeptUserListByDeptId" resultType="java.lang.Long" parameterType="java.lang.Long">
+		select  user_id from sys_user  where  dept_id = #{deptId}
 	</select>
-    
+
     <insert id="insertDept" parameterType="SysDept">
- 		insert into sys_dept(
- 			<if test="deptId != null and deptId != 0">dept_id,</if>
- 			<if test="parentId != null and parentId != 0">parent_id,</if>
- 			<if test="deptName != null and deptName != ''">dept_name,</if>
- 			<if test="ancestors != null and ancestors != ''">ancestors,</if>
- 			<if test="orderNum != null and orderNum != ''">order_num,</if>
- 			<if test="leader != null and leader != ''">leader,</if>
- 			<if test="phone != null and phone != ''">phone,</if>
- 			<if test="email != null and email != ''">email,</if>
- 			<if test="status != null">status,</if>
- 			<if test="createBy != null and createBy != ''">create_by,</if>
- 			create_time
- 		)values(
- 			<if test="deptId != null and deptId != 0">#{deptId},</if>
- 			<if test="parentId != null and parentId != 0">#{parentId},</if>
- 			<if test="deptName != null and deptName != ''">#{deptName},</if>
- 			<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
- 			<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
- 			<if test="leader != null and leader != ''">#{leader},</if>
- 			<if test="phone != null and phone != ''">#{phone},</if>
- 			<if test="email != null and email != ''">#{email},</if>
- 			<if test="status != null">#{status},</if>
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
- 			sysdate()
- 		)
-	</insert>
-	
-	<update id="updateDept" parameterType="SysDept">
- 		update sys_dept
- 		<set>
- 			<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
- 			<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
- 			<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
- 			<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
- 			<if test="leader != null">leader = #{leader},</if>
- 			<if test="phone != null">phone = #{phone},</if>
- 			<if test="email != null">email = #{email},</if>
- 			<if test="status != null and status != ''">status = #{status},</if>
- 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- 			update_time = sysdate()
- 		</set>
- 		where dept_id = #{deptId}
-	</update>
-	
-	<update id="updateDeptChildren" parameterType="java.util.List">
-	    update sys_dept set ancestors =
-	    <foreach collection="depts" item="item" index="index"
-	        separator=" " open="case dept_id" close="end">
-	        when #{item.deptId} then #{item.ancestors}
-	    </foreach>
-	    where dept_id in
-	    <foreach collection="depts" item="item" index="index"
-	        separator="," open="(" close=")">
-	        #{item.deptId}
-	    </foreach>
-	</update>
-	 
-	<update id="updateDeptStatusNormal" parameterType="Long">
- 	    update sys_dept set status = '0' where dept_id in 
- 	    <foreach collection="array" item="deptId" open="(" separator="," close=")">
-        	#{deptId}
+        insert into sys_dept(
+        <if test="deptId != null and deptId != 0">dept_id,</if>
+        <if test="parentId != null and parentId != 0">parent_id,</if>
+        <if test="deptName != null and deptName != ''">dept_name,</if>
+        <if test="ancestors != null and ancestors != ''">ancestors,</if>
+        <if test="orderNum != null and orderNum != ''">order_num,</if>
+        <if test="leader != null and leader != ''">leader,</if>
+        <if test="phone != null and phone != ''">phone,</if>
+        <if test="email != null and email != ''">email,</if>
+        <if test="status != null">status,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        create_time
+        )values(
+        <if test="deptId != null and deptId != 0">#{deptId},</if>
+        <if test="parentId != null and parentId != 0">#{parentId},</if>
+        <if test="deptName != null and deptName != ''">#{deptName},</if>
+        <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
+        <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
+        <if test="leader != null and leader != ''">#{leader},</if>
+        <if test="phone != null and phone != ''">#{phone},</if>
+        <if test="email != null and email != ''">#{email},</if>
+        <if test="status != null">#{status},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        sysdate()
+        )
+    </insert>
+
+    <update id="updateDept" parameterType="SysDept">
+        update sys_dept
+        <set>
+            <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
+            <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
+            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
+            <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
+            <if test="leader != null">leader = #{leader},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="email != null">email = #{email},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+            update_time = sysdate()
+        </set>
+        where dept_id = #{deptId}
+    </update>
+
+    <update id="updateDeptChildren" parameterType="java.util.List">
+        update sys_dept set ancestors =
+        <foreach collection="depts" item="item" index="index"
+                 separator=" " open="case dept_id" close="end">
+            when #{item.deptId} then #{item.ancestors}
+        </foreach>
+        where dept_id in
+        <foreach collection="depts" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item.deptId}
         </foreach>
-	</update>
-	
-	<delete id="deleteDeptById" parameterType="Long">
+    </update>
+
+    <update id="updateDeptStatusNormal" parameterType="Long">
+        update sys_dept set status = '0' where dept_id in
+        <foreach collection="array" item="deptId" open="(" separator="," close=")">
+            #{deptId}
+        </foreach>
+    </update>
+
+    <delete id="deleteDeptById" parameterType="Long">
 		update sys_dept set del_flag = '2' where dept_id = #{deptId}
 	</delete>
 

+ 6 - 0
ruixuan-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -109,6 +109,12 @@
         <include refid="selectRoleVo"/>
         where r.role_key=#{roleKey} limit 1
     </select>
+    <select id="getRoleBYUserId" resultType="java.lang.String" parameterType="java.lang.Long">
+       select  t2.role_key  from sys_user_role t1
+        left join  sys_role t2
+        on t1.role_id = t2.role_id
+        where  t1.user_id = #{userId};
+    </select>
 
     <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
         insert into sys_role(