mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
fix: 修复无法设置角色的bug
This commit is contained in:
@@ -237,7 +237,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
});
|
||||
}
|
||||
|
||||
async delete(id: number) {
|
||||
async delete(id: any) {
|
||||
await this.clearTriggers(id);
|
||||
//TODO 删除storage
|
||||
// const storage = new DbStorage(pipeline.userId, this.storageService);
|
||||
|
||||
@@ -29,8 +29,8 @@ export class RoleService extends BaseService<RoleEntity> {
|
||||
ttl: 1000 * 60 * 10,
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ getRepository() {
|
||||
return;
|
||||
}
|
||||
//先删除所有
|
||||
await this.userRoleService.delete({ userId });
|
||||
await this.userRoleService.deleteWhere({ userId });
|
||||
//再添加
|
||||
await this.addRoles(userId, roles);
|
||||
|
||||
@@ -95,7 +95,7 @@ getRepository() {
|
||||
}
|
||||
|
||||
async authz(roleId: any, permissionIds: any) {
|
||||
await this.rolePermissionService.delete({ roleId });
|
||||
await this.rolePermissionService.deleteWhere({ roleId });
|
||||
for (const permissionId of permissionIds) {
|
||||
await this.rolePermissionService.add({
|
||||
roleId,
|
||||
@@ -125,4 +125,12 @@ getRepository() {
|
||||
this.permissionCache.set(roleIdsKey, permissionSet);
|
||||
return permissionSet;
|
||||
}
|
||||
|
||||
async delete(id: any) {
|
||||
const idArr = this.resolveIdArr(id);
|
||||
const urs = await this.userRoleService.find({ where: { roleId: In(idArr) } });
|
||||
if (urs.length > 0) {
|
||||
throw new Error('该角色已被用户使用,无法删除');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user