😎代码优化(字段和接口黑名单相关)

This commit is contained in:
zuohuaijun 2024-11-25 01:48:15 +08:00
parent 384da76e0d
commit 800225501f
5 changed files with 17 additions and 22 deletions

View File

@ -27,6 +27,9 @@ public class SysRoleApiService : ITransient
{
await _sysRoleApiRep.DeleteAsync(u => u.RoleId == input.Id);
if (input.ApiList == null || input.ApiList.Count < 1)
return;
var roleApis = input.ApiList.Where(u => !string.IsNullOrWhiteSpace(u)).Select(u => new SysRoleApi
{
RoleId = input.Id,

View File

@ -192,9 +192,6 @@ public class SysRoleService : IDynamicApiController, ITransient
[DisplayName("授权角色表格")]
public async Task GrantRoleTable(RoleTableInput input)
{
if (input.TableColumnList == null || input.TableColumnList.Count < 1)
return;
await _sysRoleTableService.GrantRoleTable(input);
}

View File

@ -41,6 +41,9 @@ public class SysRoleTableService : ITransient
{
await _sysRoleTableRep.AsDeleteable().Where(u => u.RoleId == input.Id).ExecuteCommandAsync();
if (input.TableColumnList == null || input.TableColumnList.Count < 1)
return;
var sysRoleTableList = new List<SysRoleTable>();
foreach (var item in input.TableColumnList)
{
@ -87,11 +90,11 @@ public class SysRoleTableService : ITransient
// 排除特定表格
var ignoreTables = new List<string>
{
"DingTalkUser",
"ApprovalFlow",
"GoViewPro",
"GoViewPro",
"GoViewProData"
//"DingTalkUser",
//"ApprovalFlow",
//"GoViewPro",
//"GoViewPro",
//"GoViewProData"
};
// 排除特定字段
var ignoreColumns = new List<string>

View File

@ -40,9 +40,8 @@ import NoticeBar from '/@/components/noticeBar/index.vue';
import { getAPI } from '/@/utils/axios-utils';
import { SysMenuApi, SysRoleApi } from '/@/api-services/api';
import { SysMenu, UpdateRoleInput } from '/@/api-services/models';
import { SysMenu } from '/@/api-services/models';
const ruleFormRef = ref();
const treeRef = ref<InstanceType<typeof ElTree>>();
const state = reactive({
loading: false,
@ -50,7 +49,6 @@ const state = reactive({
drawerTitle: '',
menuIdList: [] as any,
roleId: 0,
ruleForm: {} as UpdateRoleInput,
menuData: [] as Array<SysMenu>, //
});
@ -68,9 +66,7 @@ const openDrawer = async (row: any) => {
state.drawerTitle = '授权角色菜单【' + row.name + '】';
state.loading = true;
ruleFormRef.value?.resetFields();
treeRef.value?.setCheckedKeys([]); //
state.ruleForm = JSON.parse(JSON.stringify(row));
if (row.id != undefined) {
var res = await getAPI(SysRoleApi).apiSysRoleOwnMenuListGet(row.id);
setTimeout(() => {
@ -98,7 +94,7 @@ const treeNodeClass = (node: SysMenu) => {
let addClass = true; //
for (var key in node.children) {
//
if (node.children[key].children?.length ?? 0 > 0) {
if (node.children[key as any].children?.length ?? 0 > 0) {
addClass = false;
break;
}

View File

@ -40,17 +40,15 @@ import NoticeBar from '/@/components/noticeBar/index.vue';
import { getAPI } from '/@/utils/axios-utils';
import { SysRoleApi } from '/@/api-services/api';
import { RoleTableOutput, UpdateRoleInput } from '/@/api-services/models';
import { RoleTableOutput } from '/@/api-services/models';
const ruleFormRef = ref();
const treeRef = ref<InstanceType<typeof ElTree>>();
const state = reactive({
loading: false,
isVisible: false,
drawerTitle: '',
menuIdList: [] as any,
tableColumnList: [] as any,
roleId: 0,
ruleForm: {} as UpdateRoleInput,
roleTableData: [] as Array<RoleTableOutput>, //
});
@ -68,9 +66,7 @@ const openDrawer = async (row: any) => {
state.drawerTitle = '设置角色字段黑名单【' + row.name + '】';
state.loading = true;
ruleFormRef.value?.resetFields();
treeRef.value?.setCheckedKeys([]); //
state.ruleForm = JSON.parse(JSON.stringify(row));
if (row.id != undefined) {
var res = await getAPI(SysRoleApi).apiSysRoleRoleTableRoleIdGet(row.id);
setTimeout(() => {
@ -88,8 +84,8 @@ const cancel = () => {
//
const submit = async () => {
state.menuIdList = treeRef.value?.getCheckedKeys() as Array<number>; //.concat(treeRef.value?.getHalfCheckedKeys());
await getAPI(SysRoleApi).apiSysRoleGrantRoleTablePost({ id: state.roleId, tableColumnList: state.menuIdList });
state.tableColumnList = treeRef.value?.getCheckedKeys() as Array<number>; //.concat(treeRef.value?.getHalfCheckedKeys());
await getAPI(SysRoleApi).apiSysRoleGrantRoleTablePost({ id: state.roleId, tableColumnList: state.tableColumnList });
cancel();
};