45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Basic.Organization.Request;
|
|
|
|
public class MigrationRequest : IValidatableObject
|
|
{
|
|
/// <summary>
|
|
/// 工号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "工号不能为空")]
|
|
public string Code { get; set; }
|
|
|
|
/// <summary>
|
|
/// 卡号
|
|
/// </summary>
|
|
public string CardNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// base64
|
|
/// </summary>
|
|
public string Face { get; set; }
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (Face.IsPresent())
|
|
{
|
|
bool v = true;
|
|
try
|
|
{
|
|
Convert.FromBase64String(Face);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
v = false;
|
|
}
|
|
|
|
if (!v)
|
|
{
|
|
yield return new ValidationResult("人脸照片需要为Base64格式", new[] { nameof(Face) });
|
|
}
|
|
}
|
|
}
|
|
}
|