//
namespace SafeCampus.System;
///
/// 菜单树查询参数
///
public class MenuTreeInput
{
///
/// 模块
///
public long? Module { get; set; }
///
/// 关键字
///
public string SearchKey { get; set; }
}
///
/// 添加菜单参数
///
public class MenuAddInput : SysResource, IValidatableObject
{
///
/// 父ID
///
[Required(ErrorMessage = "ParentId不能为空")]
public override long? ParentId { get; set; }
///
/// 标题
///
[Required(ErrorMessage = "Title不能为空")]
public override string Title { get; set; }
///
/// 菜单类型
///
public override string MenuType { get; set; } = SysResourceConst.MENU;
///
/// 模块
///
[Required(ErrorMessage = "Module不能为空")]
public override long? Module { get; set; }
///
/// 路径
///
[Required(ErrorMessage = "Path不能为空")]
public override string Path { get; set; }
///
/// 图标
///
[Required(ErrorMessage = "Icon不能为空")]
public override string Icon { get; set; }
///
/// 特殊验证
///
///
///
///
public IEnumerable Validate(ValidationContext validationContext)
{
//如果菜单类型是菜单
if (MenuType is SysResourceConst.MENU or SysResourceConst.SUBSET)
{
if (string.IsNullOrEmpty(Name))
yield return new ValidationResult("Name不能为空", new[] { nameof(Name) });
if (string.IsNullOrEmpty(Component))
yield return new ValidationResult("Component不能为空", new[] { nameof(Name) });
if (MenuType is SysResourceConst.SUBSET)//如果是子集
{
if (string.IsNullOrEmpty(ActiveMenu))
yield return new ValidationResult("ActiveMenu不能为空", new[] { nameof(Name) });
IsHome = false;
IsHide = true;
IsFull = false;
IsAffix = false;
IsKeepAlive = true;
}
}
else
{
Name = null;//设置name为空
Component = null;//设置组件为空
}
//设置分类为菜单
Category = CateGoryConst.RESOURCE_MENU;
}
}
///
/// 编辑菜单输入参数
///
public class MenuEditInput : MenuAddInput
{
///
/// ID
///
[IdNotNull(ErrorMessage = "Id不能为空")]
public override long Id { get; set; }
}
///
/// 改变模块输入参数
///
public class MenuChangeModuleInput : BaseIdInput
{
///
/// 模块ID
///
[Required(ErrorMessage = "Module不能为空")]
public long? Module { get; set; }
}