ABP开发手记13 - 更新菜单

点这里进入ABP开发手记目录

菜单更新

在展示层(即JD.CRS.Web.Mvc)的Startup下打开CRSNavigationProvider.cs //用以存放菜单相关信息

修改如下

  1 using Abp.Application.Navigation;
  2 using Abp.Localization;
  3 using JD.CRS.Authorization;
  4
  5 namespace JD.CRS.Web.Startup
  6 {
  7     /// <summary>
  8     /// This class defines menus for the application.
  9     /// </summary>
 10     public class CRSNavigationProvider : NavigationProvider
 11     {
 12         public override void SetNavigation(INavigationProviderContext context)
 13         {
 14             context.Manager.MainMenu
 15                 .AddItem( //一级菜单 - 首页
 16                     new MenuItemDefinition(
 17                         PageNames.Home,
 18                         L("HomePage"),
 19                         url: "",
 20                         icon: "home",
 21                         requiredPermissionName: PermissionNames.Pages_Home
 22                     )
 23                 )
 24                 .AddItem( //一级菜单 - 基础数据
 25                     new MenuItemDefinition(
 26                         "Data",
 27                         L("Data"),
 28                         icon: "storage"
 29                     ).AddItem( //二级菜单 - 办公室设置
 30                         new MenuItemDefinition(
 31                             PageNames.Office,
 32                             L("Office"),
 33                             url: "Office",
 34                             requiredPermissionName: PermissionNames.Pages_Office
 35                         )
 36                     ).AddItem( //二级菜单 - 院系设置
 37                         new MenuItemDefinition(
 38                             PageNames.Department,
 39                             L("Department"),
 40                             url: "Department",
 41                             requiredPermissionName: PermissionNames.Pages_Department
 42                         )
 43                     ).AddItem( //二级菜单 - 课程设置
 44                         new MenuItemDefinition(
 45                             PageNames.Course,
 46                             L("Course"),
 47                             url: "Course",
 48                             requiredPermissionName: PermissionNames.Pages_Course
 49                         )
 50                     ).AddItem( //二级菜单 - 教职员设置
 51                         new MenuItemDefinition(
 52                             PageNames.Instructor,
 53                             L("Instructor"),
 54                             url: "Instructor",
 55                             requiredPermissionName: PermissionNames.Pages_Instructor
 56                         )
 57                     ).AddItem( //二级菜单 - 学生设置
 58                         new MenuItemDefinition(
 59                             PageNames.Student,
 60                             L("Student"),
 61                             url: "Student",
 62                             requiredPermissionName: PermissionNames.Pages_Student
 63                         )
 64                     )
 65                 )
 66                 .AddItem( //一级菜单 - 综合服务
 67                     new MenuItemDefinition(
 68                         "Operation",
 69                         L("Operation"),
 70                         icon: "business"
 71                     ).AddItem( //二级菜单 - 教职员办公室设置
 72                         new MenuItemDefinition(
 73                             PageNames.OfficeInstructor,
 74                             L("OfficeInstructor"),
 75                             url: "OfficeInstructor"
 76                         )
 77                     ).AddItem( //二级菜单 - 院系主任设置
 78                         new MenuItemDefinition(
 79                             PageNames.DepartmentInstructor,
 80                             L("DepartmentInstructor"),
 81                             url: "DepartmentInstructor"
 82                         )
 83                     ).AddItem( //二级菜单 - 院系课程设置
 84                         new MenuItemDefinition(
 85                             PageNames.DepartmentCourse,
 86                             L("DepartmentCourse"),
 87                             url: "DepartmentCourse"
 88                         )
 89                     ).AddItem( //二级菜单 - 教职员课程设置
 90                         new MenuItemDefinition(
 91                             PageNames.InstructorCourse,
 92                             L("InstructorCourse"),
 93                             url: "InstructorCourse"
 94                         )
 95                     ).AddItem( //二级菜单 - 学生课程设置
 96                         new MenuItemDefinition(
 97                             PageNames.StudentCourse,
 98                             L("StudentCourse"),
 99                             url: "StudentCourse"
100                         )
101                     )
102                 )
103                 .AddItem( //一级菜单 - 管理报表
104                     new MenuItemDefinition(
105                         "Report",
106                         L("Report"),
107                         icon: "poll"
108                     ).AddItem( //二级菜单 - 办公室报表
109                         new MenuItemDefinition(
110                             PageNames.OfficeReport,
111                             L("OfficeReport"),
112                             url: "OfficeReport",
113                             requiredPermissionName: PermissionNames.Pages_OfficeReport
114                         )
115                     ).AddItem( //二级菜单 - 院系报表
116                         new MenuItemDefinition(
117                             PageNames.DepartmentReport,
118                             L("DepartmentReport"),
119                             url: "DepartmentReport",
120                             requiredPermissionName: PermissionNames.Pages_DepartmentReport
121                         )
122                     ).AddItem( //二级菜单 - 课程报表
123                         new MenuItemDefinition(
124                             PageNames.CourseReport,
125                             L("CourseReport"),
126                             url: "CourseReport",
127                             requiredPermissionName: PermissionNames.Pages_CourseReport
128                         )
129                     ).AddItem( //二级菜单 - 教职员报表
130                         new MenuItemDefinition(
131                             PageNames.InstructorReport,
132                             L("InstructorReport"),
133                             url: "InstructorReport",
134                             requiredPermissionName: PermissionNames.Pages_InstructorReport
135                         )
136                     ).AddItem( //二级菜单 - 学生报表
137                         new MenuItemDefinition(
138                             PageNames.StudentReport,
139                             L("StudentReport"),
140                             url: "StudentReport",
141                             requiredPermissionName: PermissionNames.Pages_StudentReport
142                         )
143                     )
144                 )
145                 .AddItem( //一级菜单 - 系统设置
146                     new MenuItemDefinition(
147                         "Setting",
148                         L("Setting"),
149                         icon: "settings"
150                     ).AddItem( //二级菜单 - 租户管理
151                         new MenuItemDefinition(
152                             PageNames.Tenants,
153                             L("Tenants"),
154                             url: "Tenants",
155                             requiredPermissionName: PermissionNames.Pages_Tenants
156                         )
157                     ).AddItem( //二级菜单 - 用户管理
158                         new MenuItemDefinition(
159                             PageNames.Users,
160                             L("Users"),
161                             url: "Users",
162                             requiredPermissionName: PermissionNames.Pages_Users
163                         )
164                     ).AddItem( //二级菜单 - 角色管理
165                         new MenuItemDefinition(
166                             PageNames.Roles,
167                             L("Roles"),
168                             url: "Roles",
169                             requiredPermissionName: PermissionNames.Pages_Roles
170                         )
171                     )
172                 )
173                 .AddItem( //一级菜单 - 关于
174                     new MenuItemDefinition(
175                         PageNames.About,
176                         L("About"),
177                         url: "About",
178                         icon: "info",
179                         requiresAuthentication: true
180                     )
181                 );
182         }
183
184         private static ILocalizableString L(string name)
185         {
186             return new LocalizableString(name, CRSConsts.LocalizationSourceName);
187         }
188     }
189 }

