SysDictDataService.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 字典数据服务
  5. /// </summary>
  6. public class SysDictDataService : ISysDictDataService, ITransient
  7. {
  8. private readonly IRepository<SysDictData> _dictDataRep;
  9. public SysDictDataService(IRepository<SysDictData> dictDataRep)
  10. {
  11. _dictDataRep = dictDataRep;
  12. }
  13. /// <summary>
  14. /// 获取所有字典列表
  15. /// </summary>
  16. /// <returns></returns>
  17. public async Task<List<SysDictDataOutput>> GetAllList()
  18. {
  19. var items = await _dictDataRep.DetachedEntities//.Include(t => t.DictType)
  20. .Where(u => u.Status == CommonStatus.ENABLE)
  21. .OrderBy(u => u.Sort)
  22. .ProjectToType<SysDictDataOutput>()
  23. .ToListAsync();
  24. return items;
  25. }
  26. /// <summary>
  27. /// 通过字典类型ID获取字典列表
  28. /// </summary>
  29. /// <param name="dictTypeId"></param>
  30. /// <returns></returns>
  31. public async Task<List<SysDictDataOutput>> GetListByDictTypeId(int dictTypeId)
  32. {
  33. var items = await _dictDataRep.DetachedEntities.Include(t => t.SysDictType)
  34. .Where(u => u.SysDictTypeId == dictTypeId && u.Status == CommonStatus.ENABLE)
  35. .OrderBy(u => u.Sort)
  36. .ProjectToType<SysDictDataOutput>()
  37. .ToListAsync();
  38. return items;
  39. }
  40. }