AuthManager.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 HZY.Framework.DependencyInjection;
  10. using Mapster;
  11. using Model;
  12. namespace BLL.Manager
  13. {
  14. public class AuthManager:IScopedSelfDependency
  15. {
  16. private readonly AuthService _authService;
  17. public AuthManager(AuthService authService)
  18. {
  19. _authService = authService;
  20. }
  21. public async Task<BaseResult> UpdateAuthAsync(UpdateAuthDto request)
  22. {
  23. var entity = request.Adapt<AuthEntity>();
  24. var res = await _authService.UpdateAsync(entity);
  25. if (res)
  26. {
  27. return new BaseResult() { Result = SystemEnums.Result.Success };
  28. }
  29. return new BaseResult() { Result = SystemEnums.Result.Fail, Msg = "更新权限失败" };
  30. }
  31. public async Task<BaseResult<QueryAuthResultDto>> GetAuthAsync(QueryAuthDto request)
  32. {
  33. var res = await _authService.GetByOneAsync(c => c.Role == request.Role);
  34. return new BaseResult<QueryAuthResultDto>() { Result = SystemEnums.Result.Success, Data = new List<QueryAuthResultDto>() { res.Adapt<QueryAuthResultDto>() } };
  35. }
  36. }
  37. }