RBAC权限实战

2024-06-15 01:12
文章标签 实战 权限 rbac

本文主要是介绍RBAC权限实战,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、项目结构说明、搭建以及初步验证

引入SSM框架依赖:

<dependencies>                                                              
    <dependency>                                                            
        <groupId>javax.servlet</groupId>                        
        <artifactId>servlet-api</artifactId>                          
        <version>2.5</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>javax.servlet.jsp</groupId>                        
        <artifactId>jsp-api</artifactId>                       
        <version>2.1.3-b06</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-core</artifactId>                          
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-context</artifactId>                       
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-jdbc</artifactId>                          
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-orm</artifactId>                           
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-web</artifactId>                           
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-webmvc</artifactId>                        
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>com.mchange</groupId>                                
        <artifactId>c3p0</artifactId>                                 
        <version>0.9.2</version>                                      
    </dependency>                                                           
    <dependency>                                                            
        <groupId>cglib</groupId>                                      
        <artifactId>cglib</artifactId>                                
        <version>2.2</version>                                        
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.aspectj</groupId>                                
        <artifactId>aspectjweaver</artifactId>                        
        <version>1.6.8</version>                                      
    </dependency>                                                           
                                                                                  
    <!-- Spring整合MyBatis -->                                              
    <!-- MyBatis中延迟加载需要使用Cglib -->                                 
    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->         
    <dependency>                                                            
        <groupId>org.mybatis</groupId>                                
        <artifactId>mybatis</artifactId>                              
        <version>3.2.8</version>                                      
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.mybatis</groupId>                                
        <artifactId>mybatis-spring</artifactId>                       
        <version>1.2.2</version>                                      
    </dependency>                                                           
                                                                                  
    <!-- 控制日志输出:结合log4j -->                                        
    <dependency>                                                            
        <groupId>log4j</groupId>                                      
        <artifactId>log4j</artifactId>                                
        <version>1.2.17</version>                                     
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.slf4j</groupId>                                  
        <artifactId>slf4j-api</artifactId>                            
        <version>1.7.7</version>                                      
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.slf4j</groupId>                                  
        <artifactId>slf4j-log4j12</artifactId>                        
        <version>1.7.7</version>                                      
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>mysql</groupId>                                      
        <artifactId>mysql-connector-java</artifactId>                 
        <version>5.1.37</version>                                     
    </dependency>                                                           
    <dependency>                                                            
        <groupId>jstl</groupId>                                       
        <artifactId>jstl</artifactId>                                 
        <version>1.2</version>                                        
    </dependency>                                                           
                                                                                  
    <!-- ********其他****************************** -->                     
                                                                                  
    <!-- Ehcache二级缓存 -->                                                
    <dependency>                                                            
        <groupId>net.sf.ehcache</groupId>                             
        <artifactId>ehcache</artifactId>                              
        <version>1.6.2</version>                                      
    </dependency>                                                           
                                                                                  
                                                                                  
    <!-- 石英调度 - 开始 -->                                                
    <dependency>                                                            
        <groupId>org.quartz-scheduler</groupId>                       
        <artifactId>quartz</artifactId>                               
        <version>1.8.5</version>                                      
    </dependency>                                                           
    <dependency>                                                            
        <groupId>org.springframework</groupId>                        
        <artifactId>spring-context-support</artifactId>               
        <version>4.0.0.RELEASE</version>                              
    </dependency>                                                           
    <dependency>                                                            
        <groupId>commons-collections</groupId>                        
        <artifactId>commons-collections</artifactId>                  
        <version>3.1</version>                                        
    </dependency>                                                           
    <!-- 石英调度 - 结束 -->                                                
                                                                                  
    <dependency>                                                            
        <groupId>org.codehaus.jackson</groupId>                       
        <artifactId>jackson-mapper-asl</artifactId>                   
        <version>1.9.2</version>                                      
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.apache.poi</groupId>                             
        <artifactId>poi</artifactId>                                  
        <version>3.9</version>                                        
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.jfree</groupId>                                  
        <artifactId>jfreechart</artifactId>                           
        <version>1.0.19</version>                                     
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>commons-fileupload</groupId>                         
        <artifactId>commons-fileupload</artifactId>                   
        <version>1.3.1</version>                                      
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.freemarker</groupId>                             
        <artifactId>freemarker</artifactId>                           
        <version>2.3.19</version>                                     
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.activiti</groupId>                               
        <artifactId>activiti-engine</artifactId>                      
        <version>5.15.1</version>                                     
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.activiti</groupId>                               
        <artifactId>activiti-spring</artifactId>                      
        <version>5.15.1</version>                                     
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.apache.commons</groupId>                         
        <artifactId>commons-email</artifactId>                        
        <version>1.3.1</version>                                      
    </dependency>                                                           
                                                                                  
    <dependency>                                                            
        <groupId>org.activiti</groupId>                               
        <artifactId>activiti-explorer</artifactId>                    
        <version>5.15.1</version>                                     
        <exclusions>                                                        
            <exclusion>                                                     
                <artifactId>groovy-all</artifactId>                   
                <groupId>org.codehaus.groovy</groupId>                
            </exclusion>                                                    
        </exclusions>                                                       
    </dependency>                                                           
