FlowApproverCheckRepository.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Common.AppOptions;
  4. using GxPress.Entity.WorkFlow;
  5. using GxPress.Repository.Interface.WorkFlow;
  6. using Microsoft.Extensions.Options;
  7. using Datory;
  8. namespace GxPress.Repository.Implement.WorkFlow
  9. {
  10. public class FlowApproverCheckRepository : IFlowApproverCheckRepository
  11. {
  12. private readonly Repository<FlowApproverCheck> _repository;
  13. public FlowApproverCheckRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor)
  14. {
  15. var database = new Database(DatabaseType.Parse(dbOptionsAccessor.CurrentValue.DatabaseType), dbOptionsAccessor.CurrentValue.ConnectionString);
  16. _repository = new Repository<FlowApproverCheck>(database);
  17. }
  18. public IDatabase Database => _repository.Database;
  19. public string TableName => _repository.TableName;
  20. public List<TableColumn> TableColumns => _repository.TableColumns;
  21. public async Task<int> InsertAsync(FlowApproverCheck item)
  22. {
  23. return await _repository.InsertAsync(item);
  24. }
  25. public async Task<IEnumerable<FlowApproverCheck>> GetListAsync(int flowId)
  26. {
  27. return await _repository.GetAllAsync(Q
  28. .Where(nameof(FlowApproverCheck.FlowId), flowId)
  29. .OrderByDesc(nameof(FlowApproverCheck.Id))
  30. );
  31. }
  32. public async Task<bool> DeleteAllAsync(int flowId)
  33. {
  34. return await _repository.DeleteAsync(Q
  35. .Where(nameof(FlowApproverCheck.FlowId), flowId)
  36. ) > 0;
  37. }
  38. }
  39. }