StoreHousesApplicationService.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.BasicInfo.StoreHouses.Dto;
  14. using ShwasherSys.Lambda;
  15. namespace ShwasherSys.BasicInfo.StoreHouses
  16. {
  17. [AbpAuthorize]
  18. public class StoreHousesAppService : ShwasherAsyncCrudAppService<StoreHouse, StoreHouseDto, int, PagedRequestDto, StoreHouseCreateDto, StoreHouseUpdateDto >, IStoreHousesAppService
  19. {
  20. protected IStatesAppService StatesAppService { get; set; }
  21. public StoreHousesAppService(IRepository<StoreHouse, int> repository, IStatesAppService statesAppService) : base(repository, "StoreHouseName")
  22. {
  23. StatesAppService = statesAppService;
  24. KeyIsAuto = false;
  25. }
  26. protected override string GetPermissionName { get; set; } = PermissionNames.PagesBasicInfoStoreHouses;
  27. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesBasicInfoStoreHouses;
  28. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesBasicInfoStoreHousesCreate;
  29. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesBasicInfoStoreHousesUpdate;
  30. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesBasicInfoStoreHousesDelete;
  31. [AbpAuthorize(PermissionNames.PagesBasicInfoStoreHouses),DisableAuditing]
  32. public override async Task<PagedResultDto<StoreHouseDto>> GetAll(PagedRequestDto input)
  33. {
  34. CheckGetAllPermission();
  35. var query = CreateFilteredQuery(input).Where(i=>i.IsLock=="N");
  36. if (input.SearchList != null && input.SearchList.Count > 0)
  37. {
  38. List<LambdaObject> objList = new List<LambdaObject>();
  39. foreach (var o in input.SearchList)
  40. {
  41. if (o.KeyWords.IsNullOrEmpty())
  42. continue;
  43. object keyWords = o.KeyWords;
  44. objList.Add(new LambdaObject
  45. {
  46. FieldType = (LambdaFieldType)o.FieldType,
  47. FieldName = o.KeyField,
  48. FieldValue = keyWords,
  49. ExpType = (LambdaExpType)o.ExpType
  50. });
  51. }
  52. var exp = objList.GetExp<StoreHouse>();
  53. query = query.Where(exp);
  54. }
  55. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  56. query = ApplySorting(query, input);
  57. query = ApplyPaging(query, input);
  58. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  59. var storeHouseDtos = ObjectMapper.Map<List<StoreHouseDto>>(entities);
  60. foreach (var storeHouseDto in storeHouseDtos)
  61. {
  62. storeHouseDto.StoreHouseTypeName =
  63. StatesAppService.GetDisplayValue("StoreHouse", "StoreHouseType", storeHouseDto.StoreHouseTypeId + "");
  64. }
  65. var dtos = new PagedResultDto<StoreHouseDto>(totalCount,storeHouseDtos);
  66. return dtos;
  67. }
  68. }
  69. }