当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 67

cytimefly / auto-code-admin
关闭

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

auto-code-admin

欢迎使用auto-code-admin后台代码自动生成引擎 演示地址 账号 ztp 密码 111111(服务器在美国,有时访问可能比较慢.)

更新

2019-05-09: 版本 2.1.2

1.移除Swagger(这个东西代码入侵性太强.里面也有一些BUG), 如需使用请在自己的项目增加swagger jar包 然后将 globalConfig.sswagger 设置为true

2019-05-08: 版本 2.1.1

1.生成的bean不再忽略转译之前的get方法了

2.BaseDao,BaseService 增加 selectByConditionFirst方法.返回第一条记录

2019-03-22: 版本:2.1.0 生成代码增加可视化视图,不再需要写yaml文件配置了

2019-03-18 增加 swagger api支持

1.增加权限 auto-code-admin/update_sql/2019-03-18.sql
2. yaml 文件 globalConfig 增加  swagger: true 配置

项目介绍

项目实现的功能介绍

1.用户,角色,权限管理(权限控制到按钮)

2.图片管理

3.操作日志(针对于用户,每次点击的记录都会被记录)

4.报表管理

5.代码生成 (支持可视化生成单表, 一对一, 一对多 ,多对多代码.)

项目的优势在哪里

1.目前市面上的代码生成工具绝大多数仅仅支持生成单表,该项目支持 单表, 一对一, 一对多 ,多对多 以及所对应的页面生成.大大简化了开发的工作量

2.该项目仅仅只是帮你生成单表以及多表的增删改查,不做任何底层的改动.只要你知道怎么使用 spring boot+mybatis技术.就能看懂代码

什么情况选择该项目

1.该项目前后台代码一起生成.如果你是做后台.页面展示比较固定.该项目非常适合你

2.如果你们采用前后台分离.或者开发的页面模板不固定.请使用 auto-code 该项目. 这个项目只生成接口适用性很广.spring boot项目和传统的javaweb项目都适用.不管是一次开发还是二次开发, 只需要简单的集成一个jar包以及少量的配置.就能生成代码

为何会发起该项目?

绝大多数时候我们都是在做增删改查.每次创建一张表.然后我们需要重新写一次增删改查, 写虽然简单,不过极度耗时(controller,server,serverImpl,dao,xml) 所以才有了该项目,该项目能帮助我们减少后台开发的80%的工作量,让你专注于业务的实现.

软件架构

