38 lines
991 B
C#
38 lines
991 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using Org.BouncyCastle.Crypto.Digests;
|
|
|
|
namespace Dlhis.Basic.Organization.Request;
|
|
|
|
public class GainfoUploadFaceRequest : IValidatableObject
|
|
{
|
|
/// <summary>
|
|
/// no/idno
|
|
/// </summary>
|
|
[Required(ErrorMessage = "no/idno不能为空")]
|
|
public string UserNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 人脸base64
|
|
/// </summary>
|
|
[Required(ErrorMessage = "人脸照片不能为空")]
|
|
public string Face { get; set; }
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
//后续增加参数判断,如果传入的类型是base64才进行校验
|
|
bool v = true;
|
|
try
|
|
{
|
|
_ = Convert.FromBase64String(Face);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
v = false;
|
|
}
|
|
|
|
if (!v)
|
|
{
|
|
yield return new ValidationResult("人脸照片需要为Base64格式", new[] { nameof(Face) });
|
|
}
|
|
}
|
|
} |