2026-04-12 16:54:39 +08:00

53 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.ComponentModel.DataAnnotations;
using YD_Event.Core.Enum;
namespace YD_Event.Application.Role.Dtos;
/// <summary>
/// 添加角色输入
/// </summary>
public class AddSysRoleInput : IValidatableObject
{
/// <summary>
/// 角色名称
/// </summary>
[Required(ErrorMessage = "角色名称为必填项")]
[MaxLength(32, ErrorMessage = "角色名称限制32个字符内")]
public string Name { get; set; }
/// <summary>
/// 备注
/// </summary>
[MaxLength(200, ErrorMessage = "备注限制200个字符内")]
public string Remark { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; } = 100;
/// <summary>
/// 状态
/// </summary>
public AvailabilityStatus Status { get; set; } = AvailabilityStatus.Enable;
/// <summary>
/// 菜单ID集合
/// </summary>
public List<long> MenuIds { get; set; }
/// <summary>
/// 菜单ID集合(前端使用)
/// </summary>
public List<long> Menus { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var menuIds = MenuIds ?? Menus;
if (menuIds == null || menuIds.Count == 0)
{
yield return new ValidationResult("请选择权限", new[] { nameof(MenuIds), nameof(Menus) });
}
}
}