SysDictItemService.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Attribute;
  2. using Dto;
  3. using Vo;
  4. using Model;
  5. using Model.Base;
  6. using Repository;
  7. using Service;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace Services
  10. {
  11. /// <summary>
  12. /// 字典项Service业务层处理
  13. /// </summary>
  14. [AppService(ServiceType = typeof(ISysDictItemService), ServiceLifetime = LifeTime.Transient)]
  15. public class SysDictItemService : BaseService<SysDictItem>, ISysDictItemService
  16. {
  17. /// <summary>
  18. /// 字典项-列表
  19. /// </summary>
  20. /// <param name="parm">请求参数</param>
  21. /// <returns>字典项列表</returns>
  22. public PagedInfo<SysDictItemListVo> List([FromQuery] SysDictItemListDto parm)
  23. {
  24. //开始拼装查询条件
  25. var predicate = Expressionable.Create<SysDictItem>();
  26. predicate = predicate.AndIF(parm.dictId != null, m => m.dictId == parm.dictId);
  27. predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.label), m => m.label.Contains(parm.label));
  28. predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.description), m => m.description.Contains(parm.description));
  29. var response = Queryable()
  30. .Where(predicate.ToExpression())
  31. .OrderByDescending(m => m.id)
  32. .ToPage<SysDictItem, SysDictItemListVo>(new PagerInfo());
  33. return response;
  34. }
  35. }
  36. }