</dependencies> 

二、登录功能

页面原型:

三、用户名称和退出系统

主页面原型代码:

<!DOCTYPE html>
<html lang="GB18030">
  <head>
    <meta charset="GB18030">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/main.css">
    <style>
    .tree li {
        list-style-type: none;
        cursor:pointer;
    }
    .tree-closed {
        height : 40px;
    }
    .tree-expanded {
        height : auto;
    }
    </style>
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
          <div><a class="navbar-brand" style="font-size:32px;" href="#">众筹平台 - 控制面板</a></div>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li style="padding-top:8px;">
                <div class="btn-group">
                  <button type="button" class="btn btn-default btn-success dropdown-toggle" data-toggle="dropdown">
                    <i class="glyphicon glyphicon-user"></i> 张三 <span class="caret"></span>
                  </button>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#"><i class="glyphicon glyphicon-cog"></i> 个人设置</a></li>
                        <li><a href="#"><i class="glyphicon glyphicon-comment"></i> 消息</a></li>
                        <li class="divider"></li>
                        <li><a href="index.html"><i class="glyphicon glyphicon-off"></i> 退出系统</a></li>
                      </ul>
                </div>
            </li>
            <li style="margin-left:10px;padding-top:8px;">
                <button type="button" class="btn btn-default btn-danger">
                  <span class="glyphicon glyphicon-question-sign"></span> 帮助
                </button>
            </li>
          </ul>
          <form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="查询">
          </form>
        </div>
      </div>
    </nav>
    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <div class="tree">
                <ul style="padding-left:0px;" class="list-group">
                    <li class="list-group-item tree-closed" >
                        <a href="main.html"><i class="glyphicon glyphicon-dashboard"></i> 控制面板</a> 
                    </li>
                    <li class="list-group-item tree-closed">
                        <span><i class="glyphicon glyphicon glyphicon-tasks"></i> 权限管理 <span class="badge" style="float:right">3</span></span> 
                        <ul style="margin-top:10px;display:none;">
                            <li style="height:30px;">
                                <a href="user.html"><i class="glyphicon glyphicon-user"></i> 用户维护</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="role.html"><i class="glyphicon glyphicon-king"></i> 角色维护</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="permission.html"><i class="glyphicon glyphicon-lock"></i> 许可维护</a> 
                            </li>
                        </ul>
                    </li>
                    <li class="list-group-item tree-closed">
                        <span><i class="glyphicon glyphicon-ok"></i> 业务审核 <span class="badge" style="float:right">3</span></span> 
                        <ul style="margin-top:10px;display:none;">
                            <li style="height:30px;">
                                <a href="auth_cert.html"><i class="glyphicon glyphicon-check"></i> 实名认证审核</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="auth_adv.html"><i class="glyphicon glyphicon-check"></i> 广告审核</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="auth_project.html"><i class="glyphicon glyphicon-check"></i> 项目审核</a> 
                            </li>
                        </ul>
                    </li>
                    <li class="list-group-item tree-closed">
                        <span><i class="glyphicon glyphicon-th-large"></i> 业务管理 <span class="badge" style="float:right">7</span></span> 
                        <ul style="margin-top:10px;display:none;">
                            <li style="height:30px;">
                                <a href="cert.html"><i class="glyphicon glyphicon-picture"></i> 资质维护</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="type.html"><i class="glyphicon glyphicon-equalizer"></i> 分类管理</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="process.html"><i class="glyphicon glyphicon-random"></i> 流程管理</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="advertisement.html"><i class="glyphicon glyphicon-hdd"></i> 广告管理</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="message.html"><i class="glyphicon glyphicon-comment"></i> 消息模板</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="project_type.html"><i class="glyphicon glyphicon-list"></i> 项目分类</a> 
                            </li>
                            <li style="height:30px;">
                                <a href="tag.html"><i class="glyphicon glyphicon-tags"></i> 项目标签</a> 
                            </li>
                        </ul>
                    </li>
                    <li class="list-group-item tree-closed" >
                        <a href="param.html"><i class="glyphicon glyphicon-list-alt"></i> 参数管理</a> 
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <h1 class="page-header">控制面板</h1>

          <div class="row placeholders">
            <div class="col-xs-6 col-sm-3 placeholder">
              <img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img data-src="holder.js/200x200/auto/vine" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img data-src="holder.js/200x200/auto/vine" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="jquery/jquery-2.1.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script src="script/docs.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $(".list-group-item").click(function(){
                    // jquery对象的回调方法中的this关键字为DOM对象
                    // $(DOM) ==> JQuery
                    if ( $(this).find("ul") ) { // 3 li
                        $(this).toggleClass("tree-closed");
                        if ( $(this).hasClass("tree-closed") ) {
                            $("ul", this).hide("fast");
                        } else {
                            $("ul", this).show("fast");
                        }
                    }
                });
            });
        </script>
  </body>
