| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | using FluentValidation;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace OASystem.Domain.Dtos.Tencent{    /// <summary>    /// TencentOCR ID证件识别     /// </summary>    public class IDCardOCRDto:DtoBase    {        public int UserId { get; set; }        /// <summary>        /// 语言        /// 1 ch 中文        /// 2 en 英文        /// </summary>        public int Language { get; set; }        /// <summary>        /// 图片的 Base64 值。要求图片经Base64编码后不超过 7M,分辨率建议500*800以上,支持PNG、JPG、JPEG、BMP格式。建议卡片部分占据图片2/3以上。        /// </summary>        public string picBase64 { get; set; }        /// <summary>        /// 0 FRONT:身份证有照片的一面(人像面)        /// 1 BACK:身份证有国徽的一面(国徽面)        ///   该参数如果不填,将为您自动判断身份证正反面。        /// </summary>        public int CardSide { get; set; }    }    /// <summary>    /// TencentOCR ID证件识别 DTO 验证    /// </summary>    public class IDCardOCRDtoFoalidator : AbstractValidator<IDCardOCRDto>    {        public IDCardOCRDtoFoalidator()        {            RuleFor(it => it.UserId)                .GreaterThan(0)                .WithMessage($"请传入有效的用户UserId值") ;            RuleFor(it => it.Language)                .NotNull()                .NotEmpty()                .InclusiveBetween(1, 2)                .WithMessage("Language(超出范围):1 ch 中文 2 en 英文");            RuleFor(it => it.picBase64).NotNull().NotEmpty().WithMessage("picBase64为空");            RuleFor(it => it.picBase64).Must(base64 => OCRVerifyMethod.ImageSize(base64)).WithMessage("图片不能大于7M!");            RuleFor(it => it.picBase64).Must(base64 => OCRVerifyMethod.ImageType(base64)).WithMessage("图片格式不正确!只支持 PNG、JPG、JPEG、BMP格式的文件!");//            RuleFor(it => it.CardSide).InclusiveBetween(0, 1).WithMessage("CardSide(超出范围):0 人像面 1 国徽面");        }    }}
 |