IndustryRepository.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Hotline.Orders;
  2. using Hotline.Repository.SqlSugar.DataPermissions;
  3. using Hotline.Snapshot;
  4. using Hotline.Snapshot.Interfaces;
  5. using SqlSugar;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using XF.Domain.Dependency;
  12. namespace Hotline.Repository.SqlSugar.Snapshot;
  13. public class IndustryRepository : BaseRepository<Industry>, IIndustryRepository, IScopeDependency
  14. {
  15. public IndustryRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
  16. {
  17. }
  18. public async Task<IList<dynamic>> GetDataBaseAsync()
  19. {
  20. var result = await Queryable()
  21. .Select(m => new { m.Id, m.Name })
  22. .ToListAsync();
  23. return result.Cast<dynamic>().ToList();
  24. }
  25. public async Task<double> GetIntervalTimeAsync(string industryId, double defaultValue, CancellationToken cancellationToken)
  26. {
  27. var time = await Queryable().Where(m => m.Id == industryId).Select(m => m.IntervalTime).FirstAsync(cancellationToken);
  28. if (time <= 0)
  29. return defaultValue;
  30. return time;
  31. }
  32. }