mirror of https://gitee.com/y_project/RuoYi.git
修改菜单权限显示问题
parent
91dd624048
commit
ff67062c7f
|
@ -46,7 +46,8 @@ public class SysMenuController extends BaseController
|
|||
@ResponseBody
|
||||
public List<SysMenu> list(SysMenu menu)
|
||||
{
|
||||
List<SysMenu> menuList = menuService.selectMenuList(menu);
|
||||
Long userId = ShiroUtils.getUserId();
|
||||
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,8 @@ public class SysMenuController extends BaseController
|
|||
@ResponseBody
|
||||
public List<Ztree> roleMenuTreeData(SysRole role)
|
||||
{
|
||||
List<Ztree> ztrees = menuService.roleMenuTreeData(role);
|
||||
Long userId = ShiroUtils.getUserId();
|
||||
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
|
||||
return ztrees;
|
||||
}
|
||||
|
||||
|
@ -165,9 +167,10 @@ public class SysMenuController extends BaseController
|
|||
*/
|
||||
@GetMapping("/menuTreeData")
|
||||
@ResponseBody
|
||||
public List<Ztree> menuTreeData(SysRole role)
|
||||
public List<Ztree> menuTreeData()
|
||||
{
|
||||
List<Ztree> ztrees = menuService.menuTreeData();
|
||||
Long userId = ShiroUtils.getUserId();
|
||||
List<Ztree> ztrees = menuService.menuTreeData(userId);
|
||||
return ztrees;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.ruoyi.quartz.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -40,16 +39,7 @@ public class SysJobServiceImpl implements ISysJobService
|
|||
List<SysJob> jobList = jobMapper.selectJobAll();
|
||||
for (SysJob job : jobList)
|
||||
{
|
||||
CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, job.getJobId());
|
||||
// 如果不存在,则创建
|
||||
if (cronTrigger == null)
|
||||
{
|
||||
ScheduleUtils.createScheduleJob(scheduler, job);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScheduleUtils.updateScheduleJob(scheduler, job);
|
||||
}
|
||||
ScheduleUtils.updateScheduleJob(scheduler, job);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,13 @@ public class ScheduleUtils
|
|||
// 放入参数,运行时的方法可以获取
|
||||
jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);
|
||||
|
||||
// 判断是否存在
|
||||
if (scheduler.checkExists(getJobKey(job.getJobId())))
|
||||
{
|
||||
// 防止创建时存在数据问题 先移除,然后在执行创建操作
|
||||
scheduler.deleteJob(getJobKey(job.getJobId()));
|
||||
}
|
||||
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
|
||||
// 暂停任务
|
||||
|
@ -106,22 +113,7 @@ public class ScheduleUtils
|
|||
*/
|
||||
public static void updateScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
JobKey jobKey = getJobKey(job.getJobId());
|
||||
|
||||
// 判断是否存在
|
||||
if (scheduler.checkExists(jobKey))
|
||||
{
|
||||
// 先移除,然后做更新操作
|
||||
scheduler.deleteJob(jobKey);
|
||||
}
|
||||
|
||||
createScheduleJob(scheduler, job);
|
||||
|
||||
// 暂停任务
|
||||
if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
|
||||
{
|
||||
pauseJob(scheduler, job.getJobId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,14 +17,22 @@ public interface SysMenuMapper
|
|||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuAll();
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuAllByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询系统正常显示菜单(不含按钮)
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuNormalAll();
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
|
@ -57,6 +65,14 @@ public interface SysMenuMapper
|
|||
*/
|
||||
public List<SysMenu> selectMenuList(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuListByUserId(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
*
|
||||
|
|
|
@ -27,16 +27,18 @@ public interface ISysMenuService
|
|||
* 查询系统菜单列表
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuList(SysMenu menu);
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId);
|
||||
|
||||
/**
|
||||
* 查询菜单集合
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 所有菜单信息
|
||||
*/
|
||||
public List<SysMenu> selectMenuAll();
|
||||
public List<SysMenu> selectMenuAll(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
|
@ -50,23 +52,26 @@ public interface ISysMenuService
|
|||
* 根据角色ID查询菜单
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Ztree> roleMenuTreeData(SysRole role);
|
||||
public List<Ztree> roleMenuTreeData(SysRole role, Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有菜单信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Ztree> menuTreeData();
|
||||
public List<Ztree> menuTreeData(Long userId);
|
||||
|
||||
/**
|
||||
* 查询系统所有权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Map<String, String> selectPermsAll();
|
||||
public Map<String, String> selectPermsAll(Long userId);
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
|
|
|
@ -65,9 +65,19 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* @return 所有菜单信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(SysMenu menu)
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
||||
{
|
||||
return menuMapper.selectMenuList(menu);
|
||||
List<SysMenu> menuList = null;
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,9 +86,18 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* @return 所有菜单信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuAll()
|
||||
public List<SysMenu> selectMenuAll(Long userId)
|
||||
{
|
||||
return menuMapper.selectMenuAll();
|
||||
List<SysMenu> menuList = null;
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
menuList = menuMapper.selectMenuAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
menuList = menuMapper.selectMenuAllByUserId(userId);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,11 +128,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Ztree> roleMenuTreeData(SysRole role)
|
||||
public List<Ztree> roleMenuTreeData(SysRole role, Long userId)
|
||||
{
|
||||
Long roleId = role.getRoleId();
|
||||
List<Ztree> ztrees = new ArrayList<Ztree>();
|
||||
List<SysMenu> menuList = menuMapper.selectMenuAll();
|
||||
List<SysMenu> menuList = selectMenuAll(userId);
|
||||
if (StringUtils.isNotNull(roleId))
|
||||
{
|
||||
List<String> roleMenuList = menuMapper.selectMenuTree(roleId);
|
||||
|
@ -132,9 +151,9 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Ztree> menuTreeData()
|
||||
public List<Ztree> menuTreeData(Long userId)
|
||||
{
|
||||
List<SysMenu> menuList = menuMapper.selectMenuAll();
|
||||
List<SysMenu> menuList = selectMenuAll(userId);
|
||||
List<Ztree> ztrees = initZtree(menuList);
|
||||
return ztrees;
|
||||
}
|
||||
|
@ -145,10 +164,10 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public LinkedHashMap<String, String> selectPermsAll()
|
||||
public LinkedHashMap<String, String> selectPermsAll(Long userId)
|
||||
{
|
||||
LinkedHashMap<String, String> section = new LinkedHashMap<>();
|
||||
List<SysMenu> permissions = menuMapper.selectMenuAll();
|
||||
List<SysMenu> permissions = selectMenuAll(userId);
|
||||
if (StringUtils.isNotEmpty(permissions))
|
||||
{
|
||||
for (SysMenu menu : permissions)
|
||||
|
|
|
@ -50,6 +50,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by parent_id, order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuAllByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
LEFT JOIN sys_role ro on ur.role_id = ro.role_id
|
||||
where ur.user_id = #{userId}
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
|
@ -78,7 +88,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
order by parent_id, order_num
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
LEFT JOIN sys_role ro on ur.role_id = ro.role_id
|
||||
where ur.user_id = #{params.userId}
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="visible != null and visible != ''">
|
||||
AND m.visible = #{visible}
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<delete id="deleteMenuById" parameterType="Long">
|
||||
delete from sys_menu where menu_id = #{menuId} or parent_id = #{menuId}
|
||||
</delete>
|
||||
|
|
Loading…
Reference in New Issue