Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-platform-enterprise
Commits
ebdac7f0
Commit
ebdac7f0
authored
Jan 14, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限菜单查询方式调整:一开始只查询第一层
parent
de27f588
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
6 deletions
+62
-6
MenuController.java
...java/com/gic/operation/web/controller/MenuController.java
+62
-6
No files found.
gic-platform-operation-web/src/main/java/com/gic/operation/web/controller/MenuController.java
View file @
ebdac7f0
package
com
.
gic
.
operation
.
web
.
controller
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
com.gic.auth.qo.MenuOperationItemListQO
;
import
com.gic.open.api.dto.ServePropDTO
;
...
...
@@ -119,6 +116,11 @@ public class MenuController {
@RequestMapping
(
"/list-menu-tree"
)
public
RestResponse
listMenuTree
(
MenuListQO
params
)
{
LOGGER
.
info
(
"菜单列表查询参数:{}"
,
JSON
.
toJSONString
(
params
));
int
parentMenuId
=
MenuLevelConstants
.
FIRST_LEVEL_PARENT_ID
;
//逐级展开的方式,所以需要传ID,如果不传,默认查询第一层级,即level = 1
if
(
params
.
getMenuId
()
==
null
)
{
params
.
setLevel
(
1
);
}
if
(
params
.
getIsGIC
()
!=
null
&&
params
.
getIsGIC
()
==
MenuProjectConstants
.
APP_PROJECT_CODE
)
{
//如果是查询app应用类别,必须实时更新最新应用数据
params
.
setNeedUpdateAppMenu
(
true
);
...
...
@@ -126,7 +128,7 @@ public class MenuController {
ServiceResponse
<
List
<
MenuDTO
>>
result
=
menuApiService
.
listMenuTree
(
params
);
if
(
result
.
isSuccess
())
{
if
(
StringUtils
.
isBlank
(
params
.
getSearch
()))
{
return
RestResponse
.
success
(
changeListToTree
(
MenuLevelConstants
.
FIRST_LEVEL_PARENT_ID
,
result
.
getResult
()));
return
RestResponse
.
success
(
addAuthItemSignAndChildrenSignToList
(
parentMenuId
,
result
.
getResult
()));
}
else
{
return
ResultControllerUtils
.
commonResult
(
result
);
}
...
...
@@ -309,7 +311,7 @@ public class MenuController {
if
(
list
!=
null
)
{
for
(
int
j
=
0
,
length
=
list
.
size
();
j
<
length
;
j
++)
{
MenuDTO
menuDTO
=
list
.
get
(
j
);
if
(
storeGroupId
==
menuDTO
.
getParentId
())
{
if
(
storeGroupId
==
menuDTO
.
getParentId
()
&&
menuDTO
.
getLevel
()
==
length
)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>(
16
);
data
.
put
(
"menuId"
,
menuDTO
.
getMenuId
());
data
.
put
(
"menuName"
,
menuDTO
.
getMenuName
());
...
...
@@ -347,6 +349,60 @@ public class MenuController {
return
result
;
}
/**
* 是权限项标识/是否有子菜单
* @param storeGroupId
* @param list
* @return
*/
public
List
<
Map
<
String
,
Object
>>
addAuthItemSignAndChildrenSignToList
(
int
storeGroupId
,
List
<
MenuDTO
>
list
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
if
(
list
!=
null
)
{
List
<
Integer
>
parentMenuIdList
=
new
ArrayList
<>(
list
.
size
());
for
(
MenuDTO
menuDTO
:
list
)
{
parentMenuIdList
.
add
(
menuDTO
.
getMenuId
());
}
Set
<
String
>
authItemMap
=
new
HashSet
<>(
16
);
Set
<
String
>
childrenMap
=
new
HashSet
<>(
16
);
ServiceResponse
<
List
<
MenuDTO
>>
listByParentIdListResult
=
menuApiService
.
listByParentMenuIdList
(
parentMenuIdList
);
if
(
listByParentIdListResult
.
isSuccess
())
{
List
<
MenuDTO
>
listByParentIdList
=
listByParentIdListResult
.
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
listByParentIdList
))
{
for
(
MenuDTO
child
:
listByParentIdList
)
{
int
menuType
=
child
.
getMenuType
().
intValue
();
if
(
menuType
==
MenuTypeEnum
.
ROLE
.
getCode
())
{
authItemMap
.
add
(
child
.
getParentId
().
toString
());
}
else
if
(
menuType
==
MenuTypeEnum
.
PAGE
.
getCode
())
{
childrenMap
.
add
(
child
.
getParentId
().
toString
());
}
}
}
}
for
(
int
j
=
0
,
length
=
list
.
size
();
j
<
length
;
j
++)
{
MenuDTO
menuDTO
=
list
.
get
(
j
);
if
(
storeGroupId
==
menuDTO
.
getParentId
()
&&
menuDTO
.
getLevel
()
==
length
)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>(
16
);
data
.
put
(
"menuId"
,
menuDTO
.
getMenuId
());
data
.
put
(
"menuName"
,
menuDTO
.
getMenuName
());
data
.
put
(
"menuUrl"
,
menuDTO
.
getMenuUrl
());
data
.
put
(
"project"
,
menuDTO
.
getProject
());
data
.
put
(
"sort"
,
menuDTO
.
getSort
());
data
.
put
(
"menuCode"
,
menuDTO
.
getMenuCode
());
data
.
put
(
"parentCode"
,
menuDTO
.
getParentCode
());
data
.
put
(
"parentId"
,
menuDTO
.
getParentId
());
data
.
put
(
"menuVersionName"
,
menuDTO
.
getMenuVersionName
());
data
.
put
(
"seq"
,
j
+
1
);
//是否拥有子集,用于 展开按钮的显示
data
.
put
(
"children"
,
childrenMap
.
contains
(
menuDTO
.
getMenuId
().
toString
()));
//是否有权限项
data
.
put
(
"hasAuthItem"
,
authItemMap
.
contains
(
menuDTO
.
getMenuId
().
toString
()));
result
.
add
(
data
);
}
}
}
return
result
;
}
public
static
List
<
Map
<
String
,
Object
>>
changePageListToTree
(
int
storeGroupId
,
List
<
MenuDTO
>
list
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
if
(
list
!=
null
)
{
...
...
Write
Preview
Markdown
is supported
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