Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
d68ac05b
提交
d68ac05b
编写于
5月 13, 2020
作者:
lzlhxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
权限表数据多项选择视图使用自定义eltree展示菜单及权限数据
上级
3d8fb398
变更
4
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
689 行增加
和
23 行删除
+689
-23
sys-permissionmpickup-view.less
...ys-permissionmpickup-view/sys-permissionmpickup-view.less
+50
-2
sys-permissionmpickup-view.vue
...sys-permissionmpickup-view/sys-permissionmpickup-view.vue
+234
-18
UAACoreService.java
...va/cn/ibizlab/core/extensions/service/UAACoreService.java
+385
-3
UAACoreResource.java
.../java/cn/ibizlab/api/rest/extensions/UAACoreResource.java
+20
-0
未找到文件。
app_web/src/pages/uaa/sys-permissionmpickup-view/sys-permissionmpickup-view.less
浏览文件 @
d68ac05b
...
@@ -66,3 +66,51 @@
...
@@ -66,3 +66,51 @@
height: 64px;
height: 64px;
}
}
}
}
.tree-right-menu {
.ivu-divider-horizontal {
width: calc(100% - 32px);
min-width: calc(100% - 32px);
margin: 0 auto;
}
.ivu-dropdown-item {
position: relative;
padding-left: 32px;
> i {
position: absolute;
left: 16px;
top: 10px;
}
.ivu-icon-ios-arrow-forward {
left: initial;
right: 4px;
}
}
.ivu-dropdown {
.ivu-select-dropdown {
margin: 0;
}
}
}
.text{
font-weight: 700;color: #303133;font-size: 15px;margin-left:10px;margin-top:20px;
}
.col{
display: inline-block;
width: 400px;
}
.search{
width:200px;margin-left:20px;margin-top:30px;margin-bottom:20px;
}
.save{
margin-top:30px;margin-bottom:20px;margin-left:40px;
}
.roll{
height:680px;overflow:hidden;overflow-x: hidden;overflow-y: auto;
}
.tre{
margin-left:20px;
}
// this is less
app_web/src/pages/uaa/sys-permissionmpickup-view/sys-permissionmpickup-view.vue
浏览文件 @
d68ac05b
<
script
lang=
'tsx'
>
<
template
>
import
{
Component
}
from
'vue-property-decorator'
;
<div
class=
"view-container dempickupview sys-permissionmpickup-view"
>
import
SYS_PERMISSIONMPickupViewBase
from
'./sys-permissionmpickup-view-base.vue'
;
<card
class=
'view-card view-no-caption view-no-toolbar'
:dis-hover=
"true"
:padding=
"0"
:bordered=
"false"
>
<div
class=
"content-container pickup-view"
>
<div
class=
"translate-contant"
>
<!--菜单分配-->
<div
class=
"center"
:style=
"
{width : '50%' }">
<context-menu-container
class=
'design-tree-container'
>
<div
>
<div
class=
"text"
>
菜单分配
</div>
<div
class=
"roll"
>
<el-tree
class=
"tre"
:data=
"this.CDdata"
ref=
"CDtree"
show-checkbox
node-key=
"id"
:default-expanded-keys=
"this.CDdataexpandedKeys"
highlight-current
:props=
"this.defaultProps"
@
check-change=
"handleCheckChange"
>
</el-tree>
</div>
</div>
</context-menu-container>
</div>
<!--权限分配-->
<div
class=
"center"
:style=
"
{width : '50%' }">
<context-menu-container
class=
'design-tree-container'
>
<div
>
<div
class=
"text"
>
权限分配
</div>
<div
class=
"roll"
>
<el-tree
class=
"tre"
:data=
"this.QXdata"
ref=
"QXtree"
show-checkbox
node-key=
"id"
:default-expanded-keys=
"this.QXdataexpandedKeys"
highlight-current
:props=
"this.defaultProps"
@
check-change=
"handleCheckChange"
>
</el-tree>
</div>
</div>
</context-menu-container>
</div>
</div>
<!--操作按钮-->
<card
:dis-hover=
"true"
:bordered=
"false"
class=
"footer"
>
<row
:style=
"
{ textAlign: 'right' }">
<i-button
type=
"primary"
:disabled=
"this.selectData.length > 0 ? false : true"
@
click=
"onClickOk"
>
{{
this
.
containerModel
.
view_okbtn
.
text
}}
</i-button>
<i-button
@
click=
"onClickCancel"
>
{{
this
.
containerModel
.
view_cancelbtn
.
text
}}
</i-button>
</row>
</card>
</div>
</card>
</div>
</
template
>
import
view_pickupviewpanel
from
'@widgets/sys-permission/mpickup-viewpickupviewpanel-pickupviewpanel/mpickup-viewpickupviewpanel-pickupviewpanel.vue'
;
<
script
lang=
'tsx'
>
@
Component
({
import
{
Vue
,
Component
,
Emit
,
Prop
,
Watch
,
Provide
}
from
'vue-property-decorator'
;
import
view_pickupviewpanel
from
'@widgets/sys-permission/mpickup-viewpickupviewpanel-pickupviewpanel/mpickup-viewpickupviewpanel-pickupviewpanel.vue'
;
import
{
Subject
,
Subscription
}
from
"rxjs"
;
import
{
Util
}
from
"@/utils"
;
import
{
ControlInterface
}
from
'@/interface/control'
;
import
ContextMenuContainer
from
"@components/context-menu-container/context-menu-container.vue"
;
@
Component
({
components
:
{
components
:
{
ContextMenuContainer
,
view_pickupviewpanel
,
view_pickupviewpanel
,
},
},
beforeRouteEnter
:
(
to
:
any
,
from
:
any
,
next
:
any
)
=>
{
beforeRouteEnter
:
(
to
:
any
,
from
:
any
,
next
:
any
)
=>
{
...
@@ -12,8 +78,158 @@ import view_pickupviewpanel from '@widgets/sys-permission/mpickup-viewpickupview
...
@@ -12,8 +78,158 @@ import view_pickupviewpanel from '@widgets/sys-permission/mpickup-viewpickupview
vm
.
$store
.
commit
(
'addCurPageViewtag'
,
{
fullPath
:
to
.
fullPath
,
viewtag
:
vm
.
viewtag
});
vm
.
$store
.
commit
(
'addCurPageViewtag'
,
{
fullPath
:
to
.
fullPath
,
viewtag
:
vm
.
viewtag
});
});
});
},
},
})
})
export
default
class
SYS_PERMISSIONMPickupView
extends
SYS_PERMISSIONMPickupViewBase
{
export
default
class
SYS_PERMISSIONMPickupView
extends
Vue
{
/*菜单分配数据*/
protected
CDdata
:
any
=
[];
/*菜单分配数据默认展开节点*/
protected
CDdataexpandedKeys
:
any
=
[];
/*权限分配数据*/
protected
QXdata
:
any
=
[];
/*权限分配数据默认展开节点*/
protected
QXdataexpandedKeys
:
any
=
[];
/**
* 树显示说明:子树为节点对象的children,节点标签为节点对象的label
*/
protected
defaultProps
:
any
=
{
children
:
'children'
,
label
:
'label'
}
/**
* 选中数据
*/
protected
selectData
:
any
=
{};
/**
* 视图选中数据
*/
public
viewSelections
:
any
[]
=
[];
/**
* 父数据
*/
protected
parentData
:
any
=
{};
/**
* 父数据主键
*/
protected
srfparentkey
:
any
;
/**
* vue 创建
*/
public
created
(){
const
_this
:
any
=
this
;
// 获取父数据
if
(
_this
.
$attrs
&&
_this
.
$attrs
.
viewdata
)
{
_this
.
parentData
=
JSON
.
parse
(
_this
.
$attrs
.
viewdata
);
}
if
(
_this
.
parentData
&&
_this
.
parentData
.
srfparentkey
){
_this
.
srfparentkey
=
_this
.
parentData
.
srfparentkey
;
console
.
log
(
"父主键:"
+
_this
.
srfparentkey
);
}
}
/**
* vue 挂载
*/
public
mounted
(){
this
.
initTree
();
}
/**
* 初始化树
*/
private
initTree
(){
const
_this
=
this
;
// get全部菜单和权限的请求路径
const
url
=
`uaa/sys_role/custom/getallMenuAndPermission`
;
this
.
$http
.
get
(
url
).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!==
200
)
{
this
.
$Notice
.
error
({
title
:
'错误'
,
desc
:
response
.
message
});
return
;
}
else
{
// 给树赋值,数据结构在后台已经按照eltree格式化
_this
.
CDdata
=
response
.
data
[
0
];
_this
.
QXdata
=
response
.
data
[
1
];
// 树视图默认展开一级节点
if
(
_this
.
CDdata
&&
_this
.
CDdata
.
length
>
0
){
_this
.
CDdata
.
forEach
((
item
:
any
,
index
:
any
)
=>
{
_this
.
CDdataexpandedKeys
.
push
(
item
[
index
].
id
);
})
}
if
(
_this
.
QXdata
&&
_this
.
QXdata
.
length
>
0
){
_this
.
QXdata
.
forEach
((
item
:
any
,
index
:
any
)
=>
{
_this
.
QXdataexpandedKeys
.
push
(
item
[
index
]);
})
}
}
}).
catch
((
e
)
=>
{
console
.
log
(
e
);
});
}
/**
* 处理选中节点
*/
protected
handleCheckChange
()
{
console
.
log
(
"SYS_PERMISSIONMPickupView执行了handleCheckChange"
)
// 两棵树
const
CDtree
:
any
=
this
.
$refs
.
CDtree
;
const
QXtree
:
any
=
this
.
$refs
.
QXtree
;
// 获取选中状态的节点
const
arr
=
CDtree
.
getCheckedNodes
().
concat
(
QXtree
.
getCheckedNodes
());
// console.group("选中的node:" + arr);
this
.
selectData
=
arr
;
}
/**
* 容器模型
*/
public
containerModel
:
any
=
{
view_okbtn
:
{
name
:
'okbtn'
,
type
:
'button'
,
text
:
'确定'
,
disabled
:
true
},
view_cancelbtn
:
{
name
:
'cancelbtn'
,
type
:
'button'
,
text
:
'取消'
,
disabled
:
false
},
};
/**
* 确定
*/
public
onClickOk
():
void
{
// 处理选中的数据
if
(
this
.
selectData
&&
this
.
selectData
.
length
>
0
){
this
.
selectData
.
forEach
((
item
:
any
)
=>
{
let
_itemTemp
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
item
));
let
_item
:
any
=
{};
if
(
!
_itemTemp
.
children
){
// 是末节点则为库中存在的权限数据,添加到viewSelections
_item
.
srfdataaccaction
=
_itemTemp
.
id
;
_item
.
srfkey
=
_itemTemp
.
id
;
_item
.
sys_permission
=
_itemTemp
.
id
;
_item
.
sys_permissionid
=
_itemTemp
.
id
;
_item
.
srfmajortext
=
_itemTemp
.
label
;
_item
.
sys_permissionname
=
_itemTemp
.
label
;
Object
.
assign
(
_item
,
{
_select
:
false
})
this
.
viewSelections
.
push
(
_item
);
}
});
}
}
// 交给viewdataschange进行后续保存进库操作
this
.
$emit
(
'viewdataschange'
,
this
.
viewSelections
);
this
.
$emit
(
'close'
,
null
);
}
/**
* 取消
*/
public
onClickCancel
():
void
{
this
.
$emit
(
'close'
,
null
);
}
}
</
script
>
</
script
>
<
style
lang=
'less'
>
@import './sys-permissionmpickup-view.less';
</
style
>
\ No newline at end of file
ibzuaa-core/src/main/java/cn/ibizlab/core/extensions/service/UAACoreService.java
浏览文件 @
d68ac05b
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.service.ISYS_PERMISSIONService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
@Service
@Service
@Slf4j
@Slf4j
public
class
UAACoreService
public
class
UAACoreService
{
{
@Autowired
private
ISYS_PERMISSIONService
isys_permissionService
;
/**
* 获取用户菜单
*
* @return
*/
public
JSONArray
getAppMenu
()
{
// 用户所在系统id,R7的AuthenticationUser中已经没有systemid了
// String systemid= AuthenticationUser.getAuthenticationUser().getSystemid();
String
systemid
=
null
;
StringBuilder
nPermissionSQL
=
new
StringBuilder
();
nPermissionSQL
.
append
(
"SELECT "
);
nPermissionSQL
.
append
(
" t.SYS_PERMISSIONID as sys_permissionid, "
);
nPermissionSQL
.
append
(
" t.SYS_PERMISSIONNAME as sys_permissionname, "
);
nPermissionSQL
.
append
(
" t1.PERMISSIONID as permissionid, "
);
nPermissionSQL
.
append
(
" t1.P_PERMISSIONID as p_permissionid, "
);
nPermissionSQL
.
append
(
" t1.PSAPPID as psappid, "
);
nPermissionSQL
.
append
(
" t1.PSAPPNAME as psappname, "
);
nPermissionSQL
.
append
(
" t1.PSAPPMENUID as psappmenuid, "
);
nPermissionSQL
.
append
(
" t1.PSAPPMENUNAME as psappmenuname, "
);
nPermissionSQL
.
append
(
" t1.PSSYSTEMID as systemid "
);
nPermissionSQL
.
append
(
" FROM IBZPERMISSION t"
);
nPermissionSQL
.
append
(
" INNER JOIN IBZPSAPPMENUITEM t1 ON t.SYS_PERMISSIONID = t1.SYS_PSAPPMENUITEMID and t.enable =1"
);
StringBuilder
permissionSQL
=
new
StringBuilder
();
permissionSQL
.
append
(
"SELECT "
);
permissionSQL
.
append
(
" t.SYS_PERMISSIONID as sys_permissionid,"
);
permissionSQL
.
append
(
" t.SYS_PERMISSIONNAME as sys_permissionname,"
);
permissionSQL
.
append
(
" t1.PERMISSIONID as permissionid,"
);
permissionSQL
.
append
(
" t1.P_PERMISSIONID as p_permissionid,"
);
permissionSQL
.
append
(
" t1.PSAPPID as psappid,"
);
permissionSQL
.
append
(
" t1.PSAPPNAME as psappname,"
);
permissionSQL
.
append
(
" t1.PSAPPMENUID as psappmenuid,"
);
permissionSQL
.
append
(
" t1.PSAPPMENUNAME as psappmenuname,"
);
permissionSQL
.
append
(
" t1.PSSYSTEMID as systemid"
);
permissionSQL
.
append
(
" FROM IBZPERMISSION t"
);
permissionSQL
.
append
(
" INNER JOIN IBZPSAPPMENUITEM t1 ON t.SYS_PERMISSIONID = t1.SYS_PSAPPMENUITEMID and t.systemid='"
+
systemid
+
"' and t.enable =1"
);
List
<
JSONObject
>
permissions
;
if
(
StringUtils
.
isEmpty
(
systemid
))
{
permissions
=
isys_permissionService
.
select
(
nPermissionSQL
.
toString
(),
null
);
}
else
{
permissions
=
isys_permissionService
.
select
(
permissionSQL
.
toString
(),
null
);
}
JSONArray
treeNode
=
new
JSONArray
();
if
(
permissions
.
size
()
>
0
)
{
treeNode
=
this
.
transferAppMenuToELTree
(
permissions
);
}
return
treeNode
;
}
/**
* 用于将资源表中菜单数据转换成饿了么树格式数据
*
* @param
* @return
*/
private
JSONArray
transferAppMenuToELTree
(
List
<
JSONObject
>
appMenuDatas
)
{
Map
<
String
,
String
>
appKeyMap
=
new
HashMap
<>();
Map
<
String
,
String
>
appMenuKeyMap
=
new
HashMap
<>();
JSONObject
groupByMenuObj
=
this
.
groupByAppMenu
(
appMenuDatas
,
appKeyMap
,
appMenuKeyMap
);
//将数据库数据进行分组
JSONArray
elTreeObj
=
transferAppMenuToELTree
(
groupByMenuObj
,
appKeyMap
,
appMenuKeyMap
);
//将分组后的数据转换成饿了么树格式数据
return
elTreeObj
;
}
/**
* 将数据库中的菜单数据进行分组
*
* @param dbdata
* @return
*/
private
JSONObject
groupByAppMenu
(
List
<
JSONObject
>
dbdata
,
Map
<
String
,
String
>
appKeyMap
,
Map
<
String
,
String
>
appMenuKeyMap
)
{
JSONObject
permission_app
=
new
JSONObject
();
//顶级模块数据
for
(
JSONObject
obj
:
dbdata
)
{
String
str_app
=
String
.
format
(
"IBIZAPP-%s"
,
obj
.
get
(
"psappid"
));
String
str_appName
=
String
.
format
(
"%s"
,
obj
.
get
(
"psappname"
));
String
str_appMenu
=
String
.
format
(
"IBIZMENU-%s"
,
obj
.
get
(
"psappmenuid"
));
String
str_appMenuName
=
String
.
format
(
"%s"
,
obj
.
get
(
"psappmenuname"
));
String
systemId
=
String
.
format
(
"%s"
,
obj
.
get
(
"systemid"
));
String
sys_permissionId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s"
,
systemId
,
obj
.
get
(
"permissionid"
)).
getBytes
());
String
p_sys_permissionId
=
""
;
if
(!
StringUtils
.
isEmpty
(
obj
.
get
(
"p_permissionid"
)))
{
p_sys_permissionId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s"
,
systemId
,
obj
.
get
(
"p_permissionid"
)).
getBytes
());
}
JSONObject
cur_app
=
new
JSONObject
();
JSONArray
cur_app_menu
=
new
JSONArray
();
if
(
permission_app
.
containsKey
(
str_app
))
//合并前端应用
cur_app
=
permission_app
.
getJSONObject
(
str_app
);
if
(
cur_app
.
containsKey
(
str_appMenu
))
//合并菜单
cur_app_menu
=
cur_app
.
getJSONArray
(
str_appMenu
);
JSONObject
permission
=
new
JSONObject
();
permission
.
put
(
"id"
,
sys_permissionId
);
permission
.
put
(
"pid"
,
p_sys_permissionId
);
permission
.
put
(
"label"
,
obj
.
get
(
"sys_permissionname"
));
cur_app_menu
.
add
(
permission
);
cur_app
.
put
(
str_appMenu
,
cur_app_menu
);
permission_app
.
put
(
str_app
,
cur_app
);
//应用名称映射表
if
(!
appKeyMap
.
containsKey
(
str_app
))
appKeyMap
.
put
(
str_app
,
str_appName
);
//应用菜单名称映射表
if
(!
appMenuKeyMap
.
containsKey
(
str_appMenu
))
appMenuKeyMap
.
put
(
str_appMenu
,
str_appMenuName
);
}
return
permission_app
;
}
/**
* 将以分组的树节点转换成饿了么格式的树
*
* @param sysApps
* @return
*/
private
JSONArray
transferAppMenuToELTree
(
JSONObject
sysApps
,
Map
<
String
,
String
>
appKeyMap
,
Map
<
String
,
String
>
appMenuKeyMap
)
{
JSONArray
appMenuArr
=
new
JSONArray
();
Set
<
String
>
sysAppkeys
=
sysApps
.
keySet
();
for
(
String
sysAppkey
:
sysAppkeys
)
{
Object
appMenu
=
sysApps
.
get
(
sysAppkey
);
if
(
appMenu
instanceof
JSONObject
)
{
JSONArray
appChildMenuItemArr
=
transferAppMenuToELTree
((
JSONObject
)
appMenu
,
appKeyMap
,
appMenuKeyMap
);
//递归遍历输出下级节点信息
JSONObject
appMenuItem
=
new
JSONObject
();
appMenuItem
.
put
(
"id"
,
sysAppkey
);
sysAppkey
=
praseLabel
(
sysAppkey
,
appKeyMap
,
appMenuKeyMap
);
appMenuItem
.
put
(
"label"
,
sysAppkey
);
appMenuItem
.
put
(
"children"
,
appChildMenuItemArr
);
appMenuArr
.
add
(
appMenuItem
);
}
else
{
if
(
appMenu
instanceof
JSONArray
)
{
JSONArray
appMenuItemArr
=
sysApps
.
getJSONArray
(
sysAppkey
);
JSONObject
appMenuItem
=
new
JSONObject
();
appMenuItem
.
put
(
"id"
,
sysAppkey
);
sysAppkey
=
praseLabel
(
sysAppkey
,
appKeyMap
,
appMenuKeyMap
);
appMenuItem
.
put
(
"label"
,
sysAppkey
);
appMenuItem
.
put
(
"children"
,
getTreesData
(
appMenuItemArr
,
""
));
appMenuArr
.
add
(
appMenuItem
);
}
}
}
return
appMenuArr
;
}
/**
* 递归遍历树节点
*
* @param PermissionNodes
* @param parentId
* @return
*/
private
JSONArray
getTreesData
(
JSONArray
PermissionNodes
,
Object
parentId
)
{
JSONArray
treeDatas
=
new
JSONArray
();
for
(
int
a
=
0
;
a
<
PermissionNodes
.
size
();
a
++)
{
JSONObject
PermissionNode
=
PermissionNodes
.
getJSONObject
(
a
);
String
p_permissionId
=
PermissionNode
.
getString
(
"pid"
);
if
(
StringUtils
.
isEmpty
(
p_permissionId
))
{
p_permissionId
=
""
;
}
if
(
parentId
.
equals
(
p_permissionId
))
{
JSONArray
childCodeItem
=
getTreesData
(
PermissionNodes
,
PermissionNode
.
getString
(
"id"
));
if
(
childCodeItem
.
size
()
>
0
)
{
PermissionNode
.
put
(
"children"
,
childCodeItem
);
}
treeDatas
.
add
(
PermissionNode
);
}
}
return
treeDatas
;
}
/**
* 拿到带有IBIZAPP-或IBIZMENU-标识的key把标记移除
*/
private
String
praseLabel
(
String
key
,
Map
<
String
,
String
>
appKeyMap
,
Map
<
String
,
String
>
appMenuKeyMap
)
{
if
(
key
.
startsWith
(
"IBIZAPP-"
))
{
if
(
appKeyMap
.
containsKey
(
key
))
{
key
=
appKeyMap
.
get
(
key
);
}
key
=
key
.
replace
(
"IBIZAPP-"
,
""
);
}
if
(
key
.
startsWith
(
"IBIZMENU-"
))
{
if
(
appMenuKeyMap
.
containsKey
(
key
))
{
key
=
appMenuKeyMap
.
get
(
key
);
}
key
=
key
.
replace
(
"IBIZMENU-"
,
""
);
}
return
key
;
}
/**
* 获取数据操作标识
*
* @return
*/
public
JSONArray
getDEOppriv
()
{
JSONArray
treeNode
=
new
JSONArray
();
StringBuilder
permissionsSql
=
new
StringBuilder
();
permissionsSql
.
append
(
"select "
);
permissionsSql
.
append
(
" t.SYS_PERMISSIONID as sys_permissionid, "
);
permissionsSql
.
append
(
" t.SYS_PERMISSIONNAME as sys_permissionname, "
);
permissionsSql
.
append
(
" t1.PSSYSMODULEID as pssysmoduleid, "
);
permissionsSql
.
append
(
" t1.PSSYSMODULENAME as pssysmodulename, "
);
permissionsSql
.
append
(
" t1.PSDATAENTITYID as psdataentityid, "
);
permissionsSql
.
append
(
" t1.PSDATAENTITYNAME as psdataentityname, "
);
permissionsSql
.
append
(
" t1.Pssourceid as pssourceid, "
);
permissionsSql
.
append
(
" t1.Pssourcename as pssourcename,"
);
permissionsSql
.
append
(
" t1.PSDEDATARANGEID as psdedatarangeid, "
);
permissionsSql
.
append
(
" t1.PSDEDATARANGENAME as psdedatarangename,"
);
permissionsSql
.
append
(
" t1.PSSYSTEMID as systemid "
);
permissionsSql
.
append
(
" FROM IBZPERMISSION t"
);
permissionsSql
.
append
(
" INNER JOIN IBZPSDEOPPRIV t1 ON t.SYS_PERMISSIONID = t1.SYS_PSDEOPPRIVID"
);
List
<
JSONObject
>
permissions
=
isys_permissionService
.
select
(
permissionsSql
.
toString
(),
null
);
if
(
permissions
.
size
()
>
0
)
{
treeNode
=
this
.
transferDataCapabilityToELTree
(
permissions
);
}
return
treeNode
;
}
/**
* 用于将资源表中数据能力数据转换成饿了么树格式数据
*
* @param deCapabilityDatas
* @return
*/
public
JSONArray
transferDataCapabilityToELTree
(
List
<
JSONObject
>
deCapabilityDatas
)
{
Map
<
String
,
String
>
opprivTreeNameMap
=
new
HashMap
<>();
JSONObject
groupByMenuObj
=
groupByDataCapability
(
deCapabilityDatas
,
opprivTreeNameMap
);
//将数据库数据进行分组
JSONArray
elTreeObj
=
transferDataCapabilityToELTree
(
groupByMenuObj
,
opprivTreeNameMap
);
//将分组后的数据转换成饿了么树格式数据
return
elTreeObj
;
}
/**
* 将数据库中的数据能力数据进行分组
*
* @param deCapabilityDatas
* @return
*/
private
JSONObject
groupByDataCapability
(
List
<
JSONObject
>
deCapabilityDatas
,
Map
<
String
,
String
>
opprivTreeNameMap
)
{
JSONObject
root_system
=
new
JSONObject
();
//顶级系统数据
JSONObject
permission_moudle
=
new
JSONObject
();
//次级模块数据
for
(
JSONObject
obj
:
deCapabilityDatas
)
{
JSONObject
jobj
=
new
JSONObject
();
jobj
.
putAll
(
obj
);
String
str_systemid
=
jobj
.
getString
(
"systemid"
);
String
str_moudle
=
jobj
.
getString
(
"pssysmoduleid"
);
String
str_moudle_name
=
jobj
.
getString
(
"pssysmodulename"
);
String
str_entity
=
jobj
.
getString
(
"psdataentityid"
);
String
str_entity_name
=
jobj
.
getString
(
"psdataentityname"
);
String
str_dataset
=
jobj
.
getString
(
"pssourceid"
);
String
str_dataset_name
=
jobj
.
getString
(
"pssourcename"
);
String
str_datarange
=
jobj
.
getString
(
"psdedatarangeid"
);
String
str_datarange_name
=
jobj
.
getString
(
"psdedatarangename"
);
String
str_permissionname
=
jobj
.
getString
(
"sys_permissionname"
);
String
str_permissionid
=
jobj
.
getString
(
"sys_permissionid"
);
JSONObject
cur_system
=
new
JSONObject
();
JSONObject
cur_moudle
=
new
JSONObject
();
JSONObject
cur_entity
=
new
JSONObject
();
JSONObject
cur_dataset
=
new
JSONObject
();
JSONArray
cur_data_range
=
new
JSONArray
();
if
(
root_system
.
containsKey
(
str_systemid
))
// 系统合并
cur_system
=
root_system
.
getJSONObject
(
str_systemid
);
if
(
permission_moudle
.
containsKey
(
str_moudle
))
//模块合并
cur_moudle
=
permission_moudle
.
getJSONObject
(
str_moudle
);
if
(
cur_moudle
.
containsKey
(
str_entity
))
//实体合并
cur_entity
=
cur_moudle
.
getJSONObject
(
str_entity
);
if
(
cur_entity
.
containsKey
(
str_dataset
))
//数据集合并
cur_dataset
=
cur_entity
.
getJSONObject
(
str_dataset
);
if
(
cur_dataset
.
containsKey
(
str_datarange
))
//数据范围合并
cur_data_range
=
cur_dataset
.
getJSONArray
(
str_datarange
);
JSONObject
permission
=
new
JSONObject
();
permission
.
put
(
"id"
,
str_permissionid
);
permission
.
put
(
"label"
,
str_permissionname
);
cur_data_range
.
add
(
permission
);
cur_dataset
.
put
(
str_datarange
,
cur_data_range
);
cur_entity
.
put
(
str_dataset
,
cur_dataset
);
cur_moudle
.
put
(
str_entity
,
cur_entity
);
permission_moudle
.
put
(
str_moudle
,
cur_moudle
);
//构造树节点名称集合
if
(!
opprivTreeNameMap
.
containsKey
(
str_systemid
))
{
opprivTreeNameMap
.
put
(
str_systemid
,
"SYSTEM"
);
}
if
(!
opprivTreeNameMap
.
containsKey
(
str_moudle
))
{
opprivTreeNameMap
.
put
(
str_moudle
,
str_moudle_name
);
}
if
(!
opprivTreeNameMap
.
containsKey
(
str_entity
))
{
opprivTreeNameMap
.
put
(
str_entity
,
str_entity_name
);
}
if
(!
opprivTreeNameMap
.
containsKey
(
str_dataset
))
{
opprivTreeNameMap
.
put
(
str_dataset
,
str_dataset_name
);
}
if
(!
opprivTreeNameMap
.
containsKey
(
str_datarange_name
))
{
opprivTreeNameMap
.
put
(
str_datarange
,
str_datarange_name
);
}
}
return
permission_moudle
;
}
/**
* 权限树递归
*
* @param childNode
* @return
*/
private
JSONArray
transferDataCapabilityToELTree
(
JSONObject
childNode
,
Map
<
String
,
String
>
opprivTreeNameMap
)
{
JSONArray
array
=
new
JSONArray
();
Set
<
String
>
keys
=
childNode
.
keySet
();
for
(
String
key
:
keys
)
{
Object
obj
=
childNode
.
get
(
key
);
if
(
obj
instanceof
JSONObject
)
{
JSONArray
childArr
=
transferDataCapabilityToELTree
(
childNode
.
getJSONObject
(
key
),
opprivTreeNameMap
);
//递归遍历输出下级节点信息
JSONObject
childNodeObj
=
new
JSONObject
();
childNodeObj
.
put
(
"id"
,
key
);
childNodeObj
.
put
(
"label"
,
opprivTreeNameMap
.
get
(
key
));
childNodeObj
.
put
(
"children"
,
childArr
);
array
.
add
(
childNodeObj
);
}
else
{
if
(
obj
instanceof
JSONArray
)
{
JSONArray
permissionArr
=
new
JSONArray
();
JSONArray
jsonArray
=
childNode
.
getJSONArray
(
key
);
for
(
int
a
=
0
;
a
<
jsonArray
.
size
();
a
++)
{
//最后一层
JSONObject
permissionObj
=
jsonArray
.
getJSONObject
(
a
);
JSONObject
transPermissionObj
=
new
JSONObject
();
transPermissionObj
.
put
(
"id"
,
permissionObj
.
getString
(
"id"
));
transPermissionObj
.
put
(
"label"
,
permissionObj
.
getString
(
"label"
));
permissionArr
.
add
(
transPermissionObj
);
}
JSONObject
childNodeObj
=
new
JSONObject
();
childNodeObj
.
put
(
"id"
,
key
);
childNodeObj
.
put
(
"label"
,
opprivTreeNameMap
.
get
(
key
));
childNodeObj
.
put
(
"children"
,
permissionArr
);
array
.
add
(
childNodeObj
);
}
}
}
return
array
;
}
}
}
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UAACoreResource.java
浏览文件 @
d68ac05b
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.extensions.service.UAACoreService
;
import
cn.ibizlab.core.extensions.service.UAACoreService
;
import
com.alibaba.fastjson.JSONArray
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
public
class
UAACoreResource
{
public
class
UAACoreResource
{
@Autowired
@Autowired
private
UAACoreService
uaaCoreService
;
private
UAACoreService
uaaCoreService
;
/**
* 获取全部权限列表或菜单列表
*
* @return
*/
@GetMapping
(
value
=
"/uaa/sys_role/custom/getallMenuAndPermission"
)
public
ResponseEntity
<
JSONArray
>
getAllPermission
()
{
JSONArray
treeNode
=
new
JSONArray
();
// 获取菜单
treeNode
.
add
(
uaaCoreService
.
getAppMenu
());
//获取数据能力
treeNode
.
add
(
uaaCoreService
.
getDEOppriv
());
return
ResponseEntity
.
ok
().
body
(
treeNode
);
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录