SysHelpsApplicationService.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Linq.Dynamic.Core;
  4. using System.Threading.Tasks;
  5. using Abp.Application.Services.Dto;
  6. using Abp.Authorization;
  7. using Abp.Domain.Repositories;
  8. using Abp.Extensions;
  9. using IwbZero.AppServiceBase;
  10. using ShwasherSys.Authorization.Permissions;
  11. using ShwasherSys.Authorization.Users;
  12. using ShwasherSys.BaseSysInfo.Help.Dto;
  13. using ShwasherSys.BaseSysInfo.States;
  14. using ShwasherSys.BaseSysInfo.Users.Dto;
  15. using ShwasherSys.Lambda;
  16. namespace ShwasherSys.BaseSysInfo.Help
  17. {
  18. [AbpAuthorize]
  19. public class SysHelpsAppService : ShwasherAsyncCrudAppService<SysHelp, SysHelpDto, int, PagedRequestDto, SysHelpCreateDto, SysHelpUpdateDto >, ISysHelpsAppService
  20. {
  21. private IStatesAppService StatesAppService;
  22. public SysHelpsAppService(IStatesAppService statesAppService,IRepository<SysHelp, int> repository) : base(repository)
  23. {
  24. StatesAppService = statesAppService;
  25. }
  26. protected override string GetPermissionName { get; set; } = PermissionNames.PagesSystemSysHelp;
  27. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesSystemSysHelp;
  28. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesSystemSysHelpCreate;
  29. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesSystemSysHelpUpdate;
  30. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesSystemSysHelpDelete;
  31. [AbpAuthorize(PermissionNames.PagesSystemSysHelp)]
  32. public override async Task<PagedResultDto<SysHelpDto>> GetAll(PagedRequestDto input)
  33. {
  34. var query = Repository.GetAll();
  35. if (input.SearchList != null && input.SearchList.Count > 0)
  36. {
  37. List<LambdaObject> objList = new List<LambdaObject>();
  38. foreach (var o in input.SearchList)
  39. {
  40. if (o.KeyWords.IsNullOrEmpty())
  41. continue;
  42. object keyWords = o.KeyWords;
  43. objList.Add(new LambdaObject
  44. {
  45. FieldType = (LambdaFieldType)o.FieldType,
  46. FieldName = o.KeyField,
  47. FieldValue = keyWords,
  48. ExpType = (LambdaExpType)o.ExpType
  49. });
  50. }
  51. var exp = objList.GetExp<SysHelp>();
  52. query = query.Where(exp);
  53. }
  54. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  55. query = ApplySorting(query, input);
  56. query = ApplyPaging(query, input);
  57. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  58. var dtos = new PagedResultDto<SysHelpDto>(totalCount, entities.Select(a=>new SysHelpDto()
  59. {
  60. Id = a.Id,
  61. Classification= a.Classification,
  62. ClassificationShow = StatesAppService.GetDisplayValue("SysHelp", "Classification", a.Classification + ""),
  63. HelpContent = a.HelpContent,
  64. HelpKeyWords = a.HelpKeyWords,
  65. Sequence = a.Sequence,
  66. TimeCreated = a.TimeCreated,
  67. HelpTitle = a.HelpTitle,
  68. TimeLastMod = a.TimeLastMod,
  69. UserIDLastMod = a.UserIDLastMod
  70. }).ToList());
  71. return dtos;
  72. }
  73. }
  74. }