51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Entity.Sys.Enums;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Basic.Device.Request;
|
|
|
|
public class DevicePermissionSaveReuqest : IValidatableObject
|
|
{
|
|
/// <summary>
|
|
/// 分配类型 AssignTypeEnumType
|
|
/// </summary>
|
|
[EnumDataType(typeof(AssignTypeEnumType), ErrorMessage = "枚举类型错误")]
|
|
public AssignTypeEnumType AssignType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 分配值
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 如果<see cref="AssignTypeEnumType"/>为用户,那么AssignValue=UserNo
|
|
/// </remarks>
|
|
[Required(ErrorMessage = "分配值不能为空")]
|
|
public string AssignValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// 来源分配权限类型 DevicePermissionTypeEnumType
|
|
/// </summary>
|
|
[EnumDataType(typeof(DeviceAssignmentTypeEnumType), ErrorMessage = "枚举类型错误")]
|
|
public DeviceAssignmentTypeEnumType UniqueType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 分配权限值
|
|
/// </summary>
|
|
public List<Guid> Codes { get; set; }
|
|
|
|
/// <summary>
|
|
/// AssignType == AssignTypeEnumType.Department 需要传入
|
|
/// </summary>
|
|
public string TenantId { get; set; }
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (AssignType == AssignTypeEnumType.Department)
|
|
{
|
|
if (TenantId.IsEmpty())
|
|
{
|
|
yield return new ValidationResult("请明确具体的厂区", new[] { nameof(TenantId) });
|
|
}
|
|
}
|
|
}
|
|
}
|