Sfoglia il codice sorgente

fixed: role update

xf 1 anno fa
parent
commit
0e8d34bd63
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  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 应用权限管理