using FluentValidation;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OASystem.Domain.ViewModels.Financial
{
///
/// 信用卡账单对账 DTO
///
public class CreditCardBillDTO
{
/////
///// 文件名称
/////
//public IFormFile file { get; set; }
///
/// 卡类型
///
public int cardType { get; set; }
public string beginDt { get; set; }
public string endDt { get; set; }
}
public class CreditCardBillDTOFoaValidator : AbstractValidator
{
public CreditCardBillDTOFoaValidator()
{
//RuleFor(it => it.file)
// .NotNull()
// .NotEmpty()
// .WithMessage("请上传文件!")
// .Must(it => IsExcelFile(it.FileName))
// .WithMessage("请上传Excel文件");
RuleFor(it => it.cardType)
.GreaterThan(0)
.WithMessage("请传入有效的卡类型!");
RuleFor(it => it.beginDt)
.NotNull()
.NotEmpty()
.WithMessage("请输入开始日期!")
.Must(IsValidDate)
.WithMessage("请输入正确的日期格式!");
RuleFor(it => it.endDt)
.NotNull()
.NotEmpty()
.WithMessage("请输入结束日期!")
.Must(IsValidDate)
.WithMessage("请输入正确的日期格式!");
}
private bool IsValidDate(string dateString)
{
return DateTime.TryParse(dateString, out _);
}
private bool IsExcelFile(string fileName)
{
if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
{
return false;
}
return true;
}
}
}