提交 1be642ae authored 作者: wangjiahao's avatar wangjiahao

feat: 用户权限可被收回

上级 83a243e1
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
authCount.children_count AS children_count, authCount.children_count AS children_count,
IF IF
(( authCount.children_count > 0 ), 0, 1 ) AS leaf (( authCount.children_count > 0 ), 0, 1 ) AS leaf
FROM FROM (select get_grant_auths (#{modelType},#{createBy}) cids1) t1,
( SELECT * FROM v_auth_model ( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids2) t2 ,v_auth_model
<where> <where>
model_type = #{modelType} model_type = #{modelType}
<if test="createBy != null"> <if test="1== withAuth">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from v_auth_model where model_type = #{modelType} and create_by =#{createBy}) ,#{modelType})) and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids2 ,#{modelType}))
</if> </if>
<if test="pid !=null"> <if test="pid !=null">
and v_auth_model.pid = #{pid} and v_auth_model.pid = #{pid}
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
count( 1 ) AS `children_count`, count( 1 ) AS `children_count`,
`authTemp`.`pid` AS `pid` `authTemp`.`pid` AS `pid`
FROM FROM
( SELECT * FROM v_auth_model ( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids3) t3,v_auth_model
<where> <where>
model_type = #{modelType} model_type = #{modelType}
<if test="createBy != null"> <if test="1== withAuth">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from v_auth_model where model_type = #{modelType} and create_by =#{createBy}) ,#{modelType})) and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids3 ,#{modelType}))
</if> </if>
</where> </where>
) authTemp ) authTemp
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
) authCount ON ) authCount ON
auth.id = authCount.pid auth.id = authCount.pid
<where> <where>
<if test="createBy != null"> <if test="1== withAuth">
(authCount.children_count>0 or auth.create_by = #{createBy}) (authCount.children_count>0 or FIND_IN_SET(auth.id,cids1) )
</if> </if>
</where> </where>
......
...@@ -26,6 +26,9 @@ public class BaseTreeRequest { ...@@ -26,6 +26,9 @@ public class BaseTreeRequest {
private String createBy; private String createBy;
private String withAuth;//需要根据权限返回
public BaseTreeRequest() { public BaseTreeRequest() {
} }
......
...@@ -40,18 +40,20 @@ public class SysAuthService { ...@@ -40,18 +40,20 @@ public class SysAuthService {
@Resource @Resource
private ExtVAuthModelMapper extVAuthModelMapper; private ExtVAuthModelMapper extVAuthModelMapper;
private static List<String> PRI_MODEL_TYPE = Arrays.asList("link","dataset","chart","panel"); private static List<String> PRI_MODEL_TYPE = Arrays.asList("link","dataset","chart","panel","menu");
/** /**
* @Description: 查询可见授权数据的数据如果是管理员(IsAdmin = true)且modelType 为link dataset chart panel可以查询到所有的数据, * @Description: 查询可见授权数据的数据如果是管理员(IsAdmin = true)且modelType 为link dataset chart panel menu可以查询到所有的数据,
* 如果是普通用户,只能查询到自己的数据;但是 node_type 为spine 时 节点也会返回 * 如果是普通用户,只能查询到自己的数据;但是 node_type 为spine 时 节点也会返回
**/ **/
public List<VAuthModelDTO> searchAuthModelTree(BaseTreeRequest request) { public List<VAuthModelDTO> searchAuthModelTree(BaseTreeRequest request) {
CurrentUserDto currentUserDto = AuthUtils.getUser(); CurrentUserDto currentUserDto = AuthUtils.getUser();
request.setCreateBy(null); request.setCreateBy(String.valueOf(currentUserDto.getUserId()));
if(PRI_MODEL_TYPE.contains(request.getModelType())&&(currentUserDto.getIsAdmin() == null || !currentUserDto.getIsAdmin())){ if(PRI_MODEL_TYPE.contains(request.getModelType())&&(currentUserDto.getIsAdmin() == null || !currentUserDto.getIsAdmin())){
request.setCreateBy(currentUserDto.getUsername()); request.setWithAuth("1");
}else{
request.setWithAuth("0");
} }
return extVAuthModelMapper.searchTree(request); return extVAuthModelMapper.searchTree(request);
} }
......
...@@ -226,6 +226,7 @@ i18n_auth_view=View ...@@ -226,6 +226,7 @@ i18n_auth_view=View
i18n_auth_use=Use i18n_auth_use=Use
i18n_auth_export=Export i18n_auth_export=Export
i18n_auth_manage=Manage i18n_auth_manage=Manage
i18n_auth_grant=Grant
i18n_template_system=System Template i18n_template_system=System Template
i18n_template_self=Self Template i18n_template_self=Self Template
i18n_name_cant_repeat_same_group=Name is already exists in the same group i18n_name_cant_repeat_same_group=Name is already exists in the same group
......
...@@ -227,6 +227,7 @@ i18n_auth_view=查看 ...@@ -227,6 +227,7 @@ i18n_auth_view=查看
i18n_auth_use=使用 i18n_auth_use=使用
i18n_auth_export=导出 i18n_auth_export=导出
i18n_auth_manage=管理 i18n_auth_manage=管理
i18n_auth_grant=授权
i18n_template_system=系统模板 i18n_template_system=系统模板
i18n_template_self=用户模板 i18n_template_self=用户模板
i18n_name_cant_repeat_same_group=同一分组下名称不能重复 i18n_name_cant_repeat_same_group=同一分组下名称不能重复
......
...@@ -227,6 +227,7 @@ i18n_auth_view=查看 ...@@ -227,6 +227,7 @@ i18n_auth_view=查看
i18n_auth_use=使用 i18n_auth_use=使用
i18n_auth_export=導出 i18n_auth_export=導出
i18n_auth_manage=管理 i18n_auth_manage=管理
i18n_auth_grant=授权
i18n_template_system=系統模板 i18n_template_system=系統模板
i18n_template_self=用戶模板 i18n_template_self=用戶模板
i18n_name_cant_repeat_same_group=同一分組下名稱不能重復 i18n_name_cant_repeat_same_group=同一分組下名稱不能重復
......
...@@ -940,6 +940,7 @@ export default { ...@@ -940,6 +940,7 @@ export default {
datasetAuth: '数据集权限', datasetAuth: '数据集权限',
chartAuth: '视图权限', chartAuth: '视图权限',
panelAuth: '仪表盘权限', panelAuth: '仪表盘权限',
menuAuth: '菜单和操作权限',
deptHead: '所有组织', deptHead: '所有组织',
roleHead: '所有角色', roleHead: '所有角色',
userHead: '所有用户', userHead: '所有用户',
...@@ -947,6 +948,7 @@ export default { ...@@ -947,6 +948,7 @@ export default {
datasetAuthHead: '所有数据', datasetAuthHead: '所有数据',
chartAuthHead: '所有视图', chartAuthHead: '所有视图',
panelAuthHead: '所有仪表盘', panelAuthHead: '所有仪表盘',
menuAuthHead: '所有菜单和操作',
view: '查看', view: '查看',
use: '使用', use: '使用',
export: '导出', export: '导出',
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</el-input> </el-input>
</div> </div>
<el-tabs v-model="sourceActiveName" :class="{'de-search-header': showSourceSearchInput}" @tab-click="handleClick"> <el-tabs v-model="sourceActiveName" :class="{'de-search-header': showSourceSearchInput}" @tab-click="handleClick">
<el-tab-pane v-for="(sourceInfo, index) in sourceInfoArray" :key="index" :lazy="true" :label="sourceInfo.tabName" :name="sourceInfo.authType"> <el-tab-pane v-for="(sourceInfo, index) in sourceInfoTabs" :key="index" :lazy="true" :label="sourceInfo.tabName" :name="sourceInfo.authType">
<lazy-tree <lazy-tree
v-if="authCondition" v-if="authCondition"
:active-name="sourceActiveName" :active-name="sourceActiveName"
...@@ -86,26 +86,39 @@ export default { ...@@ -86,26 +86,39 @@ export default {
tabName: this.$t('auth.linkAuth'), tabName: this.$t('auth.linkAuth'),
head: this.$t('auth.linkAuthHead'), head: this.$t('auth.linkAuthHead'),
direction: 'source', direction: 'source',
authType: 'link' authType: 'link',
authTargets: 'dept,role,user'
}, },
{ {
tabName: this.$t('auth.datasetAuth'), tabName: this.$t('auth.datasetAuth'),
head: this.$t('auth.datasetAuthHead'), head: this.$t('auth.datasetAuthHead'),
direction: 'source', direction: 'source',
authType: 'dataset' authType: 'dataset',
authTargets: 'dept,role,user'
}, },
{ {
tabName: this.$t('auth.chartAuth'), tabName: this.$t('auth.chartAuth'),
head: this.$t('auth.linkAuthHead'), head: this.$t('auth.linkAuthHead'),
direction: 'source', direction: 'source',
authType: 'chart' authType: 'chart',
authTargets: 'dept,role,user'
}, },
{ {
tabName: this.$t('auth.panelAuth'), tabName: this.$t('auth.panelAuth'),
head: this.$t('auth.panelAuthHead'), head: this.$t('auth.panelAuthHead'),
direction: 'source', direction: 'source',
authType: 'panel' authType: 'panel',
}], authTargets: 'dept,role,user'
}
// ,
// {
// tabName: this.$t('auth.menuAuth'),
// head: this.$t('auth.menuAuthHead'),
// direction: 'source',
// authType: 'menu',
// authTargets: 'role'
// }
],
targetActiveName: null, targetActiveName: null,
sourceActiveName: null, sourceActiveName: null,
showSourceSearchInput: false, showSourceSearchInput: false,
...@@ -116,6 +129,17 @@ export default { ...@@ -116,6 +129,17 @@ export default {
authCondition: null authCondition: null
} }
}, },
computed: {
sourceInfoTabs() {
const tabs = []
this.sourceInfoArray.forEach(item => {
if (item.authTargets.indexOf(this.targetActiveName) > -1) {
tabs.push(item)
}
})
return tabs
}
},
created() { created() {
this.targetActiveName = this.targetInfoArray[0].authType this.targetActiveName = this.targetInfoArray[0].authType
this.sourceActiveName = this.sourceInfoArray[0].authType this.sourceActiveName = this.sourceInfoArray[0].authType
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论