using Dlhis.Entity.Sys.Enums;
using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Device.Request;
public class DeviceGetAssignmentsRequest : IValidatableObject
{
///
/// 权限分配类型 DeviceAssignmentTypeEnumType
///
[EnumDataType(typeof(DeviceAssignmentTypeEnumType))]
public DeviceAssignmentTypeEnumType UniqueType { get; set; }
///
/// 分配类型 AssignTypeEnumType
///
[EnumDataType(typeof(AssignTypeEnumType))]
public AssignTypeEnumType AssignType { get; set; }
///
/// 分配值
///
public string AssignValue { get; set; }
///
/// 设备类型
///
[EnumDataType(typeof(DeviceTypeEnumType))]
public DeviceTypeEnumType Type { get; set; }
///
/// AssignType == AssignTypeEnumType.Department 需要传入
///
public string TenantId { get; set; }
public IEnumerable Validate(ValidationContext validationContext)
{
if (AssignType == AssignTypeEnumType.Department)
{
if (TenantId.IsEmpty())
{
yield return new ValidationResult("请明确具体的厂区", new[] { nameof(TenantId) });
}
}
}
}
public class DeviceGetAssignmentUniquesRequest
{
///
/// 权限分配类型 DeviceAssignmentTypeEnumType
///
[EnumDataType(typeof(DeviceAssignmentTypeEnumType))]
public DeviceAssignmentTypeEnumType UniqueType { get; set; }
///
/// 权限值
///
public Guid UniqueValue { get; set; }
///
/// 设备类型
///
[EnumDataType(typeof(DeviceTypeEnumType))]
public DeviceTypeEnumType Type { get; set; }
}