AuthManager.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BLL.Dto.AuthDto;
  7. using DAL.Services;
  8. using Helper;
  9. using Mapster;
  10. using Model;
  11. namespace BLL.Manager
  12. {
  13. public class AuthManager
  14. {
  15. private readonly AuthService _authService;
  16. public AuthManager(AuthService authService)
  17. {
  18. _authService = authService;
  19. }
  20. public async Task<BaseResult> UpdateAuthAsync(UpdateAuthDto request)
  21. {
  22. var entity = request.Adapt<AuthEntity>();
  23. var res = await _authService.UpdateAsync(entity);
  24. if (res)
  25. {
  26. return new BaseResult() { Result = SystemEnums.Result.Success };
  27. }
  28. return new BaseResult() { Result = SystemEnums.Result.Fail, Msg = "更新权限失败" };
  29. }
  30. public async Task<BaseResult<QueryAuthResultDto>> GetAuthAsync(QueryAuthDto request)
  31. {
  32. var res = await _authService.GetByOneAsync(c => c.Role == request.Role);
  33. return new BaseResult<QueryAuthResultDto>() { Result = SystemEnums.Result.Success, Data = new List<QueryAuthResultDto>() { res.Adapt<QueryAuthResultDto>() } };
  34. }
  35. }
  36. }