BulletinInfosApplicationService.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.Auditing;
  7. using Abp.Authorization;
  8. using Abp.Domain.Repositories;
  9. using Abp.Extensions;
  10. using IwbZero.AppServiceBase;
  11. using ShwasherSys.Authorization.Permissions;
  12. using ShwasherSys.BaseSysInfo.States;
  13. using ShwasherSys.Lambda;
  14. using ShwasherSys.NotificationInfo.Dto;
  15. namespace ShwasherSys.NotificationInfo
  16. {
  17. [AbpAuthorize]
  18. public class BulletinInfosAppService : ShwasherAsyncCrudAppService<BulletinInfo, BulletinInfoDto, int, PagedRequestDto, BulletinInfoCreateDto, BulletinInfoUpdateDto >,IBulletinInfosAppService
  19. {
  20. protected IStatesAppService StatesAppService;
  21. public BulletinInfosAppService(IRepository<BulletinInfo, int> repository, IStatesAppService statesAppService) : base(repository)
  22. {
  23. StatesAppService = statesAppService;
  24. }
  25. protected override string GetPermissionName { get; set; } = PermissionNames.PagesNotificationInfoBulletinInfos;
  26. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesNotificationInfoBulletinInfos;
  27. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesNotificationInfoBulletinInfosCreate;
  28. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesNotificationInfoBulletinInfosUpdate;
  29. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesNotificationInfoBulletinInfosDelete;
  30. [DisableAuditing]
  31. public override async Task<PagedResultDto<BulletinInfoDto>> GetAll(PagedRequestDto input)
  32. {
  33. CheckGetAllPermission();
  34. var query = CreateFilteredQuery(input);
  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<BulletinInfo>();
  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<BulletinInfoDto>(
  59. totalCount,
  60. entities.Select(i=>new BulletinInfoDto()
  61. {
  62. BulletinType = i.BulletinType,
  63. BulletinTypeName = StatesAppService.GetDisplayValue("BulletinInfo", "BulletinType", i.BulletinType),
  64. Content = i.Content,
  65. ExpirationDate = i.ExpirationDate,
  66. Id = i.Id,
  67. PromulgatTime = i.PromulgatTime,
  68. Promulgator = i.Promulgator,
  69. TimeLastMod = i.TimeLastMod,
  70. TimeCreated = i.TimeCreated,
  71. Title = i.Title
  72. }).ToList()
  73. );
  74. return dtos;
  75. }
  76. }
  77. }