소스 검색

修改接口

Dun.Jason 2 년 전
부모
커밋
7364749f02
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      src/Hotline.Api/Controllers/RoleController.cs

+ 9 - 3
src/Hotline.Api/Controllers/RoleController.cs

@@ -101,12 +101,18 @@ public class RoleController : BaseController
     public async Task AllocationAuthority(RoleAuthorityDto dto)
     {
         //判断是否存在,如果存在就做更新
-        var ishas =await _systemAuthorityRepository.AnyAsync(x => x.RoleId == dto.RoleId);
-        var model = _mapper.Map<SystemAuthority>(dto);
-        if (!ishas)
+        var model = await _systemAuthorityRepository.GetAsync(x => x.RoleId == dto.RoleId);
+        if (model is null)
+        {
+            model = _mapper.Map<SystemAuthority>(dto);
             await _systemAuthorityRepository.AddAsync(model);
+        }
         else
+        {
+            _mapper.Map(dto, model);
             await _systemAuthorityRepository.UpdateAsync(model);
+        }
+            
     }
 
     /// <summary>