1 Star 0 Fork 67

Jason / auto-code-admin

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

auto-code-admin

欢迎使用auto-code-admin后台代码自动生成引擎.2.1.0再次升级.支持可视化生成单表, 一对一, 一对多 ,多对多代码. 不再需要写yaml文件,支持无限级联 演示地址 账号 ztp 密码 111111 (服务器在美国,有时访问可能比较慢.)

目录

  1. 项目介绍
    1. 项目的优势在哪里
    2. 什么情况选择该项目
    3. 为何会发起该项目
    4. 如果您觉得项目还行.请点赞
    5. 软件架构
    6. 项目模块介绍
  2. 安装教程
    1. 代码生成教程
      1. 介绍
      2. 单表生成
      3. 一对一
      4. 一对多
      5. 多对多
    2. 生成代码注意事项
  3. 进阶篇
    1. 如何进行项目集群
    2. 权限机制的实现
    3. 配置参数介绍
    4. 如何升级
  4. 项目部分截图
    1. PC端
    2. 移动端

更新

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

什么情况选择该项目

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

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

为何会发起该项目?

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

如果您觉得项目还行.请点赞.您的支持是我最大的动力项目地址

start

软件架构

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

代码生成教程

auto-code-generator代码生成介绍

1.代码生成主要在 auto-code-generator 子模块中. 改模块基于 auto-code 做的扩展.扩展了怎么生成 单表 一对一 一对多 多对多 的页面展示关系.

  1. application.properties 文件中填写参数(不填也没事,可以到页面配置.不过建议填写.当项目重新页面参数会重置的)
# 代码生成器
#生成代码的项目根路径
auto-code.parentPath=E:\\resource\\workspaceJDB\\auto-code-admin\\auto-code-web
#生成代码的父包 如父包是com.zengtengpeng.test  controller将在com.zengtengpeng.test.controller下 bean 将在com.zengtengpeng.test.bean下 ,service,dao同理
auto-code.parentPack=com.zengtengpeng.simple
#添加权限到表的父id.如果为空则需要手动添加权限
auto-code.authParentId=89

3.这是代码生成的页面地址 http://localhost:8080/auto-code-ui/ui/index.html

单表生成

1.界面选择单表生成.选择对应的表,点击生成预览. 最后点击确认生成. 完毕.

simple

2.生成的文件如下: select

一对一代码生成 对应 auto-code_one-to-one.yaml (代码采用追加的方式.无需担心代码被覆盖)

  1. 打开界面.选择对应的表,一对一比单表多了一个外键id. 比如界面两张表的关系就是通过 user_id来关联的 如下:
test_one_to_one_user.id=test_one_to_one_class.user_id

one-to-one one-to-one

2.点击生成完毕.生成的文件和单表是一样的.里面会增加新的方法

一对多 代码生成 auto-code_one-to-many.yaml (代码采用追加的方式.无需担心代码被覆盖)

一对多一对一一样不再描述

多对多 代码生成 auto-code_many-to-many.yaml (代码采用追加的方式.无需担心代码被覆盖)

1.打开界面.选择对应的表,多对多一对一多了一个关系描述表 比如图片三张表的关系是通过 test_many_to_many_user_role来表述的.如下:

test_many_to_many_user_role.user_id=test_many_to_many_user.id and test_many_to_many_user_role.role_id=test_many_to_many_role.id

many-to-many many-to-many many-to-many

2.点击生成完毕.生成的文件和单表是一样的.里面会增加新的方法

生成代码注意事项

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

进阶篇

如何进行项目集群

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

1.安装redis 下载地址 redis官方是不支持windows的不过有社区版 下载地址

2.使用spring-session将session放入redis中,修改 auto-code-admin/pom.xml

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.session</groupId>
  <artifactId>spring-session-data-redis</artifactId>
</dependency>

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

#redis
spring.redis.host=127.0.0.1
spring.redis.port=6379

4.到此为止,集群成功

权限机制的实现

本项目采用拦截器管理权限 具体实现 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文件

项目部分截图

pc

登录

主页

权限

用户

用户详情

mobile

登录

菜单

主页

权限

用户

用户详情

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.

简介

后台管理系统代码自动生成器.2.1.0再次升级.支持可视化生成.单表, 一对一, 一对多 ,多对多代码生成,支持无限级联 展开 收起
Java
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助

53164aa7 5694891 3bd8fe86 5694891