| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 | using FluentValidation;using Google.Protobuf;using OASystem.Domain.ViewModels;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace OASystem.Domain.Dtos.Statistics{    public class DailypaymentDto    {    }    public class DailypaymentTypeInitDto:PortDtoBase    {             }    public class DailypaymentTypeDataSaveDto : PortDtoBase    {        public List<int> TypeIds { get; set; }    }    public class DailypaymentRangeDto : DtoBase    {        /// <summary>        /// 类型Data        /// 1 数据 2 excel        /// </summary>        public int Type { get; set; }        public string BeginDt { get; set; }        public string EndDt { get; set; }        /// <summary>        /// 公司Id集合        /// 实例:1,2,3,4        /// </summary>        public List<int> CompanyIds { get; set; }        /// <summary>        /// 聚合查询条件        /// </summary>        public string Filter { get; set; }    }    /// <summary>    /// dto验证    /// </summary>    public class DailypaymentRangeDtoValidator : AbstractValidator<DailypaymentRangeDto>    {        public DailypaymentRangeDtoValidator()        {            RuleFor(x => x.PortType).InclusiveBetween(from: 1, to: 3)                                    .WithMessage(MsgTips.Port);            RuleFor(x => x.PageIndex).Must(x => x > 0)                                     .WithMessage("PageIndex不能小于1");            RuleFor(x => x.PageSize).Must(x => x > 0)                                    .WithMessage("PageSize不能小于1");            RuleFor(x => x.BeginDt).NotEmpty()                                   .WithMessage("开始查询日期不能为空!")                                   .Must(IsDate)                                   .WithMessage("日期格式不正确!例如:2024-07-17");            RuleFor(x => x.EndDt).NotEmpty()                                 .WithMessage("结束查询日期不能为空!")                                 .Must(IsDate)                                 .WithMessage("日期格式不正确!例如:2024-12-31")                                 .Must(ConfirmDt)                                 .WithMessage("开始日期不能大于结束日期!");            RuleFor(x => x.Type).InclusiveBetween(from: 1, to: 2)                                .WithMessage("请输入正确的范围;1 数据View 2 excel!");         }        private bool IsDate(string date)        {            return  DateTime.TryParse(date, out _);        }        private bool ConfirmDt(DailypaymentRangeDto dto, string endDt)        {            DateTime _beginDt, _endDt;            if (DateTime.TryParse(dto.BeginDt, out _beginDt))             {                if (DateTime.TryParse(endDt, out _endDt))                {                    if (_beginDt < _endDt)                    {                        return true;                    }                }            }            return false;        }    }}
 |