Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
b6a48ff8
提交
b6a48ff8
编写于
5月 20, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
权限自定义代码
上级
5274a109
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
42 行增加
和
15 行删除
+42
-15
ClientAuthenticationResource.java
...lab/api/rest/extensions/ClientAuthenticationResource.java
+33
-9
PermissionFeignService.java
...n/ibizlab/api/rest/extensions/PermissionFeignService.java
+9
-6
未找到文件。
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/ClientAuthenticationResource.java
浏览文件 @
b6a48ff8
...
...
@@ -14,11 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -116,6 +114,7 @@ public class ClientAuthenticationResource
"\tT2.pssourceid as pssourceid,\n"
+
"\tT2.pssourcetype as pssourcetype,\n"
+
"\tT2.psdedatarangeid as dedatarange,\n"
+
"\tT1.sys_permissionid as permissionid,\n"
+
"\tT1.sys_permissionname\n"
+
"FROM\n"
+
"\tibzrole_permission T\n"
+
...
...
@@ -129,7 +128,7 @@ public class ClientAuthenticationResource
"\t WHERE\n"
+
"\t T1.USERID = #{et.param0}\n"
+
"\t)\n"
+
"AND T1.PERMISSIONTYPE = #{et.param1} "
;
"AND T1.PERMISSIONTYPE = #{et.param1}
and t1.enable=1
"
;
//统一资源
String
uniResSQL
=
"SELECT\n"
+
...
...
@@ -148,7 +147,7 @@ public class ClientAuthenticationResource
"\t WHERE\n"
+
"\t T1.USERID = #{et.param0}\n"
+
"\t)\n"
+
"AND T1.PERMISSIONTYPE = #{et.param1} "
;
"AND T1.PERMISSIONTYPE = #{et.param1}
and t1.enable=1
"
;
//应用菜单
String
appMenuSQL
=
"SELECT\n"
+
...
...
@@ -166,7 +165,7 @@ public class ClientAuthenticationResource
"\t WHERE\n"
+
"\t T1.USERID = #{et.param0}\n"
+
"\t)\n"
+
"AND T1.PERMISSIONTYPE = #{et.param1} "
;
"AND T1.PERMISSIONTYPE = #{et.param1}
and t1.enable=1
"
;
Map
opprivParam
=
new
HashMap
();
...
...
@@ -192,9 +191,34 @@ public class ClientAuthenticationResource
permissionObj
.
put
(
"entities"
,
entities
);
permissionObj
.
put
(
"unires"
,
uniRes
);
permissionObj
.
put
(
"appmenu"
,
appMenuItem
);
permissionObj
.
put
(
"authorities"
,
getAuthoritiesArray
(
user
,
entitiesList
));
user
.
setPermissionList
(
permissionObj
);
}
/**
* 获取用户资源
* @return
*/
private
JSONArray
getAuthoritiesArray
(
AuthenticationUser
user
,
List
<
JSONObject
>
dataRangeArray
)
{
JSONArray
authoritiesArray
=
new
JSONArray
();
if
(
dataRangeArray
.
size
()>
0
){
for
(
int
a
=
0
;
a
<
dataRangeArray
.
size
();
a
++){
JSONObject
dataRangeObj
=
dataRangeArray
.
get
(
a
);
String
dataRangeId
=
dataRangeObj
.
getString
(
"dedatarange"
);
String
permissionId
=
dataRangeObj
.
getString
(
"permissionid"
);
if
(
!
StringUtils
.
isEmpty
(
dataRangeId
)
&&
!
StringUtils
.
isEmpty
(
permissionId
)
&&
dataRangeId
.
equalsIgnoreCase
(
"all"
)
){
authoritiesArray
.
add
(
permissionId
);
}
}
}
if
(
user
.
getSuperuser
()==
1
){
authoritiesArray
.
add
(
"ROLE_SUPERADMIN"
);
}
return
authoritiesArray
;
}
/**
* 获取应用菜单
* @param menuItemList
...
...
@@ -205,6 +229,8 @@ public class ClientAuthenticationResource
for
(
int
a
=
0
;
a
<
menuItemList
.
size
();
a
++){
JSONObject
menuItem
=
menuItemList
.
get
(
a
);
JSONObject
newMenuItem
=
new
JSONObject
();
newMenuItem
.
put
(
"appid"
,
menuItem
.
getString
(
"MENUITEMID"
));
newMenuItem
.
put
(
"appmenuid"
,
menuItem
.
getString
(
"MENUITEMNAME"
));
newMenuItem
.
put
(
"menuitemid"
,
menuItem
.
getString
(
"MENUITEMID"
));
newMenuItem
.
put
(
"menuitemname"
,
menuItem
.
getString
(
"MENUITEMNAME"
));
menuItemArr
.
add
(
newMenuItem
);
...
...
@@ -278,6 +304,4 @@ public class ClientAuthenticationResource
user
.
setOrgInfo
(
orgInfo
);
}
}
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/PermissionFeignService.java
浏览文件 @
b6a48ff8
...
...
@@ -10,12 +10,13 @@ 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
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotBlank
;
import
java.sql.Timestamp
;
...
...
@@ -171,7 +172,7 @@ public class PermissionFeignService {
*/
private
void
saveMenuItem
(
String
menuItemId
,
String
menuItemName
,
String
parentMenuItemId
,
String
systemId
,
String
appId
,
String
appName
,
String
appMenuId
,
String
appMenuName
,
List
<
SYS_PERMISSION
>
permission_list
,
List
<
SYS_PSAPPMENUITEM
>
menu_list
){
String
sysPermissionId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s%s%s"
,
systemId
,
appId
,
appMenuId
,
menuItemId
).
getBytes
()
);
String
sysPermissionId
=
String
.
format
(
"%s-%s-%s-%s"
,
systemId
,
appId
,
appMenuId
,
menuItemId
);
SYS_PERMISSION
sys_permission
=
new
SYS_PERMISSION
();
sys_permission
.
setPermissionid
(
sysPermissionId
);
sys_permission
.
setPermissionname
(
menuItemName
);
...
...
@@ -222,7 +223,7 @@ public class PermissionFeignService {
String
uniResCode
=
uniRes
.
getString
(
"unirescode"
);
String
uniResName
=
uniRes
.
getString
(
"uniresname"
);
String
uniResId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s"
,
systemId
,
uniResCode
).
getBytes
()
);
String
uniResId
=
String
.
format
(
"%s-%s"
,
systemId
,
uniResCode
);
SYS_PERMISSION
sys_permission
=
new
SYS_PERMISSION
();
sys_permission
.
setPermissionid
(
uniResId
);
...
...
@@ -282,6 +283,8 @@ public class PermissionFeignService {
//数据查询与自定义行为不生成预置范围相关数据
if
(
(
permissionType
.
equalsIgnoreCase
(
DEActionType
)
&&
!
deActionType
.
equalsIgnoreCase
(
"BUILTIN"
))
||
(
permissionType
.
equalsIgnoreCase
(
DataSetTag
))
)
{
JSONObject
dataScope
=
new
JSONObject
();
dataScope
.
put
(
"id"
,
"all"
);
dataScope
.
put
(
"name"
,
"全部数据"
);
createDataScope
(
entity
,
deSource
,
dataScope
,
permissionType
,
systemId
,
ability_list
,
opprivList
);
}
else
{
...
...
@@ -315,7 +318,7 @@ public class PermissionFeignService {
String
dataRangeId
=
dataScope
.
getString
(
"id"
);
String
dataRangeName
=
dataScope
.
getString
(
"name"
);
String
permissionId
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%s%s%s%s"
,
systemId
,
deName
,
sourceId
,
dataRangeId
).
getBytes
()
);
String
permissionId
=
String
.
format
(
"%s-%s-%s-%s"
,
systemId
,
deName
,
sourceId
,
dataRangeId
);
String
permissionName
;
if
(!
StringUtils
.
isEmpty
(
dataRangeName
)){
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录