1.基于 springboot 2.0.7+mybatis+mysql
2.基于代码生成引擎做了页面的生成扩展 auto-code [源码地址](https://gitee.com/ztp/auto-code)
3.模板引擎-> thymeleaf 
4.前端主要使用layui
5.前端后台框架layuiAdmin  https://github.com/coderyangjie/layuiAdmin

项目模块介绍

auto-code-admin(根节点)
  -auto-code-generator  代码生成配置
  -auto-code-common ->一些公共的类,以及配置
  -auto-code-sys ->系统设置,权限,日志模块
  -auto-code-charts ->报表模块
  -auto-code-web ->发布模块(该模块聚合以上模块进行发布,如果报表模块不想使用直接在pom.xml将该模块注释掉就好.)

安装教程

1.安装jdk1.8+, mysql5.0+,maven,git 
2.下载源码
3. 导入 auto-code-admin 下的 auto_code.sql 初始化数据库
4. 修改 auto-code-web/application-dev.properties 中的数据库连接以及用户名密码
5. auto-code-admin 打开cmd密令 执行 mvn clean package
6. auto-code-admin/auto-code-web/target 找到jar包 执行 java -jar auto-code-web.jar
7. 访问 http://localhost:8080

代码生成教程

登录之后点击 代码生成页面.然后就可以生成代码了 更多配置请参见

登录

生成代码注意事项

1.多表支持无限级联生成. 比如 用户和收货地址对应,用户表和班级对应...

2.创建表结构时如果写上表与字段的注释将大大增加程序的可读性.我会将注释写到bean上面. 以及页面上.没有写注释还需要页面修改对应的值.会加大工作量.举例:


CREATE TABLE `test_code` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '测试生成代码',
  `name` varchar(50) DEFAULT NULL COMMENT '名称',
  `age` int(3) DEFAULT NULL COMMENT '年龄',
  `status` int(2) DEFAULT NULL COMMENT '{"name":"状态","1":"启用","0":"禁用"}',
  `birthday` date DEFAULT NULL COMMENT '生日',
  `remarks` text COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='测试生成代码'

3.如果注释为json键值对字符串我将会在实体类生成一个字典方法 如: {"name":"状态","1":"启用","0":"禁用"} 将会在实体类里面生成如下,同时页面展示的名称将是 "状态"

public String getStatus_(){
    if(MyStringUtils.isEmpty(status)){
         return "";
    }else if(status.equals("1")){
        return "启用";
    }else if(status.equals("0")){
        return "禁用";
    }
    return "";
}

页面展示 select

进阶篇

如何进行项目集群

集群非常简单只需要简单的几部就能完成

1.安装redis

2.修改 auto-code-admin/pom.xml

<dependency>
    <groupId>com.zengtengpeng</groupId>
    <artifactId>redisson-spring-boot-starter</artifactId>
    <version>1.0.2</version>
</dependency>

3.修改 auto-code-web/application-dev.properties 配置文件 增加redis配置

#单Redis节点模式
redisson.singleServerConfig.address=127.0.0.1:6379
server.port=8070

4.在启动类上面加上 @EnableRedissonHttpSession 注解

@SpringBootApplication
@EnableRedissonHttpSession
public class RedissonApplication {

    public static void main(String[] args) {
        SpringApplication.run(RedissonApplication.class, args);
    }

}

5.为何不使用 spring-boot-starter-data-redis 做集群?

用spring-boot-starter-data-redis做集群也是可以的,不过该项目使用的是jedis客户端做的集群, 往往项目一旦做了集群意味着要开始做分布式锁了.jedis在2.10.6版本以下会造成死锁. 之后才增加了一个一个方法修复这个问题,然后这个锁只是单机的.redlock他是没有实现的. 真正实现了redlock 的只有redssion. 本项目就是在redssion上做的一个starter. 只需要一个简单的注解 @Lock 就是实现 可重入锁,公平锁,联锁,红锁,读写锁.支持各种集群模式.同时也支持MQ,以及存储数据. 详情请参见:redisson-spring-boot-starter源码地址

权限机制的实现

本项目采用拦截器管理权限 具体实现 com.zengtengpeng.interceptor.UserInterceptor

1.具体怎么实现?  权限默认采用@RequestMapping映射值作为权限校验.
2.如果两个url想采用一个权限怎么办? 使用 com.zengtengpeng.common.annotation.Auth 注解, 
值为 另外一个权限url.这样他们就共享同一个授权了,如果不写值默认只要登录就有该权限.
3.如果该方法不需要登录就能访问怎么办? com.zengtengpeng.common.annotation.Pass 
注解标注在方法上.该方法就不需要授权

配置参数介绍

基础请参照参数 auto-code,admin在基础参数的基础上扩展了两个特有的参数

参数名 默认值 介绍
authParentId 添加权限到表的父id.如果为空则不自动生成权限
thymeleafPath templates thymeleaf 放置页面的文件目录

如何升级

1.下载项目后,自己的代码请放到 auto-code-web子模块或者自己重新新建模块
2.更新请将 auto-code-common,auto-code-generator,auto-code-sys 覆盖成最新的代码就行.
3.如果数据库有更新我会在上面更新介绍更新的SQL文件
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

纯净版后台管理引擎,抽取后台核心通用功能,专注于业务实现. 支持代码生成,权限控制到按钮.详细的操作日志.以及集群和分布式锁 展开 收起
Java
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/cytimefly/auto-code-admin.git
git@gitee.com:cytimefly/auto-code-admin.git
cytimefly
auto-code-admin
auto-code-admin
master

搜索帮助