43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Entity.Device.Enums;
|
|
|
|
namespace Dlhis.Basic.Device.Request;
|
|
|
|
public class DeviceTimePeriodSaveRequest : IValidatableObject
|
|
{
|
|
public long? Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 卡类型 timeperiod
|
|
/// </summary>
|
|
[Range(2, 3, ErrorMessage = "卡类型有误")]
|
|
public int CardType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 分配类型 DeviceTimePeriodAssignEnumType
|
|
/// </summary>
|
|
[EnumDataType(typeof(DeviceTimePeriodAssignEnumType), ErrorMessage = "时段分配类型有误")]
|
|
public DeviceTimePeriodAssignEnumType AssignType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 分配值
|
|
/// </summary>
|
|
[Required]
|
|
public Guid Value { get; set; }
|
|
|
|
/// <summary>
|
|
/// 星期配置
|
|
/// </summary>
|
|
[MinLength(7, ErrorMessage = "配置有误")]
|
|
[MaxLength(7, ErrorMessage = "配置有误")]
|
|
public List<DeviceTimePeriodSectionRequest> Sections { get; set; }
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (Sections.DistinctBy(x => x.DayOfWeek).Count() != Sections.Count)
|
|
{
|
|
yield return new ValidationResult("星期配置重复", new[] { nameof(Sections) });
|
|
}
|
|
}
|
|
} |