CRSNavigationProvider

权限更新

在领域层(即JD.CRS.Core)的Authorization下打开CRSAuthorizationProvider.cs //用以存放权限相关信息

修改如下

 1 using Abp.Authorization;
 2 using Abp.Localization;
 3 using Abp.MultiTenancy;
 4
 5 namespace JD.CRS.Authorization
 6 {
 7     public class CRSAuthorizationProvider : AuthorizationProvider
 8     {
 9         private static ILocalizableString L(string name)
10         {
11             return new LocalizableString(name, CRSConsts.LocalizationSourceName);
12         }
13         public override void SetPermissions(IPermissionDefinitionContext context)
14         {
15             context.CreatePermission(PermissionNames.Pages_Home, L("Home"));
16             context.CreatePermission(PermissionNames.Pages_Office, L("Office"));
17             context.CreatePermission(PermissionNames.Pages_Department, L("Department"));
18             context.CreatePermission(PermissionNames.Pages_Course, L("Course"));
19             context.CreatePermission(PermissionNames.Pages_Instructor, L("Instructor"));
20             context.CreatePermission(PermissionNames.Pages_Student, L("Student"));
21             context.CreatePermission(PermissionNames.Pages_OfficeInstructor, L("OfficeInstructor"));
22             context.CreatePermission(PermissionNames.Pages_DepartmentInstructor, L("DepartmentInstructor"));
23             context.CreatePermission(PermissionNames.Pages_DepartmentCourse, L("DepartmentCourse"));
24             context.CreatePermission(PermissionNames.Pages_InstructorCourse, L("InstructorCourse"));
25             context.CreatePermission(PermissionNames.Pages_StudentCourse, L("StudentCourse"));
26             context.CreatePermission(PermissionNames.Pages_OfficeReport, L("OfficeReport"));
27             context.CreatePermission(PermissionNames.Pages_DepartmentReport, L("DepartmentReport"));
28             context.CreatePermission(PermissionNames.Pages_CourseReport, L("CourseReport"));
29             context.CreatePermission(PermissionNames.Pages_InstructorReport, L("InstructorReport"));
30             context.CreatePermission(PermissionNames.Pages_StudentReport, L("StudentReport"));
31             context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
32             context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
33             context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
34         }
35     }
36 }

