95 lines
2.6 KiB
C#
95 lines
2.6 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Entity.Device.Enums;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Basic.Device.Request;
|
|
|
|
public class DeviceSaveRequest : IValidatableObject
|
|
{
|
|
public long? Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 设备唯一号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "设备唯一号不能为空")]
|
|
public string UniqueNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 模板code
|
|
/// </summary>
|
|
[Required(ErrorMessage = "模板不能为空")]
|
|
public Guid TemplateCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 供应商信息
|
|
/// </summary>
|
|
[Required(ErrorMessage = "供应商信息不能为空")]
|
|
public string Supplier { get; set; }
|
|
|
|
/// <summary>
|
|
/// 设备功能 DeviceFuncEnumType
|
|
/// </summary>
|
|
[MinLength(1, ErrorMessage = "设备功能不能为空")]
|
|
[Required(ErrorMessage = "设备功能不能为空")]
|
|
public List<DeviceFuncEnumType> Funcs { get; set; }
|
|
|
|
/// <summary>
|
|
/// 设备类型 DeviceTypeEnumType
|
|
/// </summary>
|
|
[Required(ErrorMessage = "设备类型不能为空")]
|
|
[EnumDataType(typeof(DeviceTypeEnumType))]
|
|
public DeviceTypeEnumType Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// 心跳间隔
|
|
/// </summary>
|
|
public int HeartbeatInterval { get; set; }
|
|
|
|
/// <summary>
|
|
/// 部署点
|
|
/// </summary>
|
|
public string DeployPlace { get; set; }
|
|
|
|
/// <summary>
|
|
/// 部署坐标
|
|
/// </summary>
|
|
public string DeployPosition { get; set; }
|
|
|
|
/// <summary>
|
|
/// 部署方向 DeviceDeployDirectionEnumType
|
|
/// </summary>
|
|
public DeviceDeployDirectionEnumType? DeployDirection { get; set; }
|
|
|
|
/// <summary>
|
|
/// 连接信息
|
|
/// </summary>
|
|
[Required(ErrorMessage = "连接信息不能为空")]
|
|
public string ConnectionInfo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否启用
|
|
/// </summary>
|
|
public bool Enable { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否作为考勤设备
|
|
/// </summary>
|
|
public bool AsAttendance { get; set; }
|
|
|
|
|
|
public bool EnableTimePeriod { get; set; }
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (Type != DeviceTypeEnumType.Door && AsAttendance)
|
|
{
|
|
yield return new ValidationResult($"{DeviceTypeEnumType.Door.GetDescription()}才可设置作为考勤设备", new[] { nameof(AsAttendance) });
|
|
}
|
|
|
|
if (HeartbeatInterval < 0)
|
|
{
|
|
yield return new ValidationResult("心跳间隔不可小于0", new[] { nameof(HeartbeatInterval) });
|
|
}
|
|
}
|
|
} |