Ver código fonte

添加查询数据权限方法

gao.qiang 2 anos atrás
pai
commit
0bbee4c7ee

+ 7 - 0
base-system/src/main/java/com/ozs/system/mapper/SysMenuMapper.java

@@ -125,4 +125,11 @@ public interface SysMenuMapper extends JoinBaseMapper<SysMenu> {
      * @return 结果
      */
     public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId);
+
+    /**
+     * 根据角色ID查询数据权限
+     * @param roleId
+     * @return
+     */
+    List<Long> selectMenu(@Param("roleId")Long roleId);
 }

+ 8 - 0
base-system/src/main/java/com/ozs/system/service/ISysMenuService.java

@@ -63,6 +63,14 @@ public interface ISysMenuService extends JoinIService<SysMenu> {
      */
     public List<Long> selectMenuListByRoleId(Long roleId);
 
+    /**
+     * 根据角色ID查询菜单树信息
+     *
+     * @param roleId 角色ID
+     * @return 选中菜单列表
+     */
+    public List<Long> selectMenu(Long roleId);
+
     /**
      * 构建前端路由所需要的菜单
      *

+ 5 - 0
base-system/src/main/java/com/ozs/system/service/impl/SysMenuServiceImpl.java

@@ -140,6 +140,11 @@ public class SysMenuServiceImpl extends JoinServiceImpl<SysMenuMapper, SysMenu>
         return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
     }
 
+    @Override
+    public List<Long> selectMenu(Long roleId) {
+        return menuMapper.selectMenu(roleId);
+    }
+
     /**
      * 构建前端路由所需要的菜单
      *

+ 7 - 1
base-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -125,7 +125,7 @@
 				 left join sys_user_role ur on rm.role_id = ur.role_id
 				 left join sys_role r on r.role_id = ur.role_id
 		where m.status = '1'
-		  and r.status = '0'
+		  and r.status = '1'
 		  and ur.user_id = #{userId}
 	</select>
 
@@ -150,6 +150,12 @@
 		<include refid="selectMenuVo"/>
 		where menu_name=#{menuName} and parent_id = #{parentId} limit 1
 	</select>
+	<select id="selectMenu" parameterType="Long" resultType="Long">
+		select distinct m.menu_id from sys_menu m
+		join sys_role_menu rm on m.menu_id = rm.menu_id 
+		join sys_role ro on rm.role_id = ro.role_id
+        where ro.role_id=#{roleId}
+	</select>
 
 	<update id="updateMenu" parameterType="SysMenu">
 		update sys_menu

+ 1 - 1
base-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             r.status, r.del_flag, r.create_time, r.remark
         from sys_role r
 	        left join sys_user_role ur on ur.role_id = r.role_id
-	        left join sys_user u on u.user_id = ur.user_id
+	        left join sys_user u on u.id = ur.user_id
 	        left join sys_dept d on u.dept_id = d.dept_id
     </sql>