1 Star 16 Fork 2

轻松的小希 / CommonAdmin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

项目简介

CommonAdmin是一个按钮级权限管理系统,包含企业后台最常用的系统模块,代码简洁,开箱即用。

访问地址:https://gitee.com/caochenlei/common-admin

主要功能

  • 登录功能

  • 后台首页

  • 错误页面

  • 部门管理

  • 用户管理

  • 角色管理

  • 菜单管理

  • 日志管理

  • 系统配置

  • 个人中心

采用技术

前端技术栈:

技术名称 采用版本 官方地址
vue-element-admin 4.4.0 点击访问

后端技术栈:

技术名称 采用版本 官方地址
Spring Boot 2.5.14 点击访问
Spring Security 5.5.8 点击访问
MyBatis 3.5.9 点击访问
JJWT 0.11.5 点击访问
Knife4j 3.0.3 点击访问

开发的工具:

工具名称 采用版本 下载地址
IntelliJ IDEA 2021.1 下载地址
Maven 3.6.3 下载地址
MySQL 5.7.34 下载地址
Redis 3.2.100 下载地址
Visual Studio Code 1.58.2 下载地址
Node.js 14.17.1 下载地址
Java JDK 1.8.0_291 下载地址

目录介绍

common-admin         前端工程
common-admin-server  后端工程

common-admin目录介绍:

├─plop-templates                           模板文件,可以使用npm new来创建,可以用代码生成器代替
├─public
└─src
    │  App.vue                             根组件              
    │  main.js                             入口文件
    │  permission.js                       权限控制
    │  settings.js                         全局设置
    ├─api
    │      cloudStorage.js                 存放访问后端统一存储接口api
    │      sysConfig.js                    存放访问后端系统配置接口api    
    │      sysDepartment.js                存放访问后端系统部门接口api    
    │      sysLog.js                       存放访问后端系统日志接口api
    │      sysMenu.js                      存放访问后端系统菜单接口api
    │      sysRole.js                      存放访问后端系统角色接口api
    │      sysUser.js                      存放访问后端系统用户接口api
    ├─assets                               静态资源
    ├─components                           组件库
    ├─directive                            指令集
    ├─filters                              过滤器
    ├─icons                                SVG图标
    ├─layout                               后台布局
    ├─router                               全局路由
    ├─store                                全局存储
    ├─styles                               样式库
    ├─utils                                工具类
    └─views
        ├─dashboard
        │      index.vue                   默认首页
        ├─error-page
        │      401.vue                     401错误页
        │      404.vue                     404错误页        
        ├─login
        │      index.vue                   登录页面
        ├─profile
        │      avatar.vue                  头像上传组件
        │      index.vue                   个人中心        
        ├─redirect
        │      index.vue                   重定向
        └─system
            ├─config
            │      cloudStorage.vue        云存储配置组件
            │      index.vue               系统配置管理页面            
            ├─department
            │      index.vue               系统部门管理页面            
            ├─log
            │      index.vue               系统日志管理页面
            ├─menu
            │      index.vue               系统菜单管理页面
            ├─role
            │      index.vue               系统角色管理页面
            └─user
                   index.vue               系统用户管理页面

common-admin-server目录介绍:(部分包更换了位置)

