优化多角色数据权限匹配规则
parent
47bd3c4c10
commit
c95cb70af3
@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('部门树选择')" />
|
||||||
|
<th:block th:include="include :: ztree-css" />
|
||||||
|
</head>
|
||||||
|
<style>
|
||||||
|
body{height:auto;font-family: "Microsoft YaHei";}
|
||||||
|
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
|
||||||
|
</style>
|
||||||
|
<body class="hold-transition box box-main">
|
||||||
|
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
|
||||||
|
<input id="treeName" name="treeName" type="hidden" th:value="${dept.deptName}"/>
|
||||||
|
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
|
||||||
|
<label id="btnShow" title="显示搜索" style="display:none;">︾</label>
|
||||||
|
<label id="btnHide" title="隐藏搜索">︽</label>
|
||||||
|
</div>
|
||||||
|
<div class="treeSearchInput" id="search">
|
||||||
|
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
|
||||||
|
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
|
||||||
|
</div>
|
||||||
|
<div class="treeExpandCollapse">
|
||||||
|
<a href="#" onclick="$.tree.expand()">展开</a> /
|
||||||
|
<a href="#" onclick="$.tree.collapse()">折叠</a>
|
||||||
|
</div>
|
||||||
|
<div id="tree" class="ztree treeselect"></div>
|
||||||
|
</div>
|
||||||
|
<th:block th:include="include :: footer" />
|
||||||
|
<th:block th:include="include :: ztree-js" />
|
||||||
|
<script th:inline="javascript">
|
||||||
|
var prefix = ctx + "system/user"
|
||||||
|
var deptId = [[${deptId}]];
|
||||||
|
$(function() {
|
||||||
|
var url = prefix + "/deptTreeData";
|
||||||
|
var options = {
|
||||||
|
url: url,
|
||||||
|
expandLevel: 2,
|
||||||
|
onClick : zOnClick
|
||||||
|
};
|
||||||
|
$.tree.init(options);
|
||||||
|
});
|
||||||
|
|
||||||
|
function zOnClick(event, treeId, treeNode) {
|
||||||
|
var treeId = treeNode.id;
|
||||||
|
var treeName = treeNode.name;
|
||||||
|
$("#treeId").val(treeId);
|
||||||
|
$("#treeName").val(treeName);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.ruoyi.common.core.context;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限信息
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class PermissionContextHolder
|
||||||
|
{
|
||||||
|
private static final String PERMISSION_CONTEXT_ATTRIBUTES = "PERMISSION_CONTEXT";
|
||||||
|
|
||||||
|
public static void setContext(String permission)
|
||||||
|
{
|
||||||
|
RequestContextHolder.currentRequestAttributes().setAttribute(PERMISSION_CONTEXT_ATTRIBUTES, permission,
|
||||||
|
RequestAttributes.SCOPE_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getContext()
|
||||||
|
{
|
||||||
|
return Convert.toStr(RequestContextHolder.currentRequestAttributes().getAttribute(PERMISSION_CONTEXT_ATTRIBUTES,
|
||||||
|
RequestAttributes.SCOPE_REQUEST));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue