Merge pull request #109 from sanqi377/6.x

fix:菜单权限及部门权限过多执行慢的问题
This commit is contained in:
COOL 2023-04-17 00:24:26 +08:00 committed by GitHub
commit b172ce0ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,14 +66,18 @@ export class BaseSysRoleService extends BaseService {
async updatePerms(roleId, menuIdList?, departmentIds = []) { async updatePerms(roleId, menuIdList?, departmentIds = []) {
// 更新菜单权限 // 更新菜单权限
await this.baseSysRoleMenuEntity.delete({ roleId }); await this.baseSysRoleMenuEntity.delete({ roleId });
for (const e of menuIdList) { await Promise.all(
await this.baseSysRoleMenuEntity.save({ roleId, menuId: e }); menuIdList.map(async e => {
} return await this.baseSysRoleMenuEntity.save({ roleId, menuId: e });
})
);
// 更新部门权限 // 更新部门权限
await this.baseSysRoleDepartmentEntity.delete({ roleId }); await this.baseSysRoleDepartmentEntity.delete({ roleId });
for (const departmentId of departmentIds) { await Promise.all(
await this.baseSysRoleDepartmentEntity.save({ roleId, departmentId }); departmentIds.map(async e => {
} return await this.baseSysRoleMenuEntity.save({ roleId, departmentId: e });
})
);
// 刷新权限 // 刷新权限
const userRoles = await this.baseSysUserRoleEntity.findBy({ roleId }); const userRoles = await this.baseSysUserRoleEntity.findBy({ roleId });
for (const userRole of userRoles) { for (const userRole of userRoles) {