</html>

四、权限模型简介

这篇关于RBAC权限实战的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1062015

相关文章

MySQL 多列 IN 查询之语法、性能与实战技巧(最新整理)

《MySQL多列IN查询之语法、性能与实战技巧(最新整理)》本文详解MySQL多列IN查询,对比传统OR写法,强调其简洁高效,适合批量匹配复合键,通过联合索引、分批次优化提升性能,兼容多种数据库... 目录一、基础语法:多列 IN 的两种写法1. 直接值列表2. 子查询二、对比传统 OR 的写法三、性能分析

Python办公自动化实战之打造智能邮件发送工具

《Python办公自动化实战之打造智能邮件发送工具》在数字化办公场景中,邮件自动化是提升工作效率的关键技能,本文将演示如何使用Python的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、

PowerShell中15个提升运维效率关键命令实战指南

《PowerShell中15个提升运维效率关键命令实战指南》作为网络安全专业人员的必备技能,PowerShell在系统管理、日志分析、威胁检测和自动化响应方面展现出强大能力,下面我们就来看看15个提升... 目录一、PowerShell在网络安全中的战略价值二、网络安全关键场景命令实战1. 系统安全基线核查

从原理到实战深入理解Java 断言assert

《从原理到实战深入理解Java断言assert》本文深入解析Java断言机制,涵盖语法、工作原理、启用方式及与异常的区别,推荐用于开发阶段的条件检查与状态验证,并强调生产环境应使用参数验证工具类替代... 目录深入理解 Java 断言(assert):从原理到实战引言:为什么需要断言?一、断言基础1.1 语

Java MQTT实战应用

《JavaMQTT实战应用》本文详解MQTT协议,涵盖其发布/订阅机制、低功耗高效特性、三种服务质量等级(QoS0/1/2),以及客户端、代理、主题的核心概念,最后提供Linux部署教程、Sprin... 目录一、MQTT协议二、MQTT优点三、三种服务质量等级四、客户端、代理、主题1. 客户端(Clien

在Spring Boot中集成RabbitMQ的实战记录

《在SpringBoot中集成RabbitMQ的实战记录》本文介绍SpringBoot集成RabbitMQ的步骤,涵盖配置连接、消息发送与接收,并对比两种定义Exchange与队列的方式:手动声明(... 目录前言准备工作1. 安装 RabbitMQ2. 消息发送者(Producer)配置1. 创建 Spr

深度解析Spring Boot拦截器Interceptor与过滤器Filter的区别与实战指南

《深度解析SpringBoot拦截器Interceptor与过滤器Filter的区别与实战指南》本文深度解析SpringBoot中拦截器与过滤器的区别,涵盖执行顺序、依赖关系、异常处理等核心差异,并... 目录Spring Boot拦截器(Interceptor)与过滤器(Filter)深度解析:区别、实现

深度解析Spring AOP @Aspect 原理、实战与最佳实践教程

《深度解析SpringAOP@Aspect原理、实战与最佳实践教程》文章系统讲解了SpringAOP核心概念、实现方式及原理,涵盖横切关注点分离、代理机制(JDK/CGLIB)、切入点类型、性能... 目录1. @ASPect 核心概念1.1 AOP 编程范式1.2 @Aspect 关键特性2. 完整代码实

MySQL中的索引结构和分类实战案例详解

《MySQL中的索引结构和分类实战案例详解》本文详解MySQL索引结构与分类,涵盖B树、B+树、哈希及全文索引,分析其原理与优劣势,并结合实战案例探讨创建、管理及优化技巧,助力提升查询性能,感兴趣的朋... 目录一、索引概述1.1 索引的定义与作用1.2 索引的基本原理二、索引结构详解2.1 B树索引2.2

从入门到精通MySQL 数据库索引(实战案例)

《从入门到精通MySQL数据库索引(实战案例)》索引是数据库的目录,提升查询速度,主要类型包括BTree、Hash、全文、空间索引,需根据场景选择,建议用于高频查询、关联字段、排序等,避免重复率高或... 目录一、索引是什么?能干嘛?核心作用:二、索引的 4 种主要类型(附通俗例子)1. BTree 索引(