Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
38637162
提交
38637162
编写于
5月 09, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
统一资源
上级
0015db1f
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
110 行增加
和
10 行删除
+110
-10
ClientAuthenticationResource.java
...lab/api/rest/extensions/ClientAuthenticationResource.java
+49
-4
PermissionFeignService.java
...n/ibizlab/api/rest/extensions/PermissionFeignService.java
+61
-6
未找到文件。
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/ClientAuthenticationResource.java
浏览文件 @
38637162
...
...
@@ -38,6 +38,10 @@ public class ClientAuthenticationResource
* 实体操作标识
*/
private
String
OPPriTag
=
"OPPRIV"
;
/**
* 统一资源标识
*/
private
String
UniResTag
=
"UNIRES"
;
@Autowired
@Qualifier
(
"IBZUSERService"
)
...
...
@@ -107,18 +111,59 @@ public class ClientAuthenticationResource
"\t)\n"
+
"AND T1.PERMISSIONTYPE = '%s' "
;
List
<
JSONObject
>
userPermission
=
permissionService
.
select
(
String
.
format
(
opprivSQL
,
user
.
getUserid
(),
OPPriTag
));
//查询用户权限下的菜单数据
JSONObject
userPermissionList
=
getUserPermissionList
(
userPermission
);
permissionObj
.
put
(
"userPermissionList"
,
userPermissionList
);
String
uniResSQL
=
"SELECT\n"
+
"\tt2.SYS_PSSYSUNIRESID,\n"
+
"\tt2.SYS_PSSYSUNIRESNAME,\n"
+
"\tT2.UNIRESCODE \n"
+
"FROM\n"
+
"\tibzrole_permission T\n"
+
"INNER JOIN ibzpermission T1 ON T.SYS_PERMISSIONID = T1.SYS_PERMISSIONID\n"
+
"INNER JOIN IBZPSSYSUNIRES T2 on T1.SYS_PERMISSIONID=t2.SYS_PSSYSUNIRESID\n"
+
"WHERE\n"
+
"\tT.SYS_ROLEID IN (\n"
+
"\t SELECT SYS_ROLEID\n"
+
"\t FROM\n"
+
"\t IBZUSER_ROLE t LEFT JOIN IBZUSER t1 ON t.SYS_USERID=T1.USERID\n"
+
"\t WHERE\n"
+
"\t T1.USERID = '%s'\n"
+
"\t)\n"
+
"AND T1.PERMISSIONTYPE = '%s' "
;
List
<
JSONObject
>
entitiesList
=
permissionService
.
select
(
String
.
format
(
opprivSQL
,
user
.
getUserid
(),
OPPriTag
));
//查询用户权限下的菜单数据
List
<
JSONObject
>
uniResList
=
permissionService
.
select
(
String
.
format
(
uniResSQL
,
user
.
getUserid
(),
UniResTag
));
//查询用户权限下的菜单数据
JSONObject
entities
=
getEntitiesList
(
entitiesList
);
JSONArray
uniRes
=
getUniRes
(
uniResList
);
permissionObj
.
put
(
"entities"
,
entities
);
permissionObj
.
put
(
"unires"
,
uniRes
);
user
.
setPermisionList
(
permissionObj
);
}
/**
* 获取统一资源
* @param uniResList
* @return
*/
private
JSONArray
getUniRes
(
List
<
JSONObject
>
uniResList
)
{
JSONArray
uniResArr
=
new
JSONArray
();
for
(
int
a
=
0
;
a
<
uniResList
.
size
();
a
++){
JSONObject
uniRes
=
uniResList
.
get
(
a
);
JSONObject
newUniRes
=
new
JSONObject
();
newUniRes
.
put
(
"unirescode"
,
uniRes
.
getString
(
"UNIRESCODE"
));
newUniRes
.
put
(
"uniresname"
,
uniRes
.
getString
(
"SYS_PSSYSUNIRESNAME"
));
uniResArr
.
add
(
newUniRes
);
}
return
uniResArr
;
}
/**
* 拼接实体行为资源
* @param role_permissions
* @return
*/
private
JSONObject
get
UserPermission
List
(
List
<
JSONObject
>
role_permissions
)
{
private
JSONObject
get
Entities
List
(
List
<
JSONObject
>
role_permissions
)
{
JSONObject
permission_entity
=
new
JSONObject
();
for
(
Map
rolePermission
:
role_permissions
)
{
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/PermissionFeignService.java
浏览文件 @
38637162
...
...
@@ -2,8 +2,10 @@ package cn.ibizlab.api.rest.extensions;
import
cn.ibizlab.core.uaa.domain.SYS_PERMISSION
;
import
cn.ibizlab.core.uaa.domain.SYS_PSDEOPPRIV
;
import
cn.ibizlab.core.uaa.domain.SYS_PSSYSUNIRES
;
import
cn.ibizlab.core.uaa.service.ISYS_PERMISSIONService
;
import
cn.ibizlab.core.uaa.service.ISYS_PSDEOPPRIVService
;
import
cn.ibizlab.core.uaa.service.ISYS_PSSYSUNIRESService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
...
@@ -30,6 +32,10 @@ public class PermissionFeignService {
* 实体操作标识
*/
private
String
OPPriTag
=
"OPPRIV"
;
/**
* 统一资源标识
*/
private
String
UniResTag
=
"UNIRES"
;
/**
* 实体行为操作标识
*/
...
...
@@ -45,6 +51,9 @@ public class PermissionFeignService {
@Autowired
private
ISYS_PSDEOPPRIVService
opprivService
;
@Autowired
private
ISYS_PSSYSUNIRESService
pssysuniresService
;
/**
* 拿到业务系统传过来的权限和菜单数据,存入uaa的权限表中
*/
...
...
@@ -54,23 +63,69 @@ public class PermissionFeignService {
if
(
map
!=
null
){
permissionService
.
execute
(
String
.
format
(
"UPDATE ibzpermission t SET t.enable=0 WHERE SYSTEMID='%s'"
,
systemId
));
}
List
<
SYS_PSDEOPPRIV
>
opprivList
=
new
ArrayList
<>();
//菜单项集合
List
<
SYS_PERMISSION
>
ability_list
=
new
ArrayList
<>();
//资源-操作能力集合
List
<
SYS_PSDEOPPRIV
>
opprivList
=
new
ArrayList
<>();
//数据能力
List
<
SYS_PERMISSION
>
permission_list
=
new
ArrayList
<>();
//权限
List
<
SYS_PSSYSUNIRES
>
unires_list
=
new
ArrayList
<>();
//统一资源
if
(
map
.
containsKey
(
"permission"
)){
JSONObject
paramsObj
=
new
JSONObject
(
map
);
JSONObject
capabilityPermissionObj
=
paramsObj
.
getJSONObject
(
"permission"
);
parseDECapability
(
capabilityPermissionObj
,
systemId
,
ability_list
,
opprivList
);
parseDECapability
(
capabilityPermissionObj
,
systemId
,
permission_list
,
opprivList
);
parseUniRes
(
capabilityPermissionObj
,
systemId
,
permission_list
,
unires_list
);
}
if
(
opprivList
.
size
()>
0
){
opprivService
.
saveOrUpdateBatch
(
opprivList
);
//批量保存数据操作标识
opprivService
.
saveOrUpdateBatch
(
opprivList
);
//批量保存数据能力
}
if
(
permission_list
.
size
()>
0
){
permissionService
.
saveOrUpdateBatch
(
permission_list
);
//批量保存权限资源
}
if
(
ability
_list
.
size
()>
0
){
p
ermissionService
.
saveOrUpdateBatch
(
ability_list
);
//批量保存数据操作标识
资源
if
(
unires
_list
.
size
()>
0
){
p
ssysuniresService
.
saveOrUpdateBatch
(
unires_list
);
//批量保存统一
资源
}
return
null
;
}
/**
* 存储统一资源
* @param capabilityPermissionObj
*/
private
void
parseUniRes
(
JSONObject
capabilityPermissionObj
,
String
systemId
,
List
<
SYS_PERMISSION
>
permission_list
,
List
<
SYS_PSSYSUNIRES
>
unires_list
)
{
if
(
capabilityPermissionObj
!=
null
){
JSONArray
uniResArr
=
capabilityPermissionObj
.
getJSONArray
(
"unires"
);
if
(
uniResArr
.
size
()>
0
){
for
(
int
a
=
0
;
a
<
uniResArr
.
size
();
a
++){
JSONObject
uniRes
=
uniResArr
.
getJSONObject
(
a
);
createUniRes
(
uniRes
,
systemId
,
permission_list
,
unires_list
);
}
}
}
}
/**
* 创建统一资源
* @param uniRes
*/
private
void
createUniRes
(
JSONObject
uniRes
,
String
systemId
,
List
<
SYS_PERMISSION
>
permission_list
,
List
<
SYS_PSSYSUNIRES
>
unires_list
)
{
String
uniResCode
=
uniRes
.
getString
(
"unirescode"
);
String
uniResName
=
uniRes
.
getString
(
"uniresname"
);
String
uniResId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s"
,
systemId
,
uniResCode
).
getBytes
());
SYS_PERMISSION
sys_permission
=
new
SYS_PERMISSION
();
sys_permission
.
setPermissionid
(
uniResId
);
sys_permission
.
setPermissionname
(
uniResName
);
sys_permission
.
setPssystemid
(
systemId
);
sys_permission
.
setPermissiontype
(
UniResTag
);
sys_permission
.
setEnable
(
1
);
permission_list
.
add
(
sys_permission
);
SYS_PSSYSUNIRES
sys_pssysunires
=
new
SYS_PSSYSUNIRES
();
sys_pssysunires
.
setSysPssysuniresid
(
uniResId
);
sys_pssysunires
.
setSysPssysuniresname
(
uniResName
);
sys_pssysunires
.
setUnirescode
(
uniResCode
);
unires_list
.
add
(
sys_pssysunires
);
}
/**
* 保存实体数据能力
* @param permission
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录