Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
2a2c181b
提交
2a2c181b
authored
7月 14, 2021
作者:
wangjiahao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:移除无用代码
上级
7334a76c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
0 行增加
和
72 行删除
+0
-72
SysAuthController.java
...in/java/io/dataease/controller/sys/SysAuthController.java
+0
-15
SysAuthService.java
...src/main/java/io/dataease/service/sys/SysAuthService.java
+0
-57
没有找到文件。
backend/src/main/java/io/dataease/controller/sys/SysAuthController.java
浏览文件 @
2a2c181b
...
@@ -2,10 +2,8 @@ package io.dataease.controller.sys;
...
@@ -2,10 +2,8 @@ package io.dataease.controller.sys;
import
io.dataease.base.domain.SysAuthDetail
;
import
io.dataease.base.domain.SysAuthDetail
;
import
io.dataease.controller.handler.annotation.I18n
;
import
io.dataease.controller.handler.annotation.I18n
;
import
io.dataease.controller.request.BaseTreeRequest
;
import
io.dataease.controller.request.SysAuthRequest
;
import
io.dataease.controller.request.SysAuthRequest
;
import
io.dataease.dto.SysAuthDetailDTO
;
import
io.dataease.dto.SysAuthDetailDTO
;
import
io.dataease.dto.VAuthModelDTO
;
import
io.dataease.service.sys.SysAuthService
;
import
io.dataease.service.sys.SysAuthService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -30,13 +28,6 @@ public class SysAuthController {
...
@@ -30,13 +28,6 @@ public class SysAuthController {
@Resource
@Resource
private
SysAuthService
sysAuthService
;
private
SysAuthService
sysAuthService
;
@ApiOperation
(
"查询视图"
)
@PostMapping
(
"/authModels"
)
@I18n
public
List
<
VAuthModelDTO
>
authModels
(
@RequestBody
BaseTreeRequest
request
){
return
sysAuthService
.
searchAuthModelTree
(
request
);
}
@ApiOperation
(
"查询授权"
)
@ApiOperation
(
"查询授权"
)
@PostMapping
(
"/authDetails"
)
@PostMapping
(
"/authDetails"
)
...
@@ -52,10 +43,4 @@ public class SysAuthController {
...
@@ -52,10 +43,4 @@ public class SysAuthController {
return
sysAuthService
.
searchAuthDetailsModel
(
authType
);
return
sysAuthService
.
searchAuthDetailsModel
(
authType
);
}
}
@ApiOperation
(
"修改权限"
)
@PostMapping
(
"/authChange"
)
public
void
authChange
(
@RequestBody
SysAuthRequest
request
){
sysAuthService
.
authChange
(
request
);
}
}
}
backend/src/main/java/io/dataease/service/sys/SysAuthService.java
浏览文件 @
2a2c181b
...
@@ -7,13 +7,11 @@ import io.dataease.base.domain.SysAuthDetail;
...
@@ -7,13 +7,11 @@ import io.dataease.base.domain.SysAuthDetail;
import
io.dataease.base.mapper.SysAuthMapper
;
import
io.dataease.base.mapper.SysAuthMapper
;
import
io.dataease.base.mapper.ext.ExtSysAuthDetailMapper
;
import
io.dataease.base.mapper.ext.ExtSysAuthDetailMapper
;
import
io.dataease.base.mapper.ext.ExtSysAuthMapper
;
import
io.dataease.base.mapper.ext.ExtSysAuthMapper
;
import
io.dataease.base.mapper.ext.ExtVAuthModelMapper
;
import
io.dataease.commons.constants.SystemConstants
;
import
io.dataease.commons.constants.SystemConstants
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.controller.request.BaseTreeRequest
;
import
io.dataease.controller.request.BaseTreeRequest
;
import
io.dataease.controller.request.SysAuthRequest
;
import
io.dataease.controller.request.SysAuthRequest
;
import
io.dataease.dto.SysAuthDetailDTO
;
import
io.dataease.dto.SysAuthDetailDTO
;
import
io.dataease.dto.VAuthModelDTO
;
import
io.dataease.i18n.Translator
;
import
io.dataease.i18n.Translator
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -38,30 +36,11 @@ public class SysAuthService {
...
@@ -38,30 +36,11 @@ public class SysAuthService {
@Resource
@Resource
private
ExtSysAuthDetailMapper
extSysAuthDetailMapper
;
private
ExtSysAuthDetailMapper
extSysAuthDetailMapper
;
@Resource
private
ExtVAuthModelMapper
extVAuthModelMapper
;
private
static
List
<
String
>
PRI_MODEL_TYPE
=
Arrays
.
asList
(
"link"
,
"dataset"
,
"chart"
,
"panel"
,
"menu"
);
private
static
List
<
String
>
PRI_MODEL_TYPE
=
Arrays
.
asList
(
"link"
,
"dataset"
,
"chart"
,
"panel"
,
"menu"
);
/**
* @Description: 查询可见授权数据的数据如果是管理员(IsAdmin = true)且modelType 为link dataset chart panel menu可以查询到所有的数据,
* 如果是普通用户,只能查询到自己的数据;但是 node_type 为spine 时 节点也会返回
**/
public
List
<
VAuthModelDTO
>
searchAuthModelTree
(
BaseTreeRequest
request
)
{
CurrentUserDto
currentUserDto
=
AuthUtils
.
getUser
();
request
.
setCreateBy
(
String
.
valueOf
(
currentUserDto
.
getUserId
()));
if
(
PRI_MODEL_TYPE
.
contains
(
request
.
getModelType
())
&&
(
currentUserDto
.
getIsAdmin
()
==
null
||
!
currentUserDto
.
getIsAdmin
()))
{
request
.
setWithAuth
(
"1"
);
}
else
{
request
.
setWithAuth
(
"0"
);
}
return
extVAuthModelMapper
.
searchTree
(
request
);
}
/**
/**
* @Description: 查询授权明细map
* @Description: 查询授权明细map
**/
**/
...
@@ -78,42 +57,6 @@ public class SysAuthService {
...
@@ -78,42 +57,6 @@ public class SysAuthService {
return
extSysAuthDetailMapper
.
searchAuthTypeModel
(
authType
);
return
extSysAuthDetailMapper
.
searchAuthTypeModel
(
authType
);
}
}
public
void
authChange
(
SysAuthRequest
request
)
{
SysAuthDetail
sysAuthDetail
=
request
.
getAuthDetail
();
//TODO 获取需要授权的资源id(当前节点和所有权限的下级节点)
List
<
String
>
authSources
=
getAuthModels
(
request
.
getAuthSource
(),
request
.
getAuthSourceType
());
if
(
CollectionUtils
.
isEmpty
(
authSources
))
{
throw
new
RuntimeException
(
Translator
.
get
(
"i18n_auth_source_be_canceled"
));
}
//TODO 获取需要被授权的目标id(部门当前节点和所有权限的下级节点)
List
<
String
>
authTargets
=
getAuthModels
(
request
.
getAuthTarget
(),
request
.
getAuthTargetType
());
if
(
CollectionUtils
.
isNotEmpty
(
authSources
)
&&
CollectionUtils
.
isNotEmpty
(
authTargets
))
{
List
<
String
>
authIdChange
=
new
ArrayList
<>();
authTargets
.
stream
().
forEach
(
authTarget
->
{
authSources
.
forEach
(
authSource
->
{
String
authId
=
checkAuth
(
authSource
,
request
.
getAuthSourceType
(),
authTarget
,
request
.
getAuthTargetType
());
authIdChange
.
add
(
authId
);
});
});
// 授权修改
if
(
sysAuthDetail
.
getPrivilegeValue
()
==
SystemConstants
.
PRIVILEGE_VALUE
.
ON
)
{
//当前为开启1 >>> 关闭0 需要将权限级别(PrivilegeType)大于当前级别的全新都修改为关闭 0
extSysAuthDetailMapper
.
authDetailsChange
(
SystemConstants
.
PRIVILEGE_VALUE
.
OFF
,
sysAuthDetail
.
getPrivilegeType
(),
authIdChange
);
}
else
{
//当前为关闭0 >>> 开启1 需要将权限级别(PrivilegeType)小于当前级别的全新都修改为开启 1
extSysAuthDetailMapper
.
authDetailsChange
(
SystemConstants
.
PRIVILEGE_VALUE
.
ON
,
sysAuthDetail
.
getPrivilegeType
(),
authIdChange
);
}
}
}
private
List
<
String
>
getAuthModels
(
String
id
,
String
type
)
{
List
<
VAuthModelDTO
>
vAuthModelDTOS
=
searchAuthModelTree
(
new
BaseTreeRequest
(
id
,
type
,
SystemConstants
.
WITH_EXTEND
.
CHILDREN
));
List
<
String
>
authSources
=
Optional
.
ofNullable
(
vAuthModelDTOS
).
orElse
(
new
ArrayList
<>()).
stream
().
map
(
VAuthModelDTO:
:
getId
)
.
collect
(
Collectors
.
toList
());
return
authSources
;
}
/**
/**
* @Description: 查询当前target 是否有存在授权 不存在 增加权限 并复制权限模板
* @Description: 查询当前target 是否有存在授权 不存在 增加权限 并复制权限模板
**/
**/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论