96 lines
2.4 KiB
C#
96 lines
2.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.RegularExpressions;
|
|
using Dlhis.Basic.Organization.Dto;
|
|
using Dlhis.Entity.Basic.Enums;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Basic.Organization.Request;
|
|
|
|
public class GainfoOutsourceRequest : IValidatableObject
|
|
{
|
|
public long? Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 姓名
|
|
/// </summary>
|
|
[Required(ErrorMessage = "姓名不可为空")]
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// 工号
|
|
/// </summary>
|
|
public string Code { get; set; }
|
|
|
|
/// <summary>
|
|
/// 证件号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "证件号不可为空")]
|
|
public string IdNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 性别 GenderEnumType
|
|
/// </summary>
|
|
public GenderEnumType Gender { get; set; }
|
|
|
|
/// <summary>
|
|
/// 出生日期
|
|
/// </summary>
|
|
public DateTime? Birthday { get; set; }
|
|
|
|
/// <summary>
|
|
/// 手机号码
|
|
/// </summary>
|
|
[Required(ErrorMessage = "手机号不可为空")]
|
|
public string Phone { get; set; }
|
|
|
|
/// <summary>
|
|
/// 厂区
|
|
/// </summary>
|
|
[Required(ErrorMessage = "厂区不可为空")]
|
|
public string Factory { get; set; }
|
|
|
|
/// <summary>
|
|
/// 入职日期
|
|
/// </summary>
|
|
public DateTime EntryDate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 离职日期
|
|
/// </summary>
|
|
public DateTime? ResignationDate { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
public string Remark { get; set; }
|
|
|
|
/// <summary>
|
|
/// 额外信息
|
|
/// </summary>
|
|
[Required]
|
|
public GainfoOutSourceExternalInfoDto ExternalInfo { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (Code == ExternalInfo.SapCode)
|
|
{
|
|
yield return new ValidationResult("工号和对接人工号不可相同", new[] { nameof(Code) });
|
|
}
|
|
|
|
const string containChineseRule = "[\u4e00-\u9fa5]";
|
|
if (Code.IsPresent())
|
|
{
|
|
if (Regex.IsMatch(Code, containChineseRule))
|
|
{
|
|
yield return new ValidationResult($"工号[{Code}]不能包含中文", new[] { nameof(Code) });
|
|
}
|
|
|
|
if (!Id.HasValue && Code.StartsWith("LS"))
|
|
{
|
|
yield return new ValidationResult($"工号[{Code}]不能以LS开头", new[] { nameof(Code) });
|
|
}
|
|
}
|
|
}
|
|
} |