using FluentValidation; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OASystem.Domain.Dtos.Statistics { /// /// 企业利润dtos /// public class CorporateProfitDtos : UserPageFuncDtoBase { } public class CorporateProfitDtosDtoBaseFoalidator : AbstractValidator { public CorporateProfitDtosDtoBaseFoalidator() { RuleFor(it => it.PortType).InclusiveBetween(1, 3).WithMessage(MsgTips.Port); RuleFor(it => it.UserId).GreaterThan(1).WithMessage(MsgTips.UserId); RuleFor(it => it.PageId).GreaterThan(1).WithMessage(MsgTips.PageId); } } /// /// item Dto /// public class CorporateProfitItemDto : CorporateProfitExcelDownloadDto { } /// /// item Dto /// 参数验证 /// public class CorporateProfitItemDtoFoalidator : AbstractValidator { public CorporateProfitItemDtoFoalidator() { Include(new CorporateProfitExcelDownloadDtoFoalidator()); } } public class CorporateProfitExcelDownloadDto : CorporateProfitDtos { /// /// excel类型 /// 1 月报表 2 季度报表 3 年报表 4 导出 5 生成 /// public int ExcelType { get; set; } public string BeginDt { get; set; } public string EndDt { get; set; } } public class CorporateProfitExcelDownloadDtoFoalidator : AbstractValidator { public CorporateProfitExcelDownloadDtoFoalidator() { Include(new CorporateProfitDtosDtoBaseFoalidator()); RuleFor(it => it.ExcelType).InclusiveBetween(1, 5).WithMessage("请输入有效的Excel类型"); RuleFor(it => it.BeginDt) .Must(dateString => DateTime.TryParse(dateString, out _)) .WithMessage("请输入有效开始的日期"); RuleFor(it => it.EndDt) .Must(dateString => DateTime.TryParse(dateString, out _)) .WithMessage("请输入有效结束的日期"); } } }