完善菜单按钮权限

This commit is contained in:
RuoYi 2018-03-03 16:34:14 +08:00
parent b828e7206f
commit ab230a3e32
10 changed files with 96 additions and 118 deletions

View File

@ -49,8 +49,8 @@ create table sys_user (
-- ----------------------------
-- 初始化-用户信息表数据
-- ----------------------------
insert into sys_user values('1', '1', 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '172eee54aa664e9dd0536b063796e54e', '', 0, '维护中', '2018-01-01');
insert into sys_user values('2', '1', 'ry', '若依', 'ry@163.com', '15288888888', '2f59d63eddd54f3977d6fe25aec8b2bc', '', 1, '锁定中', '2018-01-01');
insert into sys_user values('1', '1', 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '172eee54aa664e9dd0536b063796e54e', '', 0, '维护中', '2018-03-01');
insert into sys_user values('2', '1', 'ry', '若依', 'ry@163.com', '15288888888', '2f59d63eddd54f3977d6fe25aec8b2bc', '', 1, '锁定中', '2018-03-01');
@ -73,8 +73,8 @@ create table sys_role (
-- ----------------------------
-- 初始化-角色信息表数据
-- ----------------------------
insert into sys_role values('1', '管理员', 'admin', 0, '2018-01-01', '', 'system', '管理员');
insert into sys_role values('2', '普通角色', 'common', 0, '2018-01-01', '', 'system', '普通角色');
insert into sys_role values('1', '管理员', 'admin', 0, '2018-03-01', '', 'system', '管理员');
insert into sys_role values('2', '普通角色', 'common', 0, '2018-03-01', '', 'system', '普通角色');
@ -103,34 +103,25 @@ create table sys_menu (
-- 初始化-菜单信息表数据
-- ----------------------------
-- 一级菜单
insert into sys_menu values('1', '系统管理', '0', '1', '#', 'M', '0', '#', 'fa fa-gear', '2018-01-01', '', 'admin', '系统管理目录');
insert into sys_menu values('2', '系统监控', '0', '2', '#', 'M', '0', '#', 'fa fa-video-camera', '2018-01-01', '', 'admin', '系统监控目录');
insert into sys_menu values('1', '系统管理', '0', '1', '#', 'M', '0', '#', 'fa fa-gear', '2018-03-01', '', 'admin', '系统管理目录');
insert into sys_menu values('2', '系统监控', '0', '2', '#', 'M', '0', '#', 'fa fa-video-camera', '2018-03-01', '', 'admin', '系统监控目录');
-- 二级菜单
insert into sys_menu values('3', '用户管理', '1', '1', '/system/user/userList', 'C', '0', 'system:user:list', '#', '2018-01-01', '', 'admin', '用户管理菜单');
insert into sys_menu values('4', '角色管理', '1', '2', '/system/role/roleList', 'C', '0', 'system:role:list', '#', '2018-01-01', '', 'admin', '角色管理菜单');
insert into sys_menu values('5', '菜单管理', '1', '3', '/system/menu/menuList', 'C', '0', 'system:menu:list', '#', '2018-01-01', '', 'admin', '菜单管理菜单');
insert into sys_menu values('6', '部门管理', '1', '3', '/system/dept/deptList', 'C', '0', 'system:dept:list', '#', '2018-01-01', '', 'admin', '部门管理菜单');
insert into sys_menu values('7', '操作日志', '2', '1', '/monitor/operlog', 'C', '0', 'monitor:operlog', '#', '2018-01-01', '', 'admin', '操作日志菜单');
insert into sys_menu values('8', '登录日志', '2', '2', '/monitor/logininfor', 'C', '0', 'monitor:logininfor', '#', '2018-01-01', '', 'admin', '登录日志菜单');
insert into sys_menu values('9', '在线用户', '2', '3', '/monitor/online', 'C', '0', 'monitor:online', '#', '2018-01-01', '', 'admin', '在线用户菜单');
insert into sys_menu values('10', '数据监控', '2', '4', '/monitor/druid/index.html', 'C', '0', 'monitor:druid', '#', '2018-01-01', '', 'admin', '数据监控菜单');
--- 三级用户按钮
insert into sys_menu values('11', '用户新增', '3', '1', '/system/user/add', 'F', '0', 'sys:user:add', '#', '2018-01-01', '', 'admin', '用户管理新增按钮');
insert into sys_menu values('12', '用户修改', '3', '2', '/system/user/update', 'F', '0', 'sys:user:update', '#', '2018-01-01', '', 'admin', '用户管理修改按钮');
insert into sys_menu values('13', '用户删除', '3', '3', '/system/user/delete', 'F', '0', 'sys:user:delete', '#', '2018-01-01', '', 'admin', '用户管理删除按钮');
insert into sys_menu values('14', '用户查询', '3', '4', '/system/user/select', 'F', '0', 'sys:user:select', '#', '2018-01-01', '', 'admin', '用户管理查询按钮');
insert into sys_menu values('15', '密码修改', '3', '5', '/system/user/pwdUpdate', 'F', '0', 'sys:user:pwdUpdate', '#', '2018-01-01', '', 'admin', '用户密码修改按钮');
--- 三级角色按钮
insert into sys_menu values('16', '角色新增', '4', '1', '/system/role/add', 'F', '0', 'sys:role:add', '#', '2018-01-01', '', 'admin', '角色管理新增按钮');
insert into sys_menu values('17', '角色修改', '4', '2', '/system/role/update', 'F', '0', 'sys:role:update', '#', '2018-01-01', '', 'admin', '角色管理修改按钮');
insert into sys_menu values('18', '角色删除', '4', '3', '/system/role/delete', 'F', '0', 'sys:role:delete', '#', '2018-01-01', '', 'admin', '角色管理删除按钮');
insert into sys_menu values('19', '角色查询', '4', '4', '/system/role/select', 'F', '0', 'sys:role:select', '#', '2018-01-01', '', 'admin', '角色管理查询按钮');
insert into sys_menu values('20', '角色授权', '4', '5', '/system/role/auth', 'F', '0', 'sys:role:auth', '#', '2018-01-01', '', 'admin', '角色管理授权按钮');
--- 三级菜单按钮
insert into sys_menu values('21', '菜单新增', '5', '1', '/system/menu/add', 'F', '0', 'sys:menu:add', '#', '2018-01-01', '', 'admin', '菜单管理新增按钮');
insert into sys_menu values('22', '菜单修改', '5', '2', '/system/menu/update', 'F', '0', 'sys:menu:update', '#', '2018-01-01', '', 'admin', '菜单管理修改按钮');
insert into sys_menu values('23', '菜单删除', '5', '3', '/system/menu/delete', 'F', '0', 'sys:menu:delete', '#', '2018-01-01', '', 'admin', '菜单管理删除按钮');
insert into sys_menu values('24', '菜单查询', '5', '4', '/system/menu/select', 'F', '0', 'sys:menu:select', '#', '2018-01-01', '', 'system', '菜单管理查询按钮');
insert into sys_menu values('3', '用户管理', '1', '1', '/system/user/userList', 'C', '0', 'system:user:view', '#', '2018-03-01', '', 'admin', '用户管理菜单');
insert into sys_menu values('4', '角色管理', '1', '2', '/system/role/roleList', 'C', '0', 'system:role:view', '#', '2018-03-01', '', 'admin', '角色管理菜单');
insert into sys_menu values('5', '菜单管理', '1', '3', '/system/menu/menuList', 'C', '0', 'system:menu:view', '#', '2018-03-01', '', 'admin', '菜单管理菜单');
insert into sys_menu values('6', '部门管理', '1', '3', '/system/dept/deptList', 'C', '0', 'system:dept:view', '#', '2018-03-01', '', 'admin', '部门管理菜单');
insert into sys_menu values('7', '操作日志', '2', '1', '/monitor/operlog', 'C', '0', 'monitor:operlog:view', '#', '2018-03-01', '', 'admin', '操作日志菜单');
insert into sys_menu values('8', '登录日志', '2', '2', '/monitor/logininfor', 'C', '0', 'monitor:logininfor:view', '#', '2018-03-01', '', 'admin', '登录日志菜单');
insert into sys_menu values('9', '在线用户', '2', '3', '/monitor/online', 'C', '0', 'monitor:online:view', '#', '2018-03-01', '', 'admin', '在线用户菜单');
insert into sys_menu values('10', '数据监控', '2', '4', '/monitor/data', 'C', '0', 'monitor:data:xxxx', '#', '2018-03-01', '', 'admin', '数据监控菜单');
-- 操作日志按钮
insert into sys_menu values('11', '批量删除', '7', '1', '/monitor/operlog/batchRemove', 'F', '0', 'monitor:operlog:batchRemove', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('12', '详细信息', '7', '2', '/monitor/operlog/detail', 'F', '0', 'monitor:operlog:detail', '#', '2018-03-01', '', 'admin', '');
-- 登录日志按钮
insert into sys_menu values('13', '批量删除', '8', '1', '/monitor/logininfor/batchRemove', 'F', '0', 'monitor:logininfor:batchRemove', '#', '2018-03-01', '', 'admin', '');
-- 在线用户按钮
insert into sys_menu values('14', '批量强退', '9', '1', '/monitor/online/batchForceLogout', 'F', '0', 'monitor:online:batchForceLogout', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('15', '单条强退', '9', '2', '/monitor/online/forceLogout', 'F', '0', 'monitor:online:forceLogout', '#', '2018-03-01', '', 'admin', '');
-- ----------------------------
-- 5、用户和角色关联表 用户N-1角色
@ -173,6 +164,11 @@ insert into sys_role_menu values ('1', '7');
insert into sys_role_menu values ('1', '8');
insert into sys_role_menu values ('1', '9');
insert into sys_role_menu values ('1', '10');
insert into sys_role_menu values ('1', '11');
insert into sys_role_menu values ('1', '12');
insert into sys_role_menu values ('1', '13');
insert into sys_role_menu values ('1', '14');
insert into sys_role_menu values ('1', '15');
-- ----------------------------
-- 7、操作日志记录
@ -195,7 +191,7 @@ create table sys_oper_log (
primary key (oper_id)
) engine=innodb auto_increment=100 default charset=utf8;
insert into sys_oper_log values(1, '监控管理', '在线用户-强退用户', 'com.ruoyi.project.monitor.online.controller.UserOnlineController()', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-01-01');
insert into sys_oper_log values(1, '监控管理', '在线用户-强退用户', 'com.ruoyi.project.monitor.online.controller.UserOnlineController()', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-03-01');
-- ----------------------------
-- 8、数据字典表
@ -249,7 +245,7 @@ create table sys_logininfor (
primary key (info_id)
) engine=innodb auto_increment=100 default charset=utf8;
insert into sys_logininfor values(1, 'admin', '127.0.0.1', 'Chrome 45', 'Windows 7', 0, '登录成功' ,'2018-01-01');
insert into sys_logininfor values(1, 'admin', '127.0.0.1', 'Chrome 45', 'Windows 7', 0, '登录成功' ,'2018-03-01');
-- ----------------------------
-- 10、在线用户记录

View File

@ -21,7 +21,7 @@ public class DefaultExceptionHandler
public JSON handleAuthorizationException(AuthorizationException e)
{
log.error(e.getMessage(), e);
return JSON.error("未授权");
return JSON.error("您没有数据的权限,请联系管理员添加");
}
@ExceptionHandler(Exception.class)

View File

@ -0,0 +1,26 @@
package com.ruoyi.project.monitor.druid;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.framework.web.controller.BaseController;
/**
* druid 监控
*
* @author ruoyi
*/
@Controller
@RequestMapping("/monitor/data")
public class DruidController extends BaseController
{
private String prefix = "/monitor/druid";
@RequiresPermissions("monitor:data:view")
@GetMapping()
public String logininfor()
{
return "redirect:" + prefix + "/index";
}
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.project.monitor.logininfor.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,12 +32,14 @@ public class LogininforController extends BaseController
@Autowired
private ILogininforService logininforService;
@RequiresPermissions("monitor:logininfor:view")
@GetMapping()
public String logininfor()
{
return prefix + "/logininfor";
}
@RequiresPermissions("monitor:logininfor:view")
@GetMapping("/list")
@ResponseBody
public TableDataInfo list()
@ -46,6 +50,7 @@ public class LogininforController extends BaseController
return tableDataInfo;
}
@RequiresPermissions("monitor:logininfor:batchRemove")
@Log(title = "监控管理", action = "登录日志-批量删除")
@PostMapping("/batchRemove")
@ResponseBody

View File

@ -2,6 +2,7 @@ package com.ruoyi.project.monitor.online.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@ -38,12 +39,14 @@ public class UserOnlineController extends BaseController
@Autowired
private OnlineSessionDAO onlineSessionDAO;
@RequiresPermissions("monitor:online:view")
@GetMapping()
public String online()
{
return prefix + "/online";
}
@RequiresPermissions("monitor:online:view")
@GetMapping("/list")
@ResponseBody
public TableDataInfo list()
@ -54,6 +57,7 @@ public class UserOnlineController extends BaseController
return tableDataInfo;
}
@RequiresPermissions("monitor:online:batchForceLogout")
@Log(title = "监控管理", action = "在线用户-批量强退用户")
@PostMapping("/batchForceLogout")
@ResponseBody
@ -78,6 +82,7 @@ public class UserOnlineController extends BaseController
return JSON.ok();
}
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "监控管理", action = "在线用户-强退用户")
@RequestMapping("/forceLogout/{sessionId}")
@ResponseBody

View File

@ -2,6 +2,7 @@ package com.ruoyi.project.monitor.operlog.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -34,12 +35,14 @@ public class OperlogController extends BaseController
@Autowired
private IOperLogService operLogService;
@RequiresPermissions("monitor:operlog:view")
@GetMapping()
public String logininfor()
{
return prefix + "/operlog";
}
@RequiresPermissions("monitor:operlog:view")
@GetMapping("/list")
@ResponseBody
public TableDataInfo list()
@ -50,6 +53,7 @@ public class OperlogController extends BaseController
return tableDataInfo;
}
@RequiresPermissions("monitor:operlog:batchRemove")
@Log(title = "监控管理", action = "操作日志-批量删除")
@PostMapping("/batchRemove")
@ResponseBody
@ -63,8 +67,9 @@ public class OperlogController extends BaseController
return JSON.error();
}
@GetMapping("/view/{operId}")
String edit(@PathVariable("operId") Long deptId, Model model)
@RequiresPermissions("monitor:operlog:detail")
@GetMapping("/detail/{operId}")
public String detail(@PathVariable("operId") Long deptId, Model model)
{
OperLog operLog = operLogService.selectOperLogById(deptId);
model.addAttribute("operLog", operLog);

View File

@ -47,17 +47,14 @@ web_status = {
};
//对jquery的ajax方法再次封装
_ajax = function(url, data, success, type, contentType) {
success = success ||
function(data) {};
data = data || {};
_ajax = function(url, data, type) {
var config = {
url: url,
type: type,
dataType: "json",
data: data,
success: function(result) {
success(simpleSuccess(result));
simpleSuccess(result);
}
};
$.ajax(config)
@ -66,19 +63,10 @@ _ajax = function(url, data, success, type, contentType) {
/** 返回结果处理 */
function simpleSuccess(result) {
if (result.code == web_status.SUCCESS) {
if (result['msg']) {
layer.msg(result.msg, { icon: 1, time: 1000 });
}
//刷新
if (result['refresh']) {
refresh();
return;
}
return result;
} else {
if (result.msg != null) {
layer.alert(result.msg, { icon: 2, title: "系统提示" });
}
}
return null;
}

View File

@ -6,8 +6,7 @@ $(function() {
},
{
field: 'infoId',
// 列字段名
title: '访问编号' // 列标题
title: '访问编号'
},
{
field: 'loginName',
@ -45,6 +44,7 @@ $(function() {
initTable(columns, url);
});
// 批量删除
function batchRemove() {
var rows = getIdSelections("infoId");
if (rows.length == 0) {
@ -52,18 +52,6 @@ function batchRemove() {
return;
}
layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){
$.ajax({
type: 'POST',
data: { "ids": rows },
url: prefix + '/batchRemove',
success: function(r) {
if (r.code == 0) {
layer.msg(r.msg, { icon: 1, time: 1000 });
refresh();
} else {
layer.alert(r.msg, {icon: 2, title:"系统提示"});
}
}
});
_ajax(prefix + '/batchRemove', { "ids": rows }, "post");
});
}

View File

@ -6,8 +6,7 @@ $(function() {
},
{
field: 'sessionId',
// 列字段名
title: '会话编号' // 列标题
title: '会话编号'
},
{
field: 'loginName',
@ -53,32 +52,22 @@ $(function() {
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var d = '<a class="btn btn-warning btn-sm" href="#" title="删除" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-remove"></i></a> ';
return d;
var msg = '<a class="btn btn-warning btn-sm" href="#" title="强退" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-remove"></i></a> ';
return msg;
}
}];
var url = prefix + "/list";
initTable(columns, url);
});
// 单条强退
function forceLogout(id) {
layer.confirm("确定要强制选中用户下线吗?",{icon: 3, title:'提示'},function(index){
$.ajax({
url: prefix + "/forceLogout/" + id,
type: "post",
data: { 'id': id },
success: function(r) {
if (r.code == 0) {
layer.msg(r.msg, { icon: 1, time: 1000 });
refresh();
} else {
layer.alert(r.msg, {icon: 2, title:"系统提示"});
}
}
});
_ajax(prefix + "/forceLogout/" + id, { 'id': id }, "post");
})
}
// 批量强退
function batchForceLogout() {
var rows = getIdSelections("sessionId");
if (rows.length == 0) {
@ -86,18 +75,6 @@ function batchForceLogout() {
return;
}
layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){
$.ajax({
type: 'POST',
data: { "ids": rows },
url: prefix + '/batchForceLogout',
success: function(r) {
if (r.code == 0) {
layer.msg(r.msg, { icon: 1, time: 1000 });
refresh();
} else {
layer.alert(r.msg, {icon: 2, title:"系统提示"});
}
}
});
_ajax(prefix + '/batchForceLogout', { "ids": rows }, "post");
});
}

View File

@ -6,8 +6,7 @@ $(function() {
},
{
field: 'operId',
// 列字段名
title: '日志编号' // 列标题
title: '日志编号'
},
{
field: 'title',
@ -49,8 +48,8 @@ $(function() {
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var d = '<a class="btn btn-warning btn-sm" href="#" title="详细" onclick="view(\'' + row.operId + '\')"><i class="fa fa-search"></i></a> ';
return d;
var msg = '<a class="btn btn-warning btn-sm" href="#" title="详细信息" onclick="detail(\'' + row.operId + '\')"><i class="fa fa-search"></i></a> ';
return msg;
}
}];
var url = prefix + "/list";
@ -58,11 +57,12 @@ $(function() {
});
/*操作日志-详细*/
function view(id) {
var url = prefix + '/view/' + id;
function detail(id) {
var url = prefix + '/detail/' + id;
layer_show("操作日志详细", url, '800', '500');
}
// 批量删除
function batchRemove() {
var rows = getIdSelections("operId");
if (rows.length == 0) {
@ -70,18 +70,6 @@ function batchRemove() {
return;
}
layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){
$.ajax({
type: 'POST',
data: { "ids": rows },
url: prefix + '/batchRemove',
success: function(r) {
if (r.code == 0) {
layer.msg(r.msg, { icon: 1, time: 1000 });
refresh();
} else {
layer.alert(r.msg, {icon: 2, title:"系统提示"});
}
}
});
_ajax(prefix + '/batchRemove', { "ids": rows }, "post");
});
}