平安校园
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.

MenuInput.cs 3.1 KiB

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