Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
b55e6401
Commit
b55e6401
authored
Apr 10, 2020
by
季圣华
Browse files
优化角色分配权限里面的菜单树逻辑
parent
9710a325
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/FunctionsController.java
View file @
b55e6401
...
...
@@ -115,117 +115,45 @@ public class FunctionsController {
}
}
}
//筛选功能列表
for
(
Functions
functions
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"id"
,
functions
.
getId
());
item
.
put
(
"text"
,
functions
.
getName
());
//勾选判断1
Boolean
flag
=
false
;
try
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
functions
.
getId
().
toString
()
+
"]"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>设置角色对应的功能:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
}
if
(
flag
==
true
)
{
item
.
put
(
"checked"
,
true
);
}
//结束
List
<
Functions
>
dataList1
=
functionsService
.
findRoleFunctions
(
functions
.
getNumber
());
JSONArray
dataArray1
=
new
JSONArray
();
if
(
null
!=
dataList1
)
{
for
(
Functions
functions1
:
dataList1
)
{
item
.
put
(
"state"
,
"open"
);
//如果不为空,节点不展开
JSONObject
item1
=
new
JSONObject
();
item1
.
put
(
"id"
,
functions1
.
getId
());
item1
.
put
(
"text"
,
functions1
.
getName
());
//勾选判断2
//Boolean flag = false;
try
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
functions1
.
getId
().
toString
()
+
"]"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>设置角色对应的功能:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
}
if
(
flag
==
true
)
{
item1
.
put
(
"checked"
,
true
);
}
//结束
List
<
Functions
>
dataList2
=
functionsService
.
findRoleFunctions
(
functions1
.
getNumber
());
JSONArray
dataArray2
=
new
JSONArray
();
if
(
null
!=
dataList2
)
{
for
(
Functions
functions2
:
dataList2
)
{
item1
.
put
(
"state"
,
"closed"
);
//如果不为空,节点不展开
JSONObject
item2
=
new
JSONObject
();
item2
.
put
(
"id"
,
functions2
.
getId
());
item2
.
put
(
"text"
,
functions2
.
getName
());
//勾选判断3
//Boolean flag = false;
try
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
functions2
.
getId
().
toString
()
+
"]"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>设置角色对应的功能:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
}
if
(
flag
==
true
)
{
item2
.
put
(
"checked"
,
true
);
}
//结束
List
<
Functions
>
dataList3
=
functionsService
.
findRoleFunctions
(
functions2
.
getNumber
());
JSONArray
dataArray3
=
new
JSONArray
();
if
(
null
!=
dataList3
)
{
for
(
Functions
functions3
:
dataList3
)
{
item2
.
put
(
"state"
,
"closed"
);
//如果不为空,节点不展开
JSONObject
item3
=
new
JSONObject
();
item3
.
put
(
"id"
,
functions3
.
getId
());
item3
.
put
(
"text"
,
functions3
.
getName
());
//勾选判断4
//Boolean flag = false;
try
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
functions3
.
getId
().
toString
()
+
"]"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>设置角色对应的功能:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
}
if
(
flag
==
true
)
{
item3
.
put
(
"checked"
,
true
);
}
//结束
dataArray3
.
add
(
item3
);
item2
.
put
(
"children"
,
dataArray3
);
}
}
dataArray2
.
add
(
item2
);
item1
.
put
(
"children"
,
dataArray2
);
}
}
dataArray1
.
add
(
item1
);
item
.
put
(
"children"
,
dataArray1
);
}
}
dataArray
.
add
(
item
);
}
dataArray
=
getFunctionList
(
dataList
,
type
,
keyId
);
outer
.
put
(
"children"
,
dataArray
);
arr
.
add
(
outer
);
}
arr
.
add
(
outer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
arr
;
}
public
JSONArray
getFunctionList
(
List
<
Functions
>
dataList
,
String
type
,
String
keyId
)
throws
Exception
{
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
Functions
functions
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"id"
,
functions
.
getId
());
item
.
put
(
"text"
,
functions
.
getName
());
Boolean
flag
=
false
;
try
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
functions
.
getId
().
toString
()
+
"]"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>>>>>>>>设置角色对应的功能:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
}
if
(
flag
==
true
)
{
item
.
put
(
"checked"
,
true
);
}
List
<
Functions
>
funList
=
functionsService
.
findRoleFunctions
(
functions
.
getNumber
());
if
(
funList
.
size
()>
0
)
{
JSONArray
funArr
=
getFunctionList
(
funList
,
type
,
keyId
);
item
.
put
(
"children"
,
funArr
);
dataArray
.
add
(
item
);
}
else
{
dataArray
.
add
(
item
);
}
}
}
return
dataArray
;
}
/**
* 根据id列表查找功能信息
* @param functionsIds
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment