mirror of https://gitee.com/stylefeng/guns
Merge remote-tracking branch 'origin/group1-role'
# Conflicts: # src/main/java/cn/stylefeng/guns/modular/role/RoleViewController.javapull/65/head
commit
dd1f2fea3a
|
@ -60,4 +60,26 @@ public class RoleViewController {
|
|||
return "/modular/auth/role/role_edit_data_scope.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配接口界面
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 11:43
|
||||
*/
|
||||
@GetResource(name = "分配接口界面", path = "/view/role/assignApi")
|
||||
public String roleAssignApi() {
|
||||
return "/modular/auth/role/role_assign_api.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配菜单和按钮界面
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 11:45
|
||||
*/
|
||||
@GetResource(name = "分配菜单界面", path = "/view/role/assignMenuAndButtons")
|
||||
public String roleAssignMenuButton() {
|
||||
return "/modular/auth/role/role_assign_menu_button.html";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ spring:
|
|||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
|
||||
# 连接池大小根据实际情况调整
|
||||
max-active: 100
|
||||
|
|
|
@ -76,9 +76,9 @@ layui.use(['table', 'HttpRequest', 'func'], function () {
|
|||
*/
|
||||
Resource.openDetailDlg = function (data) {
|
||||
func.open({
|
||||
height: 500,
|
||||
height: 600,
|
||||
title: '资源详情',
|
||||
content: Feng.ctxPath + '/view/resource/detail?resourceId=' + data.resourceId,
|
||||
content: Feng.ctxPath + '/view/resource/detail?resourceCode=' + data.resourceCode,
|
||||
tableId: Resource.tableId
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* 详情对话框
|
||||
*/
|
||||
var ResourceInfoDlg = {
|
||||
data: {
|
||||
resourceParentId: "",
|
||||
resourceParentName: ""
|
||||
}
|
||||
};
|
||||
|
||||
layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'iconPicker'], function () {
|
||||
var $ = layui.jquery;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var form = layui.form;
|
||||
|
||||
//获取菜单信息
|
||||
var request = new HttpRequest(Feng.ctxPath + "/resource/getDetail?resourceCode=" + Feng.getUrlParam("resourceCode"), 'get');
|
||||
var resourceInfoResult = request.start();
|
||||
form.val('resourceForm', resourceInfoResult.data);
|
||||
});
|
|
@ -131,21 +131,32 @@ layui.use(['layer', 'form', 'table', 'admin', 'HttpRequest', 'func'], function (
|
|||
};
|
||||
|
||||
/**
|
||||
* 分配菜单
|
||||
* 分配菜单和按钮
|
||||
*
|
||||
* @param data 点击按钮时候的行数据
|
||||
*/
|
||||
Role.roleAssign = function (data) {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: '权限配置',
|
||||
area: ['300px', '450px'], //宽高
|
||||
fix: false,
|
||||
maxmin: true,
|
||||
content: Feng.ctxPath + '/role/role_assign/' + data.roleId,
|
||||
end: function () {
|
||||
table.reload(Role.tableId);
|
||||
}
|
||||
Role.assignMenu = function (data) {
|
||||
func.open({
|
||||
height: 650,
|
||||
width: 750,
|
||||
title: '分配菜单',
|
||||
content: Feng.ctxPath + "/view/role/assignMenuAndButtons?roleId=" + data.roleId,
|
||||
tableId: Role.tableId
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 分配接口
|
||||
*
|
||||
* @param data 点击按钮时候的行数据
|
||||
*/
|
||||
Role.assignApi = function (data) {
|
||||
func.open({
|
||||
height: 650,
|
||||
width: 550,
|
||||
title: '分配接口',
|
||||
content: Feng.ctxPath + "/view/role/assignApi?roleId=" + data.roleId,
|
||||
tableId: Role.tableId
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -187,8 +198,10 @@ layui.use(['layer', 'form', 'table', 'admin', 'HttpRequest', 'func'], function (
|
|||
Role.onEditDataScope(data);
|
||||
} else if (layEvent === 'delete') {
|
||||
Role.onDeleteRole(data);
|
||||
} else if (layEvent === 'roleAssign') {
|
||||
Role.roleAssign(data);
|
||||
} else if (layEvent === 'assignMenu') {
|
||||
Role.assignMenu(data);
|
||||
} else if (layEvent === 'assignApi') {
|
||||
Role.assignApi(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,35 +1,136 @@
|
|||
@layout("/layout/_container.html",{js:["/assets/modular/auth/resource/resource.js"]}){
|
||||
@layout("/layout/_container.html",{js:["/assets/modular/auth/resource/resource_detail.js"]}){
|
||||
|
||||
<div class="layui-body-header">
|
||||
<span class="layui-body-header-title">资源管理</span>
|
||||
</div>
|
||||
<form class="layui-form" id="resourceForm" lay-filter="resourceForm">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form toolbar">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<input id="resourceName" class="layui-input" type="text" placeholder="资源名称"/>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">应用标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="appCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input id="url" class="layui-input" type="text" placeholder="资源url"/>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="resourceCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="resourceName" placeholder="资源名称" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">项目编码</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="projectCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">控制器类名</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="className" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">方法名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="methodName" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源所属模块</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="modularCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">模块中文名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="modularName" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">初始化地址</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="ipAddress" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否视图类型</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="viewFlag" type="checkbox" lay-skin="switch" lay-filter="viewFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">请求路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="url" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">请求方法</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="httpMethod" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否需要登录</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="requiredLoginFlag" type="checkbox" lay-skin="switch" lay-filter="requiredLoginFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否需要鉴权</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="requiredPermissionFlag" type="checkbox" lay-skin="switch" lay-filter="requiredPermissionFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源添加日期</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="createTime" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">创建人</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="createUser" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-table" id="resourceTable" lay-filter="resourceTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group-bottom text-center" style="z-index: 200">
|
||||
<button type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog"> 关闭 </button>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
|
||||
</script>
|
||||
@}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@/* 加入contextPath属性和session超时的配置 */
|
||||
|
||||
<script type="text/javascript">
|
||||
var Feng = {
|
||||
ctxPath: "${ctxPath}",
|
||||
|
@ -42,25 +42,39 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
|
||||
layui.use(['ztree','ax'], function () {
|
||||
layui.use(['ztree', 'admin', 'HttpRequest'], function () {
|
||||
var $ = layui.$;
|
||||
var $ZTree = layui.ztree;
|
||||
var $ax = layui.ax;
|
||||
|
||||
var ZTreeDlg = {
|
||||
index: parent.layer.getFrameIndex(window.name)
|
||||
};
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var admin = layui.admin;
|
||||
|
||||
$("#saveButton").bind("click", function () {
|
||||
var ids = Feng.zTreeCheckedNodes("zTree");
|
||||
var ajax = new $ax(Feng.ctxPath + "/role/setAuthority", function (data) {
|
||||
Feng.success("分配角色成功!");
|
||||
parent.layer.close(ZTreeDlg.index);
|
||||
|
||||
var zTree = $.fn.zTree.getZTreeObj("zTree");
|
||||
var nodes = zTree.getCheckedNodes();
|
||||
var ids = [];
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
// 剔除掉不能被选择的节点(虚拟节点)
|
||||
if (nodes[i].resourceFlag) {
|
||||
ids.push(nodes[i].code);
|
||||
}
|
||||
}
|
||||
|
||||
var request = new HttpRequest(Feng.ctxPath + "/sysRole/grantResource", 'post', function (data) {
|
||||
Feng.success("分配接口成功!");
|
||||
|
||||
//传给上个页面,刷新table用
|
||||
admin.putTempData('formOk', true);
|
||||
|
||||
//关掉对话框
|
||||
admin.closeThisDialog();
|
||||
|
||||
}, function (data) {
|
||||
Feng.error("分配角色失败!" + data.responseJSON.message + "!");
|
||||
Feng.error("分配接口失败!" + data.message + "!");
|
||||
});
|
||||
ajax.set("ids", ids);
|
||||
ajax.set("roleId", "${roleId}");
|
||||
ajax.start();
|
||||
request.set("grantResourceList", ids);
|
||||
request.set("roleId", Feng.getUrlParam("roleId"));
|
||||
request.start(true);
|
||||
});
|
||||
|
||||
var setting = {
|
||||
|
@ -73,12 +87,19 @@
|
|||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
enable: true,
|
||||
idKey: "code",
|
||||
pIdKey: "parentCode",
|
||||
rootPId: "-1"
|
||||
},
|
||||
key: {
|
||||
checked: "checked",
|
||||
name: "nodeName"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ztree = new $ZTree("zTree", "/menu/menuTreeListByRoleId/${roleId}");
|
||||
var ztree = new $ZTree("zTree", "/resource/getLateralTree?roleId=" + Feng.getUrlParam("roleId"));
|
||||
ztree.setSettings(setting);
|
||||
ztree.init();
|
||||
});
|
||||
|
@ -88,3 +109,4 @@
|
|||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>${constants.getSystemName()}</title>
|
||||
<meta name="description" content="${constants.getSystemName()}">
|
||||
<meta name="author" content="stylefeng">
|
||||
|
||||
<link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
|
||||
<link href="${ctxPath}/assets/expand/plugins/ztree/zTreeStyle.css?v=${constants.getReleaseVersion()}" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="deptForm" class="layui-fluid">
|
||||
<div class="layui-row" style="margin-top:15px;background: #f2f7f8;padding: 20px;">
|
||||
<ul id="zTree" class="ztree"></ul>
|
||||
</div>
|
||||
<div class="layui-row" style="background: #CFD4D5;padding: 10px;">
|
||||
<div style="text-align: center;">
|
||||
<button class="layui-btn layui-btn-sm" id="saveButton">保存</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var Feng = {
|
||||
ctxPath: "${ctxPath}",
|
||||
version: '${constants.getReleaseVersion()}'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>
|
||||
|
||||
<!--其他插件js-->
|
||||
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/jquery/jquery-3.2.1.min.js?v=${constants.getReleaseVersion()}"></script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/ztree/jquery.ztree.all.min.js?v=${constants.getReleaseVersion()}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
layui.use(['ztree', 'admin', 'HttpRequest'], function () {
|
||||
var $ = layui.$;
|
||||
var $ZTree = layui.ztree;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var admin = layui.admin;
|
||||
|
||||
$("#saveButton").bind("click", function () {
|
||||
|
||||
var zTree = $.fn.zTree.getZTreeObj("zTree");
|
||||
var nodes = zTree.getCheckedNodes();
|
||||
var menuIds = [];
|
||||
var buttonList = [];
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
// 剔除掉不能被选择的节点(虚拟节点)
|
||||
if (nodes[i].menuFlag) {
|
||||
menuIds.push(nodes[i].id);
|
||||
} else {
|
||||
buttonList.push({
|
||||
"buttonId": nodes[i].id,
|
||||
"buttonCode": nodes[i].buttonCode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var request = new HttpRequest(Feng.ctxPath + "/sysRole/grantMenuAndButton", 'post', function (data) {
|
||||
Feng.success("分配成功!");
|
||||
|
||||
//传给上个页面,刷新table用
|
||||
admin.putTempData('formOk', true);
|
||||
|
||||
//关掉对话框
|
||||
admin.closeThisDialog();
|
||||
|
||||
}, function (data) {
|
||||
Feng.error("分配失败!" + data.message + "!");
|
||||
});
|
||||
request.set("grantMenuIdList", menuIds);
|
||||
request.set("grantMenuButtonIdList", buttonList);
|
||||
request.set("roleId", Feng.getUrlParam("roleId"));
|
||||
request.start(true);
|
||||
});
|
||||
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true,
|
||||
chkboxType: {
|
||||
"Y": "ps",
|
||||
"N": "ps"
|
||||
}
|
||||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: "id",
|
||||
pIdKey: "pid",
|
||||
rootPId: "-1"
|
||||
},
|
||||
key: {
|
||||
checked: "checked",
|
||||
name: "name"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ztree = new $ZTree("zTree", "/sysMenu/menuAndButtonTree?roleId=" + Feng.getUrlParam("roleId"));
|
||||
ztree.setSettings(setting);
|
||||
ztree.init();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue