//分類管理權限 public const string Pages_Category = "Pages.Category"; public const string Pages_Category_Create = "Pages.Category.Create"; public const string Pages_Category_Edit = "Pages.Category.Edit"; public const string Pages_Category_Delete = "Pages.Category.Delete";
//分類權限的獲取 var category=pages.CreateChildPermission(AppPermissions.Pages_Category, L("CategoryManager")); category.CreateChildPermission(AppPermissions.Pages_Category_Create, L("Category_Create")); category.CreateChildPermission(AppPermissions.Pages_Category_Edit, L("Category_Edit")); category.CreateChildPermission(AppPermissions.Pages_Category_Delete, L("Category_Delete"));
<text name="Category_Create" value="添加分類" /> <text name="Category_Edit" value="編輯分類" /> <text name="Category_Delete" value="刪除分類" />
var _categoryService = abp.services.app.category; //權限 var _permissions = { create: abp.auth.hasPermission('Pages.Category.Create'), edit: abp.auth.hasPermission('Pages.Category.Edit'), 'delete': abp.auth.hasPermission('Pages.Category.Delete') };
var $span = $('<span></span>'); if (_permissions.edit) {//判斷是否有編輯權限 $('<button class="btn btn-default btn-xs" title="' + app.localize('Edit') + '"><i class="fa fa-edit"></i></button>') .appendTo($span) .click(function() { _editModal.open({ id: data.record.id }); }); } if (_permissions.delete) {//判斷是否有刪除權限 $('<button class="btn btn-default btn-xs" title="' + app.localize('Delete') + '"><i class="fa fa-trash-o"></i></button>') .appendTo($span) .click(function() { deleteCategory(data.record); }); } return $span;
@if (IsGranted(AppPermissions.Pages_Category_Create))//判斷是否有添加分類的權限 { <button id="CreateNewCategoryButton" class="btn btn-primary blue"><i class="fa fa-plus"></i>添加分類</button> }
[AbpMvcAuthorize(AppPermissions.Pages_Category)] public class CategoryController : AbpZeroTemplateControllerBase { ... [AbpMvcAuthorize(AppPermissions.Pages_Category_Create)] public ActionResult CreateModal() [AbpMvcAuthorize(AppPermissions.Pages_Category_Edit)] public ActionResult EditModal(int id) ...
[AbpAuthorize(AppPermissions.Pages_Category)] public class CategoryAppService : AbpZeroTemplateAppServiceBase, ICategoryAppService { ... [AbpAuthorize(AppPermissions.Pages_Category_Create)] public void CreateCategory(CreateCategoryInput input) ... [AbpAuthorize(AppPermissions.Pages_Category_Delete)] public void DeleteCategory(EntityRequestInput input) ... [AbpAuthorize(AppPermissions.Pages_Category_Edit)] public void UpdateCategory(CreateCategoryInput input) ...
//子菜單 PageNames.App.Common.Category, L("CategoryManager"), url:"Mpa/Category", icon: "icon-globe", requiredPermissionName: AppPermissions.Pages_Category//菜單權限,登陸用戶所在角色有此權限纔會顯示出來 ))