Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
Project
Project
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
hubin
long-tern-care-service
Commits
415c5929
Commit
415c5929
authored
Feb 20, 2023
by
董天德
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_20230210_dtd' into dev_20230130_mast
parents
81bc7af3
e6c4ee2e
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
117 additions
and
32 deletions
+117
-32
SystemResourceinterface.java
...graim/ltc/pojo/entity/system/SystemResourceinterface.java
+11
-0
ReqUserInfo.java
...ain/java/com/hungraim/ltc/pojo/vo/system/ReqUserInfo.java
+2
-0
AuthorizationManager.java
...m/hungraim/ltc/gateway/security/AuthorizationManager.java
+8
-7
InitResourceRoleCacheRunner.java
...m/hungraim/ltc/component/InitResourceRoleCacheRunner.java
+1
-1
UserController.java
...va/com/hungraim/ltc/system/controller/UserController.java
+21
-1
SystemInterfaceMapper.java
...va/com/hungraim/ltc/system/dao/SystemInterfaceMapper.java
+9
-4
SystemUserMapper.java
...in/java/com/hungraim/ltc/system/dao/SystemUserMapper.java
+12
-0
ISystemUserService.java
...a/com/hungraim/ltc/system/service/ISystemUserService.java
+9
-0
SystemInterfaceServiceImpl.java
...m/ltc/system/service/impl/SystemInterfaceServiceImpl.java
+32
-19
SystemUserServiceImpl.java
...ngraim/ltc/system/service/impl/SystemUserServiceImpl.java
+12
-0
No files found.
common/common-core/src/main/java/com/hungraim/ltc/pojo/entity/system/SystemResourceinterface.java
0 → 100644
View file @
415c5929
package
com
.
hungraim
.
ltc
.
pojo
.
entity
.
system
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
@Data
@TableName
(
"LTC_RESOURCE_INTERFACE"
)
public
class
SystemResourceinterface
{
private
Long
resourceId
;
private
Long
interfaceId
;
}
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/system/ReqUserInfo.java
View file @
415c5929
...
@@ -22,5 +22,7 @@ public class ReqUserInfo {
...
@@ -22,5 +22,7 @@ public class ReqUserInfo {
private
Long
organId
;
private
Long
organId
;
private
Long
srvOrganId
;
private
Long
srvOrganId
;
private
String
organName
;
private
String
srvOrganName
;
}
}
gateway-service/src/main/java/com/hungraim/ltc/gateway/security/AuthorizationManager.java
View file @
415c5929
...
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
...
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.hungraim.ltc.constant.AuthConstants
;
import
com.hungraim.ltc.constant.AuthConstants
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemRoleResource
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -87,14 +88,14 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
...
@@ -87,14 +88,14 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
String
[]
splitpath
=
path
.
split
(
"/"
);
String
[]
splitpath
=
path
.
split
(
"/"
);
String
pathNew
=
"/"
+
splitpath
[
1
]
+
"/"
+
splitpath
[
2
]
+
"/*"
;
String
pathNew
=
"/"
+
splitpath
[
1
]
+
"/"
+
splitpath
[
2
]
+
"/*"
;
Set
<
String
>
authorities
=
new
HashSet
<>();
Set
<
String
>
authorities
=
new
HashSet
<>();
Map
<
String
,
List
<
Long
>>
rolesResources
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
);
Map
<
String
,
List
<
SystemRoleResource
>>
rolesResources
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
);
Map
<
String
,
List
<
S
ystemInterface
>>
interfaces
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
Map
<
String
,
List
<
S
tring
>>
interfaces
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
List
<
Long
>
resources
=
rolesResources
.
get
(
roleId
);
List
<
SystemRoleResource
>
resources
=
rolesResources
.
get
(
roleId
);
for
(
Long
resource
:
resources
)
{
for
(
SystemRoleResource
resource
:
resources
)
{
List
<
S
ystemInterface
>
systemInterfaces
=
interfaces
.
get
(
resource
.
toString
());
List
<
S
tring
>
systemInterfaces
=
interfaces
.
get
(
resource
.
getResourceId
()
.
toString
());
if
(
systemInterfaces
!=
null
&&
systemInterfaces
.
size
()
>
0
)
{
if
(
systemInterfaces
!=
null
&&
systemInterfaces
.
size
()
>
0
)
{
for
(
S
ystemInterface
iter
:
systemInterfaces
)
{
for
(
S
tring
iter
:
systemInterfaces
)
{
if
(
pathMatcher
.
match
(
iter
.
getInterfaceUrl
()
,
pathNew
))
{
if
(
pathMatcher
.
match
(
iter
,
pathNew
))
{
authorities
.
addAll
(
Convert
.
toList
(
String
.
class
,
roleId
));
authorities
.
addAll
(
Convert
.
toList
(
String
.
class
,
roleId
));
}
}
}
}
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/component/InitResourceRoleCacheRunner.java
View file @
415c5929
...
@@ -25,6 +25,6 @@ public class InitResourceRoleCacheRunner implements CommandLineRunner {
...
@@ -25,6 +25,6 @@ public class InitResourceRoleCacheRunner implements CommandLineRunner {
@Override
@Override
public
void
run
(
String
...
args
)
{
public
void
run
(
String
...
args
)
{
resourceService
.
refreshPermissionRolesCache
();
//
resourceService.refreshPermissionRolesCache();
}
}
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/UserController.java
View file @
415c5929
...
@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
...
@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.hungraim.ltc.constant.Gender
;
import
com.hungraim.ltc.constant.Gender
;
import
com.hungraim.ltc.pojo.entity.disable.ChFndOrgan
;
import
com.hungraim.ltc.pojo.entity.disable.ChSrvOrgan
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.pojo.entity.system.SystemUserRole
;
import
com.hungraim.ltc.pojo.entity.system.SystemUserRole
;
import
com.hungraim.ltc.pojo.vo.system.ReqUserInfo
;
import
com.hungraim.ltc.pojo.vo.system.ReqUserInfo
;
...
@@ -16,6 +18,7 @@ import com.hungraim.ltc.system.service.impl.SystemUserServiceImpl;
...
@@ -16,6 +18,7 @@ import com.hungraim.ltc.system.service.impl.SystemUserServiceImpl;
import
com.hungraim.ltc.util.CheckStrength
;
import
com.hungraim.ltc.util.CheckStrength
;
import
com.hungraim.ltc.util.Result
;
import
com.hungraim.ltc.util.Result
;
import
com.hungraim.ltc.util.ResultCode
;
import
com.hungraim.ltc.util.ResultCode
;
import
com.hungraim.ltc.util.TokenParsingUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
...
@@ -172,7 +175,9 @@ public class UserController {
...
@@ -172,7 +175,9 @@ public class UserController {
* @return
* @return
*/
*/
@PostMapping
(
"/queryUsers"
)
@PostMapping
(
"/queryUsers"
)
public
Result
queryUsers
(
ReqUserInfo
reqUserInfo
)
{
public
Result
queryUsers
(
@RequestHeader
(
"Authorization"
)
String
token
,
ReqUserInfo
reqUserInfo
)
{
long
srvOrganId
=
TokenParsingUtil
.
TokenParsing
(
token
,
"srvOrganId"
);
long
organId
=
TokenParsingUtil
.
TokenParsing
(
token
,
"organId"
);
QueryWrapper
<
SystemUser
>
systemUserQueryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
SystemUser
>
systemUserQueryWrapper
=
new
QueryWrapper
<>();
if
(!
StrUtil
.
isBlankIfStr
(
reqUserInfo
.
getName
()))
{
if
(!
StrUtil
.
isBlankIfStr
(
reqUserInfo
.
getName
()))
{
...
@@ -185,7 +190,16 @@ public class UserController {
...
@@ -185,7 +190,16 @@ public class UserController {
if
(!
StrUtil
.
isBlankIfStr
(
reqUserInfo
.
getEnable
()))
{
if
(!
StrUtil
.
isBlankIfStr
(
reqUserInfo
.
getEnable
()))
{
systemUserQueryWrapper
.
and
(
wrapper
->
wrapper
.
lambda
().
eq
(
SystemUser:
:
getUserStatus
,
reqUserInfo
.
getEnable
()));
systemUserQueryWrapper
.
and
(
wrapper
->
wrapper
.
lambda
().
eq
(
SystemUser:
:
getUserStatus
,
reqUserInfo
.
getEnable
()));
}
}
if
(
srvOrganId
!=
0
)
{
systemUserQueryWrapper
.
and
(
wrapper
->
wrapper
.
lambda
().
eq
(
SystemUser:
:
getSrvOrganId
,
srvOrganId
));
}
if
(
organId
!=
0
)
{
systemUserQueryWrapper
.
and
(
wrapper
->
wrapper
.
lambda
().
eq
(
SystemUser:
:
getOrganId
,
organId
));
}
List
<
SystemUser
>
users
=
userInfoService
.
list
(
systemUserQueryWrapper
);
List
<
SystemUser
>
users
=
userInfoService
.
list
(
systemUserQueryWrapper
);
List
<
ChFndOrgan
>
chFndOrganList
=
userInfoService
.
fndAllOrgans
();
List
<
ChSrvOrgan
>
chSrvOrganList
=
userInfoService
.
srvOrganLists
();
List
<
ReqUserInfo
>
resUsers
=
users
.
stream
().
map
(
user
->
{
List
<
ReqUserInfo
>
resUsers
=
users
.
stream
().
map
(
user
->
{
ReqUserInfo
userInfo
=
new
ReqUserInfo
();
ReqUserInfo
userInfo
=
new
ReqUserInfo
();
userInfo
.
setId
(
user
.
getUserId
());
userInfo
.
setId
(
user
.
getUserId
());
...
@@ -196,6 +210,12 @@ public class UserController {
...
@@ -196,6 +210,12 @@ public class UserController {
userInfo
.
setGender
(
Gender
.
MAN
.
getCode
().
equals
(
user
.
getGender
())
?
Gender
.
MAN
.
getDesc
()
:
Gender
.
WOMAN
.
getDesc
());
userInfo
.
setGender
(
Gender
.
MAN
.
getCode
().
equals
(
user
.
getGender
())
?
Gender
.
MAN
.
getDesc
()
:
Gender
.
WOMAN
.
getDesc
());
userInfo
.
setOrganId
(
user
.
getOrganId
());
userInfo
.
setOrganId
(
user
.
getOrganId
());
userInfo
.
setSrvOrganId
(
user
.
getSrvOrganId
());
userInfo
.
setSrvOrganId
(
user
.
getSrvOrganId
());
if
(
userInfo
.
getOrganId
()!=
null
&&
userInfo
.
getOrganId
()>
0
&&
userInfo
.
getSrvOrganId
()!=
null
&&
!
userInfo
.
getSrvOrganId
().
equals
(
"0"
)){
List
<
ChFndOrgan
>
collect
=
chFndOrganList
.
stream
().
filter
(
chFndOrgan
->
chFndOrgan
.
getOrganId
().
equals
(
user
.
getOrganId
().
toString
())).
collect
(
Collectors
.
toList
());
List
<
ChSrvOrgan
>
chSrvOrgans
=
chSrvOrganList
.
stream
().
filter
(
chSrvOrgan
->
chSrvOrgan
.
getSrvOrganId
().
equals
(
user
.
getSrvOrganId
().
intValue
())).
collect
(
Collectors
.
toList
());
userInfo
.
setOrganName
(
collect
.
get
(
0
).
getOrganName
());
userInfo
.
setSrvOrganName
(
chSrvOrgans
.
get
(
0
).
getSrvOrganName
());
}
return
userInfo
;
return
userInfo
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
return
Result
.
success
(
resUsers
);
return
Result
.
success
(
resUsers
);
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/dao/SystemInterfaceMapper.java
View file @
415c5929
...
@@ -3,6 +3,8 @@ package com.hungraim.ltc.system.dao;
...
@@ -3,6 +3,8 @@ package com.hungraim.ltc.system.dao;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemResource
;
import
com.hungraim.ltc.pojo.entity.system.SystemResource
;
import
com.hungraim.ltc.pojo.entity.system.SystemResourceinterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemRoleResource
;
import
org.apache.ibatis.annotations.*
;
import
org.apache.ibatis.annotations.*
;
import
java.util.List
;
import
java.util.List
;
...
@@ -14,14 +16,17 @@ import java.util.List;
...
@@ -14,14 +16,17 @@ import java.util.List;
@Mapper
@Mapper
public
interface
SystemInterfaceMapper
extends
BaseMapper
<
SystemInterface
>
{
public
interface
SystemInterfaceMapper
extends
BaseMapper
<
SystemInterface
>
{
@Select
(
"SELECT a.INTERFACE_ID,a.INTERFACE_URL FROM LTC_INTERFACE a,LTC_RESOURCE_INTERFACE e where a.INTERFACE_ID=e.INTERFACE_ID and e.RESOURCE_ID=#{resourceId}"
)
@Select
(
"SELECT a.INTERFACE_ID,a.INTERFACE_URL FROM LTC_INTERFACE a"
)
List
<
SystemInterface
>
listInterface
(
Long
resourceId
);
List
<
SystemInterface
>
listInterface
();
@Select
(
"select c.RESOURCE_ID,c.INTERFACE_ID from LTC_RESOURCE_INTERFACE c"
)
List
<
SystemResourceinterface
>
listResourceInterface
();
@Select
(
"select b.ROLE_ID from LTC_ROLE b"
)
@Select
(
"select b.ROLE_ID from LTC_ROLE b"
)
List
<
Long
>
listRole
();
List
<
Long
>
listRole
();
@Select
(
"select c.RESOURCE_ID
from LTC_ROLE_RESOURCE c WHERE c.ROLE_ID=#{roleId}
"
)
@Select
(
"select c.RESOURCE_ID
,c.ROLE_ID from LTC_ROLE_RESOURCE c
"
)
List
<
Long
>
listRoleResource
(
Long
roleId
);
List
<
SystemRoleResource
>
listRoleResource
(
);
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/dao/SystemUserMapper.java
View file @
415c5929
...
@@ -2,8 +2,13 @@ package com.hungraim.ltc.system.dao;
...
@@ -2,8 +2,13 @@ package com.hungraim.ltc.system.dao;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.hungraim.ltc.pojo.entity.disable.ChFndOrgan
;
import
com.hungraim.ltc.pojo.entity.disable.ChSrvOrgan
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
/**
* 用户
* 用户
...
@@ -12,4 +17,11 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -12,4 +17,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
@Mapper
public
interface
SystemUserMapper
extends
BaseMapper
<
SystemUser
>
{
public
interface
SystemUserMapper
extends
BaseMapper
<
SystemUser
>
{
@Select
(
"select ORGAN_ID,ORGAN_NAME from CH_FND_ORGAN"
)
List
<
ChFndOrgan
>
fndAllOrgans
();
@Select
(
"select SRV_ORGAN_ID,SRV_ORGAN_NAME from CH_SRV_ORGAN"
)
List
<
ChSrvOrgan
>
srvOrganLists
();
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/ISystemUserService.java
View file @
415c5929
package
com
.
hungraim
.
ltc
.
system
.
service
;
package
com
.
hungraim
.
ltc
.
system
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.hungraim.ltc.pojo.entity.disable.ChFndOrgan
;
import
com.hungraim.ltc.pojo.entity.disable.ChSrvOrgan
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
java.util.List
;
/**
/**
* @author hubin
* @author hubin
*/
*/
public
interface
ISystemUserService
extends
IService
<
SystemUser
>
{
public
interface
ISystemUserService
extends
IService
<
SystemUser
>
{
List
<
ChFndOrgan
>
fndAllOrgans
();
List
<
ChSrvOrgan
>
srvOrganLists
();
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/impl/SystemInterfaceServiceImpl.java
View file @
415c5929
...
@@ -3,6 +3,8 @@ package com.hungraim.ltc.system.service.impl;
...
@@ -3,6 +3,8 @@ package com.hungraim.ltc.system.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.hungraim.ltc.constant.AuthConstants
;
import
com.hungraim.ltc.constant.AuthConstants
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemInterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemResourceinterface
;
import
com.hungraim.ltc.pojo.entity.system.SystemRoleResource
;
import
com.hungraim.ltc.system.dao.SystemInterfaceMapper
;
import
com.hungraim.ltc.system.dao.SystemInterfaceMapper
;
import
com.hungraim.ltc.system.service.ISystemInterfaceService
;
import
com.hungraim.ltc.system.service.ISystemInterfaceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -11,6 +13,7 @@ import org.springframework.data.redis.core.RedisTemplate;
...
@@ -11,6 +13,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* @author mq
* @author mq
...
@@ -34,29 +37,39 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
...
@@ -34,29 +37,39 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
@Override
@Override
public
void
listResourceInterface
()
{
public
void
listResourceInterface
()
{
try
{
redisTemplate
.
delete
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
redisTemplate
.
delete
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
redisTemplate
.
delete
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
);
redisTemplate
.
delete
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
);
Map
<
String
,
List
<
Long
>>
roleResourcesMap
=
new
TreeMap
<>();
Map
<
String
,
List
<
SystemRoleResource
>>
roleResourcesMap
=
new
TreeMap
<>();
Map
<
String
,
List
<
SystemInterface
>>
stringStringHashMap
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
stringStringHashMap
=
new
HashMap
<>();
//角色数据
List
<
Long
>
roles
=
systemInterfaceMapper
.
listRole
();
List
<
Long
>
roles
=
systemInterfaceMapper
.
listRole
();
String
roleId
;
//角色和资源数据
for
(
Long
role
:
roles
)
{
List
<
SystemRoleResource
>
roleResources
=
systemInterfaceMapper
.
listRoleResource
();
List
<
Long
>
roleResources
=
systemInterfaceMapper
.
listRoleResource
(
role
);
//资源和接口数据
//保存资源和接口
List
<
SystemResourceinterface
>
resourceInterface
=
systemInterfaceMapper
.
listResourceInterface
();
for
(
Long
roleResource:
roleResources
){
//接口数据
List
<
SystemInterface
>
systemInterfaces
=
systemInterfaceMapper
.
listInterface
(
roleResource
);
List
<
SystemInterface
>
systemInterfaces
=
systemInterfaceMapper
.
listInterface
();
stringStringHashMap
.
put
(
roleResource
.
toString
(),
systemInterfaces
);
roles
.
stream
().
forEach
(
role
->
{
}
//角色和资源数据
// 转换 roles -> ROLE_{roleId}
List
<
SystemRoleResource
>
roleResourceList
=
roleResources
.
stream
().
filter
(
roleResource
->
roleResource
.
getRoleId
().
equals
(
role
)).
collect
(
Collectors
.
toList
());
roleId
=
AuthConstants
.
AUTHORITY_PREFIX
+
role
;
roleResourceList
.
stream
().
forEach
(
roleResource
->
{
//保存角色和资源
//资源和接口数据
roleResourcesMap
.
put
(
roleId
,
roleResources
);
List
<
SystemResourceinterface
>
resourceinterfaceList
=
resourceInterface
.
stream
().
filter
(
role2
->
role2
.
getResourceId
().
equals
(
roleResource
.
getResourceId
())).
collect
(
Collectors
.
toList
());
}
List
<
String
>
systemResourceinterfaces
=
new
ArrayList
<>();
resourceinterfaceList
.
stream
().
forEach
(
resourceinterface
->{
List
<
SystemInterface
>
collect
=
systemInterfaces
.
stream
().
filter
(
role2
->
role2
.
getInterfaceId
().
equals
(
resourceinterface
.
getInterfaceId
())).
collect
(
Collectors
.
toList
());
systemResourceinterfaces
.
add
(
collect
.
get
(
0
).
getInterfaceUrl
());
});
//资源和接口
stringStringHashMap
.
put
(
roleResource
.
getResourceId
().
toString
(),
systemResourceinterfaces
);
});
//角色和资源
roleResourcesMap
.
put
(
AuthConstants
.
AUTHORITY_PREFIX
+
role
.
toString
(),
roleResourceList
);
});
redisTemplate
.
opsForHash
().
putAll
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
,
roleResourcesMap
);
redisTemplate
.
opsForHash
().
putAll
(
AuthConstants
.
PERMISSION_ROLES_RESOURCE_KEY
,
roleResourcesMap
);
redisTemplate
.
opsForHash
().
putAll
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
,
stringStringHashMap
);
redisTemplate
.
opsForHash
().
putAll
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
,
stringStringHashMap
);
}
catch
(
RuntimeException
e
){
e
.
printStackTrace
();
}
}
}
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/impl/SystemUserServiceImpl.java
View file @
415c5929
...
@@ -2,6 +2,8 @@ package com.hungraim.ltc.system.service.impl;
...
@@ -2,6 +2,8 @@ package com.hungraim.ltc.system.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.hungraim.ltc.pojo.entity.disable.ChFndOrgan
;
import
com.hungraim.ltc.pojo.entity.disable.ChSrvOrgan
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.pojo.entity.system.SystemUser
;
import
com.hungraim.ltc.system.dao.SystemUserMapper
;
import
com.hungraim.ltc.system.dao.SystemUserMapper
;
import
com.hungraim.ltc.system.dao.SystemUserRoleMapper
;
import
com.hungraim.ltc.system.dao.SystemUserRoleMapper
;
...
@@ -9,6 +11,7 @@ import com.hungraim.ltc.system.service.ISystemUserService;
...
@@ -9,6 +11,7 @@ import com.hungraim.ltc.system.service.ISystemUserService;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* @author hubin
* @author hubin
...
@@ -23,4 +26,13 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
...
@@ -23,4 +26,13 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
private
SystemUserRoleMapper
userRoleMapper
;
private
SystemUserRoleMapper
userRoleMapper
;
@Override
public
List
<
ChFndOrgan
>
fndAllOrgans
()
{
return
userMapper
.
fndAllOrgans
();
}
@Override
public
List
<
ChSrvOrgan
>
srvOrganLists
()
{
return
userMapper
.
srvOrganLists
();
}
}
}
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