瀏覽代碼

fixed: role update

xf 1 年之前
父節點
當前提交
0e8d34bd63
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/Hotline.Api/Controllers/RoleController.cs

+ 4 - 1
src/Hotline.Api/Controllers/RoleController.cs

@@ -136,7 +136,10 @@ public class RoleController : BaseController
     [HttpPut]
     public async Task Update([FromBody] UpdateRoleDto dto)
     {
-        await _roleRepository.UpdateAsync(_mapper.Map<Role>(dto), HttpContext.RequestAborted);
+        var role = await _roleRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+        if (role == null) throw new UserFriendlyException("无效角色编号");
+        _mapper.Map(dto, role);
+        await _roleRepository.UpdateAsync(role, HttpContext.RequestAborted);
     }
 
     #region 应用权限管理