using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.Utils.Extensions; using System.ComponentModel.DataAnnotations; namespace Dlhis.Basic.Device.Request; public class DeviceGroupSaveRequest : IValidatableObject { public long? Id { get; set; } /// /// 上级分组 /// public Guid PCode { get; set; } /// /// 设备组名称 /// [Required(ErrorMessage = "设备组名称不能为空")] public string Name { get; set; } /// /// 分类类型 DeviceTypeEnumType /// [EnumDataType(typeof(DeviceTypeEnumType))] public DeviceTypeEnumType Type { get; set; } /// /// 可作为预约分组 /// public bool AsAppointment { get; set; } /// /// 备注 /// public string Remark { get; set; } public IEnumerable Validate(ValidationContext validationContext) { if (AsAppointment && Type != DeviceTypeEnumType.Door) { yield return new ValidationResult($"作为预约分组必要为{DeviceTypeEnumType.Door.GetDescription()}类型", new[] { nameof(Type) }); } } }