│  pom.xml                                                              项目依赖
└─src
    └─main
        ├─java
        │  └─io
        │      └─github
        │          └─caochenlei
        │              │  MainApplication.java                           主启动类
        │              ├─annotation
        │              │     RedisCache.java                             方法缓存注解        
        │              │      SysLogRecord.java                          系统日志注解
        │              ├─aspect
        │              │      RedisCacheAspect.java                      方法缓存切面
        │              │      SysLogAspect.java                          系统日志切面        
        │              ├─common
        │              │      Constant.java                              全局常量
        │              │      Payload.java                               JWT载荷
        │              ├─config
        │              │      AsyncConfig.java                           异步线程池配置
        │              │      ImageCodeConfig.java                       图片验证码配置
        │              │      RedisConfig.java                           Redis访问配置
        │              │      SwaggerConfig.java                         接口文档配置
        │              │      WebMvcConfig.java                          解决跨域配置
        │              │      WebSecurityConfig.java                     登录/权限配置
        │              │      WebServerFactoryCustomizerConfig.java      解决Undertow警告配置
        │              ├─controller
        │              │      CloudStorageController.java
        │              │      SysConfigController.java
        │              │      SysDepartmentController.java        
        │              │      SysLogController.java
        │              │      SysMenuController.java
        │              │      SysRoleController.java
        │              │      SysUserController.java
        │              ├─domain
        │              │      SysConfig.java
        │              │      SysDepartment.java        
        │              │      SysLog.java
        │              │      SysMenu.java
        │              │      SysRole.java
        │              │      SysUser.java
        │              ├─dto
        │              │      SysUserInfoDTO.java                       载荷中传输的用户对象
        │              ├─exception
        │              │      AuthTokenException.java                   Token认证失败异常
        │              │      AuthTokenExpiredException.java            Token时间过期异常
        │              │      CustomAuthenticationException.java        自定义认证失败异常
        │              │      ImageCodeException.java                   图片验证码失败异常
        │              ├─filter
        │              │      CustomAuthenticationFilter.java           请求验证过滤器(重要)
        │              ├─handler
        │              │      CustomAccessDeniedHandler.java            无权限访问处理器
        │              │      CustomAuthenticationEntryPointHandler.java无权限访问处理器
        │              │      CustomAuthenticationFailureHandler.java   登录失败处理器
        │              │      CustomAuthenticationSuccessHandler.java   登录成功处理器
        │              │      GlobalExceptionHandler.java               全局控制器异常处理器
        │              ├─mapper
        │              │      SysConfigMapper.java
        │              │      SysDepartmentMapper.java        
        │              │      SysLogMapper.java
        │              │      SysMenuMapper.java
        │              │      SysRoleMapper.java
        │              │      SysUserMapper.java
        │              ├─prop
        │              │      RsaKeyProperties.java                     获取RSA公/私钥配置对象
        │              ├─service
        │              │  │  SysDepartmentService.java
        │              │  │  SysLogAsyncService.java
        │              │  │  SysLogService.java
        │              │  │  SysMenuService.java
        │              │  │  SysRoleService.java
        │              │  │  SysUserService.java
        │              │  └─impl
        │              │          CloudStorageServiceImpl.java
        │              │          CosCloudStorageServiceImpl.java
        │              │          KodoCloudStorageServiceImpl.java
        │              │          OssCloudStorageServiceImpl.java
        │              │          SysConfigServiceImpl.java
        │              │          SysDepartmentServiceImpl.java
        │              │          SysLogAsyncServiceImpl.java
        │              │          SysLogServiceImpl.java
        │              │          SysMenuServiceImpl.java
        │              │          SysRoleServiceImpl.java
        │              │          SysUserDetailsServiceImpl.java        登录时验证用户/获取权限
        │              │          SysUserServiceImpl.java
        │              │          SysUserTokenServiceImpl.java          Token处理服务类
        │              ├─utils
        │              │      FileUtils.java                            文件处理操作类
        │              │      IpUtils.java                              获取客户端请求IP工具类
        │              │      JsonUtils.java                            JSON解析工具类
        │              │      JwtUtils.java                             Token解析/生成工具类
        │              │      MakeUtils.java                            部门树、菜单树、路由表工具类
        │              │      RedisCacheUtils.java                      Redis缓存工具类
        │              │      RegionUtils.java                          通过IP地址获取区域工具类        
        │              │      RsaUtils.java                             用于生成RSA公/私钥,用来加密
        │              └─vo
        │                      CloudStorageConfigVo.java                回显云存储结果
        │                      PermissionVo.java                        回显前端权限        
        │                      ResultVo.java                            回显前端统一处理结果
        │                      RoleVo.java                              回显角色选中项        
        │                      RouterVo.java                            回显前端路由表
        │                      SysUserInfoVo.java                       回显前端系统用户信息
        │                      TokenVo.java                             回显前端Token
        │                      UploadVo.java                            回显上传文件后结果
        └─resources
            │  application.yml                                          系统配置
            │  banner.txt                                               启动Banner自定义信息
            │  mybatis-config.xml                                       MyBatis配置
            ├─mapper
            │      SysConfigMapper.xml
            │      SysDepartmentMapper.xml            
            │      SysLogMapper.xml
            │      SysMenuMapper.xml
            │      SysRoleMapper.xml
            │      SysUserMapper.xml
            └─rsa
                    rsa_key                                             RSA私钥
                    rsa_key.pub                                         RSA公钥

项目安装

# 导入数据库,注意数据库账号和密码
common-admin.sql
# 克隆项目
git clone https://gitee.com/caochenlei/common-admin.git

common-admin-server安装及启动:

# 进入后端
cd common-admin-server

# 安装依赖(注:如果实在安装不上,那就试试:更换阿里云仓库地址)
mvn install

# 运行项目
mvn spring-boot:run

common-admin安装及启动:

# 进入前端
cd common-admin

# 安装依赖(注:如果实在安装不上,那就试试:cnpm install)
npm install

# 运行项目
npm run dev
访问地址:http://localhost:9527/
登录账号:zhangsan
登录密码:123456

快速开发

为了能够进行快速开发,可以使用我的另一个开源项目《代码生成器》,我已经内置了一套关于《Common-Admin》的开发模板。

软件下载地址:https://gitee.com/caochenlei/code-builder/releases/v1.0.0

但是一定注意:JDK 8,如果JDK不是8可能不会正常运行。

如果你想了解代码生成的整个细节,可以使用CMD命令行的方式启动。

java -jar CodeBuilder-1.0.0.jar

第一步:获取数据库名,然后选择《common-admin》,最后点击开始生成代码

第二步:修改工程包名,然后选择《Common-Admin》,最后点击一键生成代码