CRSAuthorizationProvider

关联更新

与菜单/权限关联的两个静态类也需要更新

JD.CRS.Web.Mvc\Startup\PageNames.cs //用以存放菜单相关静态信息

 1 namespace JD.CRS.Web.Startup
 2 {
 3     public class PageNames
 4     {
 5         public const string Home = "Home";
 6         public const string Office = "Office";
 7         public const string Department = "Department";
 8         public const string Course = "Course";
 9         public const string Instructor = "Instructor";
10         public const string Student = "Student";
11         public const string OfficeInstructor = "OfficeInstructor";
12         public const string DepartmentInstructor = "DepartmentInstructor";
13         public const string DepartmentCourse = "DepartmentCourse";
14         public const string InstructorCourse = "InstructorCourse";
15         public const string StudentCourse = "StudentCourse";
16         public const string OfficeReport = "OfficeReport";
17         public const string DepartmentReport = "DepartmentReport";
18         public const string CourseReport = "CourseReport";
19         public const string InstructorReport = "InstructorReport";
20         public const string StudentReport = "StudentReport";
21         public const string Tenants = "Tenants";
22         public const string Users = "Users";
23         public const string Roles = "Roles";
24         public const string About = "About";
25     }
26 }

PageNames

JD.CRS.Core\Authorization\PermissionNames.cs //用以存放权限相关静态信息

 1 namespace JD.CRS.Authorization
 2 {
 3     public static class PermissionNames
 4     {
 5         public const string Pages_Home = "Pages.Home";
 6         public const string Pages_Data = "Menu.Data";
 7         public const string Pages_Operation = "Menu.Operation";
 8         public const string Pages_Report = "Menu.Report";
 9         public const string Pages_Setting = "Menu.Setting";
10         public const string Pages_About = "Pages.About";
11         public const string Pages_Office = "Pages.Office";
12         public const string Pages_Department = "Pages.Department";
13         public const string Pages_Course = "Pages.Course";
14         public const string Pages_Instructor = "Pages.Instructor";
15         public const string Pages_Student = "Pages.Student";
16         public const string Pages_OfficeInstructor = "Pages.OfficeInstructor";
17         public const string Pages_DepartmentInstructor = "Pages.DepartmentInstructor";
18         public const string Pages_DepartmentCourse = "Pages.DepartmentCourse";
19         public const string Pages_InstructorCourse = "Pages.InstructorCourse";
20         public const string Pages_StudentCourse = "Pages.StudentCourse";
21         public const string Pages_OfficeReport = "Pages.OfficeReport";
22         public const string Pages_DepartmentReport = "Pages.DepartmentReport";
23         public const string Pages_CourseReport = "Pages.CourseReport";
24         public const string Pages_InstructorReport = "Pages.InstructorReport";
25         public const string Pages_StudentReport = "Pages.StudentReport";
26         public const string Pages_Tenants = "Pages.Tenants";
27         public const string Pages_Users = "Pages.Users";
28         public const string Pages_Roles = "Pages.Roles";
29     }
30 }

PermissionNames

原文地址:https://www.cnblogs.com/IT-Evan/p/ABP13.html

时间: 2024-11-09 05:12:20

ABP开发手记13 - 更新菜单的相关文章

ABP开发手记14 - 更新多语言

