Abp VNext权限定义
在Shop.Application.Contracts项目中Permissions目录下ShopPermissions定义权限名
namespace Shop.Permissions { public static class ShopPermissions { public const string GroupName = "Shop"; //Add your own permission names. Example: //public const string MyPermission1 = GroupName + ".MyPermission1"; public class Student { public const string Default = GroupName + ".Student"; public const string Update = Default + ".Update"; public const string Create = Default + ".Create"; public const string Delete = Default + ".Delete"; } } }
在ShopPermissionDefinitionProvider中定义权限
using Shop.Localization; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Localization; namespace Shop.Permissions { public class ShopPermissionDefinitionProvider : PermissionDefinitionProvider { public override void Define(IPermissionDefinitionContext context) { var myGroup = context.AddGroup(ShopPermissions.GroupName); //Define your own permissions here. Example: //myGroup.AddPermission(ShopPermissions.MyPermission1, L("Permission:MyPermission1")); var studentPermission = myGroup.AddPermission(ShopPermissions.Student.Default, L("Permission:Student")); studentPermission.AddChild(ShopPermissions.Student.Create, L("Permission:Create")); studentPermission.AddChild(ShopPermissions.Student.Update, L("Permission:Update")); studentPermission.AddChild(ShopPermissions.Student.Delete, L("Permission:Delete")); } private static LocalizableString L(string name) { return LocalizableString.Create<ShopResource>(name); } } }
本文来自博客园,作者:liessay,转载请注明原文链接:https://www.cnblogs.com/liessay/p/13173229.html