using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos; using Volo.Abp.MultiTenancy; namespace Sanhe.Abp.MenuManagement { /// /// 创建修改菜单 /// public class CreateOrUpdateMenuDto : EntityDto, IValidatableObject { /// /// 名称 /// public string Name { get; set; } /// /// 显示名称 /// public string DisplayName { get; set; } /// /// 组件路径 /// public string ComponentPath { get; set; } /// /// 路由路径 /// public string RouterPath { get; set; } /// /// 父Id /// public Guid? ParentId { get; set; } /// /// 菜单类型 /// public MenuEnumType MenuType { get; set; } /// /// 图标 /// public string Icon { get; set; } /// /// 排序 /// public string Sort { get; set; } /// /// window.open _blank /// public string TargetUrl { get; set; } /// /// 此菜单关联的权限key /// public string PermissionKey { get; set; } /// /// 表示多租户应用程序中的所属方 /// public MultiTenancySides MultiTenancySide { get; set; } public IEnumerable Validate(ValidationContext validationContext) { if (MenuType == MenuEnumType.Menu) { if (Name.IsNullOrWhiteSpace()) { yield return new ValidationResult("Name 不能为空", new[] { "Name" }); } if (DisplayName.IsNullOrWhiteSpace()) { yield return new ValidationResult("DisplayName 不能为空", new[] { "DisplayName" }); } if (RouterPath.IsNullOrWhiteSpace()) { yield return new ValidationResult("RouterPath 不能为空", new[] { "RouterPath" }); } if (ComponentPath.IsNullOrWhiteSpace()) { yield return new ValidationResult("ComponentPath 不能为空", new[] { "ComponentPath" }); } } else if (MenuType == MenuEnumType.Permission) { if (DisplayName.IsNullOrWhiteSpace()) { yield return new ValidationResult("DisplayName 不能为空", new[] { "DisplayName" }); } if (!ParentId.HasValue) { yield return new ValidationResult("ParentId 不能为空", new[] { "ParentId" }); } } } } }