点这里进入ABP开发手记目录 新增语言 在基础设施层(即JD.CRS.EntityFrameworkCore)的\EntityFrameworkCore\Seed\Host\下打开DefaultLanguagesCreator.cs //用以存放多语言相关信息 新增语言 new ApplicationLanguage(tenantId, "zh-Hant", "繁體中文", "famfamfam-flags hk"), //增加繁体中文 1 pr

ABP开发手记7 - 基础设施层更新数据库

点这里进入ABP开发手记目录 设置数据库 在基础设施层(即JD.CRS.EntityFrameworkCore)打开数据库环境设置 JD.CRS.EntityFrameworkCore/EntityFrameworkCore/CRSDbContext.cs添加一行 public DbSet<Course> Course { get; set; } //创建数据表Course 1 using Microsoft.EntityFrameworkCore; 2 using Abp.Zero.Enti

ABP开发手记8 - 应用层创建应用服务

点这里进入ABP开发手记目录 创建目录 在应用层(即JD.CRS.Application)下新建文件夹Course //用以存放Course相关应用服务 在JD.CRS.Application/Course下新建文件夹Dto //用以存放Course相关数据传输对象 创建数据传输对象 在JD.CRS.Application/Course/Dto下新建两个Dto 只读对象 CourseDto.cs //用于查询Course对象 贴上AutoMapFrom的特性 [AutoMapFrom(typeo

ABP开发手记6 - 领域层创建实体

点这里进入ABP开发手记目录 创建实体 在领域层(即JD.CRS.Core)下新建文件夹Entitys //用以存放实体对象添加一个实体类Course.cs //课程信息 1 using Abp.Domain.Entities; 2 using Abp.Domain.Entities.Auditing; 3 using Abp.Timing; 4 using System; 5 using System.Collections.Generic; 6 using System.ComponentM

ABP开发手记10 - 展示层实现增删改查-控制器

点这里进入ABP开发手记目录 创建视图模型 在展示层(即JD.CRS.Web.Mvc)的Controllers下新建一个控制器CourseController.cs 1 using Abp.Application.Services.Dto; 2 using Abp.AspNetCore.Mvc.Authorization; 3 using JD.CRS.Authorization; 4 using JD.CRS.Controllers; 5 using JD.CRS.Course; 6 usin

ABP开发手记15 - 小结

点这里进入ABP开发手记目录 效果预览 至此,基于ABP的CURD(增删改查)示例已完成,效果如下 登录 首页 查询课程 新增课程 修改课程 删除课程 阶段总结 关键步骤: 领域层创建实体基础设施层更新数据库应用层创建应用服务展示层实现增删改查 循环往复此步骤即可创建多个CURD页面. 原文地址:https://www.cnblogs.com/IT-Evan/p/ABP15.html

ABP开发手记1 - 开篇

点这里进入ABP开发手记目录 基于DDD的现代ASP.NET开发框架 - ABP ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)”的简称. ASP.NET Boilerplate是一个用最佳实践和流行技术开发现代WEB应用程序的新起点,它旨在成为一个通用的WEB应用程序框架和项目模板. ABP的官方网站:http://www.aspnetboilerplate.com ABP在Github上的开源项目:https://github.com/aspne

ABP开发手记2 - 体系架构

点这里进入ABP开发手记目录 ABP分层体系架构 介绍 应用程序代码库的分层是一种广泛接受的技术,可帮助降低复杂性并提高代码可重用性.为了实现分层体系结构,ASP.NET Boilerplate遵循域驱动设计的原理. 域驱动设计层 域驱动设计(DDD)有四个基本层: 展示层:为用户提供界面.使用应用程序层来实现用户交互. 应用层:在表示层和域层之间进行中介.编排业务对象以执行特定的应用程序任务. 领域层:包括业务对象及其规则.这是应用程序的核心. 基础设施层:提供通用技术功能,这些功能主要使用第

ABP开发手记3 - 解决方案

点这里进入ABP开发手记目录 创建项目 点这里进入ABP启动模板 如图操作,我们先生成一个基于.NET Core的MPA(多页面应用).点击"Create my project!"即可创建项目. 解读项目 展示层 (JD.CRS.Web.Mvc) 提供一个用户界面,实现用户交互操作. ASP.NET Core MVC(模型-视图-控制器)可以视为展示层.它可以是物理层(通过HTTP API使用应用程序)或逻辑层(直接注入和使用应用程序服务).无论哪种情况,它都可以包括 本地化,导航,对