1 Star 0 Fork 67

gggyvw / 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

项目介绍

为何会发起该项目? (由于线上的数据被恶意删除,修改.所以目前每隔一个小时我会恢复一次数据)

1.权限,角色,用户对于绝大多数系统来说都是一成不变的.而我们每开发一个后台都需要重新一次.每次都在重复造轮子
2.对于业务绝大多数也是围绕这增删改查来进行操作.每次创建一张表.然后我们需要重新写一次增删改查,写虽然简单,不过极度耗时(view,controller,server,serverImpl,dao,xml) 
所以才有了该项目,该项目能帮助你减少60%的工作量,让你专注于业务的实现.

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

start

软件架构

1.基于 springboot 2.0.7+mybatis+mysql
2.代码生成使用 auto-code [源码地址](https://gitee.com/ztp/auto-code)
3.模板引擎-> thymeleaf (spring boot不推荐使用jsp jsp在打包的时候会遇到各种问题)
4.前端主要使用layui
5.前端后台框架layuiAdmin  https://github.com/coderyangjie/layuiAdmin

项目模块介绍

auto-code-admin(根节点)
  -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

使用说明 源码地址

执行成功后将生成 controller,server,serverImpl,dao,xml,list.html,list_detail.html.如果仅仅是单表的增删改查.你将不需要任何改动.直接就可以提交代码.
执行代码如下:
import com.zengtengpeng.generator.bean.StartCode;
import com.zengtengpeng.generator.utils.AutoCodeUtils;

import java.util.Arrays;
import java.util.List;

public class AutoCodeTest {
	public static void main(String[] args) {
		List dataNames= Arrays.asList("test_code");
		StartCode startCode=new StartCode();
		//jdbc连接
		startCode.setJdbc("jdbc:mysql://localhost:3306/auto_code");
		//数据库用户名
		startCode.setUser("root");
		//数据库密码
		startCode.setPassword("111111");
		//需要生成的表明
		startCode.setDataNames(dataNames);
		//生成代码的绝对路径
		startCode.setParentPath("E:\\resource\\workspaceJDB\\auto-code-admin\\auto-code-web");
		//生成代码的父包
		startCode.setParentPack("com.zengtengpeng.test");
		//开始生成
		AutoCodeUtils.startByWebAdmin(startCode);
	}
}
			  
权限SQL也帮助你生成了.将打印在控制台上:
请注意第一句sql的parent_auth_id的值, 默认我是放在 ->代码生成(id=3) 栏目下的
如果你需要更改请将这个值改成对应的栏目就好
11:40:51.262 [main] INFO com.zengtengpeng.generator.create.impl.WebAdminCreateCode - 权限SQL:请注意表名注释一定要唯一,权限会找不到父ID

INSERT INTO `sys_auth` (`parent_auth_id`,`name`,`sort`,`href`,`icon`,`shows`,`create_time`) VALUES  ('3','测试生成代码','1','testCode/gotoList','layui-icon layui-icon-file-b','0',NOW());

INSERT INTO `sys_auth` (`parent_auth_id`,`name`,`sort`,`href`,`icon`,`shows`,`create_time`) VALUES  ((SELECT id FROM `sys_auth` a WHERE a.name='测试生成代码'),'查询','1','testCode/selectAll','layui-icon layui-icon-search','1',NOW());

INSERT INTO `sys_auth` (`parent_auth_id`,`name`,`sort`,`href`,`icon`,`shows`,`create_time`) VALUES  ((SELECT id FROM `sys_auth` a WHERE a.name='测试生成代码'),'导出','2','testCode/export','layui-icon layui-icon-next','1',NOW());

INSERT INTO `sys_auth` (`parent_auth_id`,`name`,`sort`,`href`,`icon`,`shows`,`create_time`) VALUES  ((SELECT id FROM `sys_auth` a WHERE a.name='测试生成代码'),'编辑','3','testCode/save','layui-icon layui-icon-edit','1',NOW());

INSERT INTO `sys_auth` (`parent_auth_id`,`name`,`sort`,`href`,`icon`,`shows`,`create_time`) VALUES  ((SELECT id FROM `sys_auth` a WHERE a.name='测试生成代码'),'删除','4','testCode/deleteByPrimaryKey','layui-icon layui-icon-fonts-del','1',NOW());

生成代码注意事项

1.创建表结构时一定要写注释!!!,不写注释生成的代码将会没有列名等等一系列问题.写注释这个是约定!
2.获取表名的注释有些版本的mysql获取不了,所以请在主键id上写上表名注释,到时候如果获取不了表名注释我将会从Id上获取
3.目前支持生成 text,date,datetime,textarea,select五种类型的输入框
  3.1 text,date,datetime,textarea 映射机制我是根据数据库的数据类型进行映射的
数据库类型 输入框类型
date date
datetime datetime
text textarea
其他 text
  3.2:select类型比较特殊,由于数据库没有键值类型. 所以我采取的是在字段注释书写json格式的注释 列: {"name":"状态","1":"启用","0":"禁用"} name为该字段的中文注释,然后在输入框将会生成如下的下拉框

select

完整的数据库实列:

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部就能完成
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 注解标注在方法上.该方法就不需要授权

项目部分截图

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.

简介

自动后台管理系统代码自动生成器 展开 收起
Java
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助

14c37bed 8189591 565d56ea 8189591