From b9780a9d03f05357e23368da170210d965fb81ac Mon Sep 17 00:00:00 2001 From: sanqi377 Date: Fri, 14 Apr 2023 10:01:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=8F=8A=E9=83=A8=E9=97=A8=E6=9D=83=E9=99=90=E8=BF=87=E5=A4=9A?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/base/service/sys/role.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/base/service/sys/role.ts b/src/modules/base/service/sys/role.ts index d42c99f..95b494d 100644 --- a/src/modules/base/service/sys/role.ts +++ b/src/modules/base/service/sys/role.ts @@ -66,14 +66,18 @@ export class BaseSysRoleService extends BaseService { async updatePerms(roleId, menuIdList?, departmentIds = []) { // 更新菜单权限 await this.baseSysRoleMenuEntity.delete({ roleId }); - for (const e of menuIdList) { - await this.baseSysRoleMenuEntity.save({ roleId, menuId: e }); - } + await Promise.all( + menuIdList.map(async e => { + return await this.baseSysRoleMenuEntity.save({ roleId, menuId: e }); + }) + ); // 更新部门权限 await this.baseSysRoleDepartmentEntity.delete({ roleId }); - for (const departmentId of departmentIds) { - await this.baseSysRoleDepartmentEntity.save({ roleId, departmentId }); - } + await Promise.all( + departmentIds.map(async e => { + return await this.baseSysRoleMenuEntity.save({ roleId, departmentId: e }); + }) + ); // 刷新权限 const userRoles = await this.baseSysUserRoleEntity.findBy({ roleId }); for (const userRole of userRoles) {