第三步:查看生成代码,然后拷贝到对应前后端工程文件夹,最后保存以后重新启动

注意事项

问题一:前端组件的路径有没有一定规范?

回答一:有,需要按照《主功能模块名/次功能模块名》这种形式来存放生成出来的views界面,并且需要修改组件名为index.vue。

问题二:如何实现的按钮级别权限管理?

回答二:

  • 后端使用@PreAuthorize("hasAuthority('sys:department:add')")注解来控制后端方法的访问权限
  • 前端使用v-if="checkPermission(['sys:department:add'])"方法来控制按钮是否显示到页面

问题三:如何生成自己的RSA公/私钥?

回答三:在工程里新建RsaUtilsTest,然后运行以下代码生成即可。

public class RsaUtilsTest {
    private String publicFile = "D:\\auth_key\\rsa_key.pub";
    private String privateFile = "D:\\auth_key\\rsa_key";
    private String secret = "123456789abcdefg";

    @Test
    public void generateKey() throws Exception {
        RsaUtils.generateKey(publicFile, privateFile, secret, 2048);
    }
}

生成后的文件可以直接替换工程默认的RSA公/私钥,也可以在application.yml中配置指定路径。

问题四:系统关于时间类型的处理?

回答四:系统后端所有时间字段需要手动加以下两个注解,代码生成器不会生成,第一个是用于返回前端的格式,第二个是序列化时采用的格式。

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;//创建时间

问题五:系统配置要注意的问题?

回答五:系统配置中order_num>0的配置项默认是通用配置项,而order_num=0为存储配置,如果你有其他特殊配置,可以让order_num为负数,并且可以在系统配置选项卡增加一个选项,并且自己实现。

问题六:为什么我配置了云存储,但是上传头像的时候遇到跨域问题?

回答六:相对应的云存储需要开启跨域配置,默认为"*",可参考:点击访问

问题七:@RedisCache注解如何使用?

回答七:@RedisCache应该运用到查询结果经常不会改变的方法上,方法参数最好是基础数据类型,引用类型也是可以的但是不建议,并且在该方法查询数据对应的修改方法上标注此注解,同时开启flush = true功能,以缓存系统配置为例:

问题八:为什么我分配菜单后刷新当前页面,发现没有生效?

回答八:其实已经生效了,由于组件缓存,所以才没有看到效果,此时只需要CTRL+F5强制刷新一下就能看到啦。

如果您有其他的问题,请联系作者或者关注CSDN进行私信。

版本说明

  • v5.1.0(2022-07-12)

    • 菜单支持侧边栏显示/隐藏
    • 优化SysDialog对话框组件
    • 优化数据库脚本默认编码
    • 清空日志记录表中的数据
  • v5.0.0(2022-07-10)

    • 升级后端部分依赖版本
    • 修复Swagger使用错误
    • 更换部分包的现有位置
    • 更换 @Resource 注入
    • 新增控制方法调用监控
    • 增强前端弹窗组件属性
    • 增强前端弹窗组件加载
    • 增强前端分页大小数量
    • 修复菜单创建属性问题
    • 修复前端登录失效问题
  • v4.0.0

    • 切换tomcat
    • 调整pom
  • v3.0.2

    • 修改接口描述
  • v3.0.1

    • 优化上传流程
    • 优化401页面
    • 优化404页面
    • 系统部门改为选填
    • 验证码区分大小写
  • v3.0.0

    • 新增401错误页面
    • 新增404错误页面
    • 支持用户多角色化,去掉分配角色搜索
    • 新增系统部门时自动打开部门列表
    • 新增系统菜单时自动打开上级列表
    • 前端表格加载提示
    • 超级管理员角色不可删除,不可编辑
    • 数据库内数据进行了调整
    • 修复前端分页的BUG
  • v2.0.0

    • 新增登录背景(默认不开启,需手动开启)
    • 新增系统配置(通用配置项以及特殊配置)
    • 新增个人中心(头像上传、修改密码)
    • 新增通用存储(七牛云(0)、阿里云(1)、腾讯云(2))
    • 新增缓存注解(@RedisCache)
    • 优化登录流程(登录成功弹出提示)
    • 优化退出流程(退出成功弹出提示)
    • 优化缓存前缀(验证码、Token缓存统一添加前缀,防止和其它应用冲突)
    • 修复日志注解(@SysLogRecord在对文件等特殊参数序列化失败的问题)
  • v1.0.0

    • 完成权限控制
    • 完成部门管理
    • 完成用户管理
    • 完成角色管理
    • 完成菜单管理
    • 完成日志管理

联系作者

Email:774908833@qq.com

CSDN:https://caochenlei.blog.csdn.net/

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

CommonAdmin是一个按钮级权限管理系统,包含企业后台最常用的系统模块,代码简洁,开箱即用。 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/caochenlei/common-admin.git
git@gitee.com:caochenlei/common-admin.git
caochenlei
common-admin
CommonAdmin
master

搜索帮助