|
@@ -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>
|