前五章均是从整体上讲述了Web应用程序的多用户权限控制实现流程,本章讲述Web权限管理系统的权限配置模块。页面模块涉及到的数据表为权限表。权限配置模块是按照用户组和页面,栏目结合组成的。通过配置一个用户组可以访问的页面即完成了该类型用户的访问权限管理。

1.1权限域

为了更规范和方便后期系统的二次开发和维护,对应特定的业务模块采用Area(域)的方式开发,权限模块的开发域如下图所示:

Web应用程序系统的多用户权限控制设计及实现-权限模块【10】

由于在Areas下还建立了一个新的目录SystemManage,故需要改变原来的路由。权限模块的路由文件名称为RightManageAreaRegistration。改变路由代码的文件名称为如下:

using System.Web.Mvc;
namespace CodeForMvcTest.Areas.RightManage
{
    public class RightManageAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "SystemManage/RightManage";
            }
        }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "SystemManage_RightManage_default",
                "SystemManage/RightManage/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

 1.2Model

权限模块的Model可参看第三章项目架构的系统共有类,对应model为TreeModel.cs。文件路径为Areas/SystemManage/Models。

 1.3视图

权限模块的视图包含在权限域中,文件路径为Areas/SystemManage/OperatorManage/Views/RightManage,视图名称为RightMange.cshtml。视图的完整代码如下:

 1 @{
 2     ViewBag.Title = "权限管理";
 3     Layout = "~/Views/Shared/_BaseLayout.cshtml";
 4 }
 5 
 6 <div class="easyui-layout" data-options="fit:true">
 7 
 8     <div data-options="region:'north',split:true" style="height: 50px;">
 9         <table style="margin-left: 5px; margin-top: 5px;">
10             <tr>
11                 <td><span style="margin-left: 10px;">用户组:</span></td>
12                 <td>
13                     <select class="easyui-combobox" name="operatorGroupId" id="operatorGroupId" style="width: 150px;"
14                         data-options="editable:false,required:true,onSelect:GetRightList">
15                         @Html.Raw(ViewBag.GroupList)
16                     </select>
17                 </td>
18                 <td>
19                     <button id="btn_submit" style="margin-left: 10px; margin-right: 10px;" onclick="UpdateRight();">保存修改</button>               
20                 </td>
21             </tr>
22         </table>
23 
24     </div>
25 
26     <div data-options="region:'center',split:true" style="padding-bottom: 10px; padding-top: 10px;">
27         <ul class="easyui-tree" id="pageTree"
28             data-options="
29                checkbox:true,
30                url:'/SystemManage/RightManage/RightManage/GetRightTree',
31                method:'get',
32                onLoadSuccess:GetRightList">
33         </ul>
34         <br />
35     </div>
36 
37 </div>
38 
39 @section scripts
40 {
41     <script type="text/javascript" src="/Areas/SystemManage/SystemJS/rightManage.js"></script>
42     <script type="text/javascript">    
43     </script>
44 }
RightManage.cshtml

相关文章:

  • 2022-01-07
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-11-23
  • 2021-10-06
  • 2022-01-12
  • 2022-02-01
  • 2021-08-10
  • 2021-08-03
  • 2021-06-13
相关资源
相似解决方案