DailypaymentDto.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using FluentValidation;
  2. using Google.Protobuf;
  3. using OASystem.Domain.ViewModels;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OASystem.Domain.Dtos.Statistics
  10. {
  11. public class DailypaymentDto
  12. {
  13. }
  14. public class DailypaymentTypeInitDto:PortDtoBase
  15. {
  16. }
  17. public class DailypaymentTypeDataSaveDto : PortDtoBase
  18. {
  19. public List<int> TypeIds { get; set; }
  20. }
  21. public class DailypaymentRangeDto : DtoBase
  22. {
  23. /// <summary>
  24. /// 类型Data
  25. /// 1 数据 2 excel
  26. /// </summary>
  27. public int Type { get; set; }
  28. public string BeginDt { get; set; }
  29. public string EndDt { get; set; }
  30. /// <summary>
  31. /// 公司Id集合
  32. /// 实例:1,2,3,4
  33. /// </summary>
  34. public List<int> CompanyIds { get; set; }
  35. /// <summary>
  36. /// 聚合查询条件
  37. /// </summary>
  38. public string Filter { get; set; }
  39. }
  40. /// <summary>
  41. /// dto验证
  42. /// </summary>
  43. public class DailypaymentRangeDtoValidator : AbstractValidator<DailypaymentRangeDto>
  44. {
  45. public DailypaymentRangeDtoValidator()
  46. {
  47. RuleFor(x => x.PortType).InclusiveBetween(from: 1, to: 3)
  48. .WithMessage(MsgTips.Port);
  49. RuleFor(x => x.PageIndex).Must(x => x > 0)
  50. .WithMessage("PageIndex不能小于1");
  51. RuleFor(x => x.PageSize).Must(x => x > 0)
  52. .WithMessage("PageSize不能小于1");
  53. RuleFor(x => x.BeginDt).NotEmpty()
  54. .WithMessage("开始查询日期不能为空!")
  55. .Must(IsDate)
  56. .WithMessage("日期格式不正确!例如:2024-07-17");
  57. RuleFor(x => x.EndDt).NotEmpty()
  58. .WithMessage("结束查询日期不能为空!")
  59. .Must(IsDate)
  60. .WithMessage("日期格式不正确!例如:2024-12-31")
  61. .Must(ConfirmDt)
  62. .WithMessage("开始日期不能大于结束日期!");
  63. RuleFor(x => x.Type).InclusiveBetween(from: 1, to: 2)
  64. .WithMessage("请输入正确的范围;1 数据View 2 excel!");
  65. }
  66. private bool IsDate(string date)
  67. {
  68. return DateTime.TryParse(date, out _);
  69. }
  70. private bool ConfirmDt(DailypaymentRangeDto dto, string endDt)
  71. {
  72. DateTime _beginDt, _endDt;
  73. if (DateTime.TryParse(dto.BeginDt, out _beginDt))
  74. {
  75. if (DateTime.TryParse(endDt, out _endDt))
  76. {
  77. if (_beginDt < _endDt)
  78. {
  79. return true;
  80. }
  81. }
  82. }
  83. return false;
  84. }
  85. }
  86. }