Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-platform
Commits
0a3a3e78
Commit
0a3a3e78
authored
Sep 09, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加菜单资源配置
parent
26c85420
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
24 deletions
+31
-24
bill-manager/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
.../xhx/base/framework/interceptor/AuthTokenServiceImpl.java
+5
-5
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+0
-1
bill-manager/src/main/java/com/mortals/xhx/base/system/role/service/impl/RoleAuthServiceImpl.java
...hx/base/system/role/service/impl/RoleAuthServiceImpl.java
+26
-18
No files found.
bill-manager/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
View file @
0a3a3e78
...
...
@@ -123,11 +123,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
}
//更新resource 路径
String
menuUrlCode
=
cacheService
.
hget
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
String
.
class
);
if
(
ObjectUtils
.
isEmpty
(
menuUrlCode
))
{
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
userEntity
.
getId
());
menuUrlCode
=
MenuEncodeUtil
.
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
menuUrlCode
);
}
//
if (ObjectUtils.isEmpty(menuUrlCode)) {
//
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
//
menuUrlCode = MenuEncodeUtil.generateMenuUrlCode(urls);
//
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userEntity.getId().toString(), menuUrlCode);
//
}
userEntity
.
setMenuUrl
(
menuUrlCode
);
return
userEntity
;
}
...
...
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
0a3a3e78
...
...
@@ -69,7 +69,6 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
continue
;
}
urls
.
add
(
url
);
// url = url.replaceAll(",", ",");
}
return
urls
;
}
...
...
bill-manager/src/main/java/com/mortals/xhx/base/system/role/service/impl/RoleAuthServiceImpl.java
View file @
0a3a3e78
...
...
@@ -21,7 +21,9 @@ import com.mortals.xhx.base.system.resource.service.ResourceService;
import
com.mortals.xhx.base.system.role.dao.RoleAuthDao
;
import
com.mortals.xhx.base.system.role.model.RoleAuthEntity
;
import
com.mortals.xhx.base.system.role.model.RoleAuthQuery
;
import
com.mortals.xhx.base.system.role.model.RoleUserQuery
;
import
com.mortals.xhx.base.system.role.service.RoleAuthService
;
import
com.mortals.xhx.base.system.role.service.RoleUserService
;
import
com.mortals.xhx.common.key.RedisKey
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
...
...
@@ -49,6 +51,8 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
private
ICacheService
cacheService
;
@Autowired
private
MenuService
menuService
;
@Autowired
private
RoleUserService
roleUserService
;
@Autowired
@Lazy
...
...
@@ -56,12 +60,9 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
@Override
public
void
doDistributionSource
(
RoleAuthQuery
query
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
query
.
getRoleId
()))
throw
new
AppException
(
"角色不能为空!"
);
// 删除角色资源老数据
Long
roleId
=
query
.
getRoleId
();
/* Map<String, Object> condition = new HashMap<>();
condition.put("roleId", roleId);
this.dao.delete(condition);*/
//todo
RoleAuthQuery
roleAuthQuery
=
new
RoleAuthQuery
();
roleAuthQuery
.
setRoleId
(
roleId
);
Long
[]
delIds
=
this
.
find
(
roleAuthQuery
).
stream
()
...
...
@@ -80,17 +81,23 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
}
this
.
dao
.
insertBatch
(
list
);
this
.
updateUserMenuUrlCache
();
//查询所有有这个用户角色的用户
// this.find(new RoleAuthQuery().roleId(roleId)).stream().filter(f->f.get)
List
<
Long
>
userIdList
=
roleUserService
.
find
(
new
RoleUserQuery
().
roleId
(
query
.
getRoleId
())).
stream
()
.
map
(
m
->
m
.
getUserId
())
.
filter
(
f
->
f
!=
null
)
.
distinct
().
collect
(
Collectors
.
toList
());
this
.
updateUserMenuUrlCache
(
userIdList
);
}
@Override
public
void
doDistributionMenu
(
RoleAuthQuery
query
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
query
.
getRoleId
()))
throw
new
AppException
(
"角色不能为空!"
);
// 删除角色资源老数据
Long
roleId
=
query
.
getRoleId
();
/* Map<String, Object> condition = new HashMap<>();
condition.put("roleId", roleId);
this.dao.delete(condition);*/
//todo
RoleAuthQuery
roleAuthQuery
=
new
RoleAuthQuery
();
roleAuthQuery
.
setRoleId
(
roleId
);
Long
[]
delIds
=
this
.
find
(
roleAuthQuery
).
stream
()
...
...
@@ -108,13 +115,16 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
list
.
add
(
entity
);
}
this
.
dao
.
insertBatch
(
list
);
this
.
updateUserMenuUrlCache
();
List
<
Long
>
userIdList
=
roleUserService
.
find
(
new
RoleUserQuery
().
roleId
(
query
.
getRoleId
())).
stream
()
.
map
(
m
->
m
.
getUserId
())
.
filter
(
f
->
f
!=
null
)
.
distinct
().
collect
(
Collectors
.
toList
());
this
.
updateUserMenuUrlCache
(
userIdList
);
}
@Override
public
List
<
MenuTreeSelect
>
editMenu
(
RoleAuthQuery
query
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
query
.
getRoleId
()))
throw
new
AppException
(
"角色不能为空"
);
if
(
ObjectUtils
.
isEmpty
(
query
.
getRoleId
()))
throw
new
AppException
(
"角色不能为空
!
"
);
RoleAuthQuery
roleAuthQuery
=
new
RoleAuthQuery
();
roleAuthQuery
.
setRoleId
(
query
.
getRoleId
());
...
...
@@ -131,13 +141,11 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
}
private
void
updateUserMenuUrlCache
()
{
//更新用户菜单
Set
<
String
>
hkeys
=
cacheService
.
hkeys
(
RedisKey
.
KEY_USER_MENU_CACHE
);
for
(
String
userId
:
hkeys
)
{
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
DataUtil
.
converStr2Long
(
userId
,
0L
));
private
void
updateUserMenuUrlCache
(
List
<
Long
>
userIdList
)
{
for
(
Long
userId
:
userIdList
)
{
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
userId
);
String
menuUrlCode
=
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userId
,
menuUrlCode
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userId
.
toString
()
,
menuUrlCode
);
}
}
...
...
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