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
254054bb
Commit
254054bb
authored
Feb 20, 2023
by
董天德
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev_20230210_dtd' into dev_ch_master
parents
af07442b
9b1cd79d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
9 deletions
+44
-9
AuthConstants.java
...rc/main/java/com/hungraim/ltc/constant/AuthConstants.java
+5
-0
SystemInterface.java
.../com/hungraim/ltc/pojo/entity/system/SystemInterface.java
+4
-0
AuthorizationManager.java
...m/hungraim/ltc/gateway/security/AuthorizationManager.java
+10
-0
RoleController.java
...va/com/hungraim/ltc/system/controller/RoleController.java
+9
-3
UserController.java
...va/com/hungraim/ltc/system/controller/UserController.java
+11
-5
SystemInterfaceMapper.java
...va/com/hungraim/ltc/system/dao/SystemInterfaceMapper.java
+1
-1
SystemInterfaceServiceImpl.java
...m/ltc/system/service/impl/SystemInterfaceServiceImpl.java
+4
-0
No files found.
common/common-core/src/main/java/com/hungraim/ltc/constant/AuthConstants.java
View file @
254054bb
...
@@ -39,6 +39,11 @@ public interface AuthConstants {
...
@@ -39,6 +39,11 @@ public interface AuthConstants {
*/
*/
String
PERMISSION_ROLES_RESOURCE_KEY
=
"ltc:roles:resource"
;
String
PERMISSION_ROLES_RESOURCE_KEY
=
"ltc:roles:resource"
;
/**
* Redis缓存权限规则key
*/
String
PERMISSION_RESOURCE_STATUS_KEY
=
"ltc:interface:status"
;
/**
/**
* 密码加密方式
* 密码加密方式
...
...
common/common-core/src/main/java/com/hungraim/ltc/pojo/entity/system/SystemInterface.java
View file @
254054bb
...
@@ -14,4 +14,8 @@ public class SystemInterface {
...
@@ -14,4 +14,8 @@ public class SystemInterface {
private
String
interfaceUrl
;
private
String
interfaceUrl
;
private
String
interfaceName
;
private
String
interfaceName
;
private
Date
createdTime
;
private
Date
createdTime
;
/**
* 是否拦截 1.拦截 0.不拦截
*/
private
Long
interceptionStatus
;
}
}
gateway-service/src/main/java/com/hungraim/ltc/gateway/security/AuthorizationManager.java
View file @
254054bb
...
@@ -85,11 +85,21 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
...
@@ -85,11 +85,21 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
if
(
"ROLE_0"
.
equals
(
roleId
))
{
if
(
"ROLE_0"
.
equals
(
roleId
))
{
return
true
;
return
true
;
}
}
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
,
String
>
interfaceHashMap
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_RESOURCE_STATUS_KEY
);
Map
<
String
,
List
<
SystemRoleResource
>>
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
<
String
>>
interfaces
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
Map
<
String
,
List
<
String
>>
interfaces
=
redisTemplate
.
opsForHash
().
entries
(
AuthConstants
.
PERMISSION_RESOURCE_INTERFACE_KEY
);
// Integer status = Integer.parseInt(interfaceHashMap.get(pathNew));
String
status
=
interfaceHashMap
.
get
(
pathNew
);
//是否拦截 1.拦截 0.不拦截
if
(
status
.
equals
(
"0"
)){
log
.
info
(
"访问路径是否拦截:不拦截"
);
return
true
;
}
log
.
info
(
"访问路径是否拦截:拦截"
);
List
<
SystemRoleResource
>
resources
=
rolesResources
.
get
(
roleId
);
List
<
SystemRoleResource
>
resources
=
rolesResources
.
get
(
roleId
);
for
(
SystemRoleResource
resource
:
resources
)
{
for
(
SystemRoleResource
resource
:
resources
)
{
List
<
String
>
systemInterfaces
=
interfaces
.
get
(
resource
.
getResourceId
().
toString
());
List
<
String
>
systemInterfaces
=
interfaces
.
get
(
resource
.
getResourceId
().
toString
());
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/RoleController.java
View file @
254054bb
package
com
.
hungraim
.
ltc
.
system
.
controller
;
package
com
.
hungraim
.
ltc
.
system
.
controller
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
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.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
@@ -11,6 +10,7 @@ import com.hungraim.ltc.pojo.vo.system.ReqRoleInfo;
...
@@ -11,6 +10,7 @@ import com.hungraim.ltc.pojo.vo.system.ReqRoleInfo;
import
com.hungraim.ltc.system.dao.SystemRoleResourceMapper
;
import
com.hungraim.ltc.system.dao.SystemRoleResourceMapper
;
import
com.hungraim.ltc.system.service.ISystemRoleResourceService
;
import
com.hungraim.ltc.system.service.ISystemRoleResourceService
;
import
com.hungraim.ltc.system.service.ISystemRoleService
;
import
com.hungraim.ltc.system.service.ISystemRoleService
;
import
com.hungraim.ltc.system.service.impl.SystemInterfaceServiceImpl
;
import
com.hungraim.ltc.util.Result
;
import
com.hungraim.ltc.util.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -36,6 +36,12 @@ public class RoleController {
...
@@ -36,6 +36,12 @@ public class RoleController {
private
SystemRoleResourceMapper
systemRoleResourceMapper
;
private
SystemRoleResourceMapper
systemRoleResourceMapper
;
@Autowired
@Autowired
private
ISystemRoleService
roleService
;
private
ISystemRoleService
roleService
;
private
final
SystemInterfaceServiceImpl
systemInterfaceService
;
@Autowired
public
RoleController
(
SystemInterfaceServiceImpl
systemInterfaceService
)
{
this
.
systemInterfaceService
=
systemInterfaceService
;
}
/**
/**
...
@@ -82,7 +88,7 @@ public class RoleController {
...
@@ -82,7 +88,7 @@ public class RoleController {
return
systemRoleResource
;
return
systemRoleResource
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
roleResourceService
.
saveBatch
(
roleResources
);
roleResourceService
.
saveBatch
(
roleResources
);
systemInterfaceService
.
listResourceInterface
();
return
Result
.
success
(
"新增成功"
);
return
Result
.
success
(
"新增成功"
);
}
}
...
@@ -185,7 +191,7 @@ public class RoleController {
...
@@ -185,7 +191,7 @@ public class RoleController {
if
(!
deleteRoleResources
.
isEmpty
()){
if
(!
deleteRoleResources
.
isEmpty
()){
systemRoleResourceMapper
.
removeByIds
(
deleteRoleResources
,
reqRoleInfo
.
getId
());
systemRoleResourceMapper
.
removeByIds
(
deleteRoleResources
,
reqRoleInfo
.
getId
());
}
}
systemInterfaceService
.
listResourceInterface
();
return
Result
.
success
(
"更新成功"
);
return
Result
.
success
(
"更新成功"
);
}
}
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/UserController.java
View file @
254054bb
...
@@ -13,12 +13,10 @@ import com.hungraim.ltc.pojo.vo.system.ReqUserInfo;
...
@@ -13,12 +13,10 @@ import com.hungraim.ltc.pojo.vo.system.ReqUserInfo;
import
com.hungraim.ltc.system.dao.SystemUserRoleMapper
;
import
com.hungraim.ltc.system.dao.SystemUserRoleMapper
;
import
com.hungraim.ltc.system.service.ISystemUserRoleService
;
import
com.hungraim.ltc.system.service.ISystemUserRoleService
;
import
com.hungraim.ltc.system.service.ISystemUserService
;
import
com.hungraim.ltc.system.service.ISystemUserService
;
import
com.hungraim.ltc.system.service.impl.SystemInterfaceServiceImpl
;
import
com.hungraim.ltc.system.service.impl.SystemUserRoleServiceImpl
;
import
com.hungraim.ltc.system.service.impl.SystemUserRoleServiceImpl
;
import
com.hungraim.ltc.system.service.impl.SystemUserServiceImpl
;
import
com.hungraim.ltc.system.service.impl.SystemUserServiceImpl
;
import
com.hungraim.ltc.util.CheckStrength
;
import
com.hungraim.ltc.util.*
;
import
com.hungraim.ltc.util.Result
;
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
;
...
@@ -39,15 +37,21 @@ import java.util.stream.Collectors;
...
@@ -39,15 +37,21 @@ import java.util.stream.Collectors;
public
class
UserController
{
public
class
UserController
{
private
final
ISystemUserService
userInfoService
;
private
final
ISystemUserService
userInfoService
;
private
final
ISystemUserRoleService
userRoleService
;
private
final
ISystemUserRoleService
userRoleService
;
private
final
SystemInterfaceServiceImpl
systemInterfaceService
;
@Resource
@Resource
private
SystemUserRoleMapper
systemUserRoleMapper
;
private
SystemUserRoleMapper
systemUserRoleMapper
;
@Autowired
@Autowired
public
UserController
(
SystemUserServiceImpl
userInfoService
,
SystemUserRoleServiceImpl
userRoleService
)
{
public
UserController
(
SystemUserServiceImpl
userInfoService
,
SystemUserRoleServiceImpl
userRoleService
,
SystemInterfaceServiceImpl
systemInterfaceService
)
{
this
.
userInfoService
=
userInfoService
;
this
.
userInfoService
=
userInfoService
;
this
.
userRoleService
=
userRoleService
;
this
.
userRoleService
=
userRoleService
;
this
.
systemInterfaceService
=
systemInterfaceService
;
}
}
...
@@ -127,6 +131,7 @@ public class UserController {
...
@@ -127,6 +131,7 @@ public class UserController {
return
systemUserRole
;
return
systemUserRole
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
userRoleService
.
saveBatch
(
roleList
);
userRoleService
.
saveBatch
(
roleList
);
systemInterfaceService
.
listResourceInterface
();
return
Result
.
success
(
"新增成功"
);
return
Result
.
success
(
"新增成功"
);
}
}
...
@@ -282,6 +287,7 @@ public class UserController {
...
@@ -282,6 +287,7 @@ public class UserController {
if
(!
deleteRoleResources
.
isEmpty
()){
if
(!
deleteRoleResources
.
isEmpty
()){
systemUserRoleMapper
.
removeByIds
(
deleteRoleResources
,
reqUserInfo
.
getId
());
systemUserRoleMapper
.
removeByIds
(
deleteRoleResources
,
reqUserInfo
.
getId
());
}
}
systemInterfaceService
.
listResourceInterface
();
// systemUserRoleMapper.removeByIds(deleteRoleResources,reqUserInfo.getId());
// systemUserRoleMapper.removeByIds(deleteRoleResources,reqUserInfo.getId());
// userRoleService.removeByIds(deleteRoleResources);
// userRoleService.removeByIds(deleteRoleResources);
return
Result
.
success
(
"更新成功"
);
return
Result
.
success
(
"更新成功"
);
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/dao/SystemInterfaceMapper.java
View file @
254054bb
...
@@ -16,7 +16,7 @@ import java.util.List;
...
@@ -16,7 +16,7 @@ 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"
)
@Select
(
"SELECT a.INTERFACE_ID,a.INTERFACE_URL
,a.INTERCEPTION_STATUS
FROM LTC_INTERFACE a"
)
List
<
SystemInterface
>
listInterface
();
List
<
SystemInterface
>
listInterface
();
@Select
(
"select c.RESOURCE_ID,c.INTERFACE_ID from LTC_RESOURCE_INTERFACE c"
)
@Select
(
"select c.RESOURCE_ID,c.INTERFACE_ID from LTC_RESOURCE_INTERFACE c"
)
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/impl/SystemInterfaceServiceImpl.java
View file @
254054bb
...
@@ -40,8 +40,10 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
...
@@ -40,8 +40,10 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
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
);
redisTemplate
.
delete
(
AuthConstants
.
PERMISSION_RESOURCE_STATUS_KEY
);
Map
<
String
,
List
<
SystemRoleResource
>>
roleResourcesMap
=
new
TreeMap
<>();
Map
<
String
,
List
<
SystemRoleResource
>>
roleResourcesMap
=
new
TreeMap
<>();
Map
<
String
,
List
<
String
>>
stringStringHashMap
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
stringStringHashMap
=
new
HashMap
<>();
Map
<
String
,
String
>
interfaceHashMap
=
new
HashMap
<>();
//角色数据
//角色数据
List
<
Long
>
roles
=
systemInterfaceMapper
.
listRole
();
List
<
Long
>
roles
=
systemInterfaceMapper
.
listRole
();
//角色和资源数据
//角色和资源数据
...
@@ -50,6 +52,7 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
...
@@ -50,6 +52,7 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
List
<
SystemResourceinterface
>
resourceInterface
=
systemInterfaceMapper
.
listResourceInterface
();
List
<
SystemResourceinterface
>
resourceInterface
=
systemInterfaceMapper
.
listResourceInterface
();
//接口数据
//接口数据
List
<
SystemInterface
>
systemInterfaces
=
systemInterfaceMapper
.
listInterface
();
List
<
SystemInterface
>
systemInterfaces
=
systemInterfaceMapper
.
listInterface
();
systemInterfaces
.
stream
().
forEach
(
systemInterface
->
interfaceHashMap
.
put
(
systemInterface
.
getInterfaceUrl
(),
systemInterface
.
getInterceptionStatus
().
toString
()));
roles
.
stream
().
forEach
(
role
->
{
roles
.
stream
().
forEach
(
role
->
{
//角色和资源数据
//角色和资源数据
List
<
SystemRoleResource
>
roleResourceList
=
roleResources
.
stream
().
filter
(
roleResource
->
roleResource
.
getRoleId
().
equals
(
role
)).
collect
(
Collectors
.
toList
());
List
<
SystemRoleResource
>
roleResourceList
=
roleResources
.
stream
().
filter
(
roleResource
->
roleResource
.
getRoleId
().
equals
(
role
)).
collect
(
Collectors
.
toList
());
...
@@ -68,6 +71,7 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
...
@@ -68,6 +71,7 @@ public class SystemInterfaceServiceImpl extends ServiceImpl<SystemInterfaceMappe
//角色和资源
//角色和资源
roleResourcesMap
.
put
(
AuthConstants
.
AUTHORITY_PREFIX
+
role
.
toString
(),
roleResourceList
);
roleResourcesMap
.
put
(
AuthConstants
.
AUTHORITY_PREFIX
+
role
.
toString
(),
roleResourceList
);
});
});
redisTemplate
.
opsForHash
().
putAll
(
AuthConstants
.
PERMISSION_RESOURCE_STATUS_KEY
,
interfaceHashMap
);
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
);
...
...
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