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
cbbee0fa
Commit
cbbee0fa
authored
Sep 27, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限菜单刷本地缓存
parent
9ebfee33
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
31 deletions
+26
-31
LoginController.java
...ava/com/gic/operation/web/controller/LoginController.java
+26
-31
No files found.
gic-platform-operation-web/src/main/java/com/gic/operation/web/controller/LoginController.java
View file @
cbbee0fa
package
com
.
gic
.
operation
.
web
.
controller
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -58,6 +58,8 @@ public class LoginController {
@Autowired
private
MarketUserApiService
marketUserApiService
;
private
static
final
String
MENU_LOCAL_CACHE_KEY
=
"auth:menu:list:all"
;
/**
* 商户绑定服务市场
...
...
@@ -153,35 +155,15 @@ public class LoginController {
enterpriseDTO
.
getVersionCode
());
if
(
menuResult
.
isSuccess
())
{
List
<
MenuDTO
>
menuList
=
menuResult
.
getResult
();
List
<
MenuInfo
>
menuInfoList
=
EntityUtil
.
changeEntityListNew
(
MenuInfo
.
class
,
menuList
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
16
);
if
(
CollectionUtils
.
isNotEmpty
(
menuInfoList
))
{
for
(
MenuInfo
menuDTO
:
menuInfoList
)
{
if
(
StringUtils
.
isBlank
(
menuDTO
.
getMenuUrl
()))
{
continue
;
}
map
.
put
(
menuDTO
.
getMenuUrl
(),
menuDTO
);
}
}
//查询全部的操作模块
Map
<
String
,
MenuInfo
>
moduleMap
=
new
HashMap
<>(
16
);
ServiceResponse
<
List
<
MenuDTO
>>
allGicMenu
=
menuApiService
.
getAllMenuNotTree
(
enterpriseDTO
.
getVersionCode
());
if
(
allGicMenu
.
isSuccess
())
{
List
<
MenuDTO
>
temp
=
allGicMenu
.
getResult
();
List
<
MenuInfo
>
tempMenuInfoList
=
EntityUtil
.
changeEntityListNew
(
MenuInfo
.
class
,
temp
);
if
(
CollectionUtils
.
isNotEmpty
(
tempMenuInfoList
))
{
for
(
MenuInfo
menuDTO
:
tempMenuInfoList
)
{
if
(
StringUtils
.
isBlank
(
menuDTO
.
getMenuUrl
()))
{
continue
;
}
moduleMap
.
put
(
menuDTO
.
getProjectUrlForWeb
()
+
menuDTO
.
getMenuUrl
(),
menuDTO
);
}
}
userDetail
.
setMenuInfoList
(
tempMenuInfoList
);
Set
<
Integer
>
menuIdSet
=
new
HashSet
<>(
2
);
if
(
CollectionUtils
.
isNotEmpty
(
menuList
))
{
menuIdSet
=
menuList
.
stream
().
filter
(
e
->
StringUtils
.
isNotBlank
(
e
.
getMenuUrl
()))
.
map
(
e
->
e
.
getMenuId
()).
collect
(
Collectors
.
toSet
());
}
//塞值
userDetail
.
setMenuUrlMap
(
map
);
userDetail
.
setModuleUrlMap
(
moduleMap
);
//塞用户权限菜单值
userDetail
.
setMenuIdSet
(
menuIdSet
);
//塞本地缓存
setAllMenuToLocaleCache
();
}
}
//塞缓存
...
...
@@ -194,4 +176,17 @@ public class LoginController {
}
return
RestResponse
.
success
();
}
/**
* gic平台的菜单数据塞本地缓存
*/
private
void
setAllMenuToLocaleCache
()
{
ServiceResponse
<
List
<
MenuDTO
>>
response
=
menuApiService
.
getAllMenu
();
if
(
response
.
isSuccess
())
{
List
<
MenuDTO
>
list
=
response
.
getResult
();
//gic平台的菜单数据塞本地缓存
RedisUtil
.
delLocalCache
(
MENU_LOCAL_CACHE_KEY
);
RedisUtil
.
setLocalCache
(
MENU_LOCAL_CACHE_KEY
,
EntityUtil
.
changeEntityListNew
(
MenuInfo
.
class
,
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