平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

128 lines
3.1 KiB

  1. //
  2. namespace SafeCampus.System;
  3. /// <summary>
  4. /// 菜单树查询参数
  5. /// </summary>
  6. public class MenuTreeInput
  7. {
  8. /// <summary>
  9. /// 模块
  10. /// </summary>
  11. public long? Module { get; set; }
  12. /// <summary>
  13. /// 关键字
  14. /// </summary>
  15. public string SearchKey { get; set; }
  16. }
  17. /// <summary>
  18. /// 添加菜单参数
  19. /// </summary>
  20. public class MenuAddInput : SysResource, IValidatableObject
  21. {
  22. /// <summary>
  23. /// 父ID
  24. /// </summary>
  25. [Required(ErrorMessage = "ParentId不能为空")]
  26. public override long? ParentId { get; set; }
  27. /// <summary>
  28. /// 标题
  29. /// </summary>
  30. [Required(ErrorMessage = "Title不能为空")]
  31. public override string Title { get; set; }
  32. /// <summary>
  33. /// 菜单类型
  34. /// </summary>
  35. public override string MenuType { get; set; } = SysResourceConst.MENU;
  36. /// <summary>
  37. /// 模块
  38. /// </summary>
  39. [Required(ErrorMessage = "Module不能为空")]
  40. public override long? Module { get; set; }
  41. /// <summary>
  42. /// 路径
  43. /// </summary>
  44. [Required(ErrorMessage = "Path不能为空")]
  45. public override string Path { get; set; }
  46. /// <summary>
  47. /// 图标
  48. /// </summary>
  49. [Required(ErrorMessage = "Icon不能为空")]
  50. public override string Icon { get; set; }
  51. /// <summary>
  52. /// 特殊验证
  53. /// </summary>
  54. /// <param name="validationContext"></param>
  55. /// <returns></returns>
  56. /// <exception cref="NotImplementedException"></exception>
  57. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  58. {
  59. //如果菜单类型是菜单
  60. if (MenuType is SysResourceConst.MENU or SysResourceConst.SUBSET)
  61. {
  62. if (string.IsNullOrEmpty(Name))
  63. yield return new ValidationResult("Name不能为空", new[] { nameof(Name) });
  64. if (string.IsNullOrEmpty(Component))
  65. yield return new ValidationResult("Component不能为空", new[] { nameof(Name) });
  66. if (MenuType is SysResourceConst.SUBSET)//如果是子集
  67. {
  68. if (string.IsNullOrEmpty(ActiveMenu))
  69. yield return new ValidationResult("ActiveMenu不能为空", new[] { nameof(Name) });
  70. IsHome = false;
  71. IsHide = true;
  72. IsFull = false;
  73. IsAffix = false;
  74. IsKeepAlive = true;
  75. }
  76. }
  77. else
  78. {
  79. Name = null;//设置name为空
  80. Component = null;//设置组件为空
  81. }
  82. //设置分类为菜单
  83. Category = CateGoryConst.RESOURCE_MENU;
  84. }
  85. }
  86. /// <summary>
  87. /// 编辑菜单输入参数
  88. /// </summary>
  89. public class MenuEditInput : MenuAddInput
  90. {
  91. /// <summary>
  92. /// ID
  93. /// </summary>
  94. [IdNotNull(ErrorMessage = "Id不能为空")]
  95. public override long Id { get; set; }
  96. }
  97. /// <summary>
  98. /// 改变模块输入参数
  99. /// </summary>
  100. public class MenuChangeModuleInput : BaseIdInput
  101. {
  102. /// <summary>
  103. /// 模块ID
  104. /// </summary>
  105. [Required(ErrorMessage = "Module不能为空")]
  106. public long? Module { get; set; }
  107. }