public async Task UpdateAsync(string id, RoleUpdateDto role, IEnumerable <string> allowedClientIds = null) { var existed = await _roleRepo.GetAsync(id, isReadonly : false); if (existed == null) { throw new IamException(HttpStatusCode.NotFound, "角色不存在"); } if (allowedClientIds != null && !allowedClientIds.Contains(existed.ClientId)) { throw new IamException(HttpStatusCode.BadRequest, "无权操作!"); } if (!String.IsNullOrWhiteSpace(role.Name) && existed.Name != role.Name) { if (await _roleRepo.IsExistedAsync(role.Name, existed.ClientId)) { throw new IamException(HttpStatusCode.BadRequest, "该名称的权限已经存在"); } } existed.Update(role.Name, role.Desc, role.IsAdmin); }
public async Task <Role> FindByIdAsync(string roleId, CancellationToken token) { return(await _roleRepo.GetAsync(roleId)); }