Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
5ce9d74a
提交
5ce9d74a
编写于
5月 25, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更改结构
上级
b2cf0255
变更
3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
142 行增加
和
0 行删除
+142
-0
SysPSSystemAspect.java
...ibizlab/core/uaa/extensions/aspect/SysPSSystemAspect.java
+84
-0
SysStructure.java
...a/cn/ibizlab/core/uaa/extensions/domain/SysStructure.java
+28
-0
UAACoreService.java
...n/ibizlab/core/uaa/extensions/service/UAACoreService.java
+30
-0
未找到文件。
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/aspect/SysPSSystemAspect.java
0 → 100644
浏览文件 @
5ce9d74a
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
aspect
;
import
cn.ibizlab.core.uaa.domain.SysPSSystem
;
import
cn.ibizlab.core.uaa.domain.SysPermission
;
import
cn.ibizlab.core.uaa.extensions.domain.PermissionType
;
import
cn.ibizlab.core.uaa.service.ISysPermissionService
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.After
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.AlternativeJdkIdGenerator
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 实体属性默认值切面,只有新建(Create)时才会填充默认值
*/
@Aspect
@Order
(
0
)
@Component
public
class
SysPSSystemAspect
{
@Autowired
@Lazy
private
ISysPermissionService
sysPermissionService
;
@After
(
value
=
"execution(* cn.ibizlab.core.uaa.service.ISysPSSystemService.create*(..))"
)
public
void
create
(
JoinPoint
point
)
throws
Exception
{
savePermission
(
point
);
}
@After
(
value
=
"execution(* cn.ibizlab.core.uaa.service.ISysPSSystemService.update*(..))"
)
public
void
update
(
JoinPoint
point
)
throws
Exception
{
savePermission
(
point
);
}
@After
(
value
=
"execution(* cn.ibizlab.core.uaa.service.ISysPSSystemService.save*(..))"
)
public
void
save
(
JoinPoint
point
)
throws
Exception
{
savePermission
(
point
);
}
private
void
savePermission
(
JoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
if
(
obj
instanceof
SysPSSystem
)
syncPermission
((
SysPSSystem
)
obj
);
else
if
(
obj
instanceof
List
)
((
List
<
SysPSSystem
>)
obj
).
forEach
(
system
->
syncPermission
(
system
));
}
}
private
void
syncPermission
(
SysPSSystem
system
)
{
if
(
StringUtils
.
isEmpty
(
system
.
getPssystemid
())||
system
.
getSysstructure
()==
null
)
return
;
Map
<
String
,
Integer
>
delPermission
=
new
HashMap
<>();
sysPermissionService
.
list
(
new
QueryWrapper
<
SysPermission
>().
select
(
"sys_permissionid"
).
eq
(
"pssystemid"
,
system
.
getPssystemid
())).
forEach
(
sysPermission
->
delPermission
.
put
(
sysPermission
.
getPermissionid
(),
1
));
List
<
SysPermission
>
list
=
system
.
getSysstructure
().
getSysPermissions
(
PermissionType
.
OPPRIV
);
list
.
addAll
(
system
.
getSysstructure
().
getSysPermissions
(
PermissionType
.
APPMENU
));
list
.
addAll
(
system
.
getSysstructure
().
getSysPermissions
(
PermissionType
.
UNIRES
));
list
.
forEach
(
sysPermission
->
delPermission
.
remove
(
sysPermission
.
getPermissionid
()));
sysPermissionService
.
removeBatch
(
delPermission
.
keySet
());
sysPermissionService
.
saveBatch
(
list
);
}
}
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/domain/SysStructure.java
浏览文件 @
5ce9d74a
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
domain
;
import
cn.ibizlab.core.uaa.domain.SysPermission
;
import
cn.ibizlab.core.uaa.extensions.domain.Structure.AppNode
;
import
cn.ibizlab.core.uaa.extensions.domain.Structure.EntityNode
;
import
cn.ibizlab.core.uaa.extensions.domain.Structure.FuncItem
;
import
cn.ibizlab.core.uaa.extensions.domain.Structure.UniResNode
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
liquibase.pro.packaged.S
;
import
lombok.Data
;
import
java.util.*
;
...
...
@@ -190,4 +192,30 @@ public class SysStructure
return
itemNode
;
}
public
List
<
SysPermission
>
getSysPermissions
(
PermissionType
type
)
{
List
<
SysPermission
>
list
=
new
ArrayList
<>();
PermissionNode
root
=
getPermissionTree
(
type
);
loopPermissionNode
(
list
,
root
);
return
list
;
}
private
void
loopPermissionNode
(
List
<
SysPermission
>
list
,
PermissionNode
root
)
{
if
(
root
.
getChildren
()!=
null
){
root
.
getChildren
().
forEach
(
node
->{
if
(
node
.
getType
()!=
null
){
SysPermission
sysPermission
=
new
SysPermission
();
sysPermission
.
setPermissionid
(
node
.
getId
());
sysPermission
.
setPermissionname
(
node
.
getFullName
());
sysPermission
.
setPssystemid
(
node
.
getSystemid
());
sysPermission
.
setPermissiontype
(
node
.
getType
().
toString
());
list
.
add
(
sysPermission
);
}
loopPermissionNode
(
list
,
node
);
});
}
}
}
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UAACoreService.java
浏览文件 @
5ce9d74a
...
...
@@ -6,13 +6,18 @@ import cn.ibizlab.core.uaa.domain.SysRolePermission;
import
cn.ibizlab.core.uaa.extensions.domain.PermissionNode
;
import
cn.ibizlab.core.uaa.extensions.domain.PermissionType
;
import
cn.ibizlab.core.uaa.filter.SysPSSystemSearchContext
;
import
cn.ibizlab.core.uaa.filter.SysRolePermissionSearchContext
;
import
cn.ibizlab.core.uaa.service.ISysPSSystemService
;
import
cn.ibizlab.core.uaa.service.ISysRolePermissionService
;
import
cn.ibizlab.core.uaa.service.ISysUserRoleService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.data.domain.Page
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
...
...
@@ -23,11 +28,17 @@ import java.util.*;
public
class
UAACoreService
{
@Autowired
@Lazy
private
ISysPSSystemService
sysPSSystemService
;
@Autowired
@Lazy
private
ISysRolePermissionService
rolePermissionService
;
@Autowired
@Lazy
private
ISysUserRoleService
userRoleService
;
public
Map
<
String
,
List
<
PermissionNode
>>
getPermissionTree
()
{
List
<
PermissionNode
>
apps
=
new
ArrayList
<>();
...
...
@@ -58,4 +69,23 @@ public class UAACoreService {
return
rolePermissions
;
}
public
Collection
<
GrantedAuthority
>
getAuthoritiesByUserId
(
String
userId
)
{
Set
<
GrantedAuthority
>
authorities
=
new
LinkedHashSet
<>();
Set
<
String
>
roleIds
=
new
HashSet
<>();
userRoleService
.
selectByUserid
(
userId
).
forEach
(
sysUserRole
->
roleIds
.
add
(
sysUserRole
.
getRoleid
()));
roleIds
.
forEach
(
roleid
->
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_"
+
roleid
)));
SysRolePermissionSearchContext
context
=
new
SysRolePermissionSearchContext
();
context
.
getSelectCond
().
in
(
"sys_roleid"
,
roleIds
).
eq
(
"permissionenable"
,
1
).
orderByAsc
(
"permissiontype"
,
"sys_permissionid"
);
context
.
setSize
(
Integer
.
MAX_VALUE
);
rolePermissionService
.
searchDefault
(
context
).
forEach
(
sysRolePermission
->
{
if
(
PermissionType
.
OPPRIV
.
toString
().
equals
(
sysRolePermission
.
getPermissiontype
()))
authorities
.
add
(
new
SimpleGrantedAuthority
(
sysRolePermission
.
getPermissionid
()));
else
authorities
.
add
(
new
SimpleGrantedAuthority
(
sysRolePermission
.
getPermissiontype
()+
"_"
+
sysRolePermission
.
getPermissionid
()));
});
return
authorities
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录