All Projects → firebata → Code-Generator

firebata / Code-Generator

Licence: Apache-2.0 license
生成Spring Boot代码

Programming Languages

java
68154 projects - #9 most used programming language
FreeMarker
481 projects

Projects that are alternatives of or similar to Code-Generator

Newbee Mall
🔥 🎉newbee-mall 项目(新蜂商城)是一套电商系统,包括 newbee-mall 商城系统及 newbee-mall-admin 商城后台管理系统,基于 Spring Boot 2.X 及相关技术栈开发。 前台商城系统包含首页门户、商品分类、新品上线、首页轮播、商品推荐、商品搜索、商品展示、购物车、订单结算、订单流程、个人订单管理、会员中心、帮助中心等模块。 后台管理系统包含数据面板、轮播图管理、商品管理、订单管理、会员管理、分类管理、设置等模块。
Stars: ✭ 8,319 (+15898.08%)
Mutual labels:  springboot2
newbee-mall-plus
🔥 🎉newbee-mall-plus 项目是 newbee-mall 项目的升级版本,增加了优惠券模块、商品秒杀模块、支付宝支付,优化了搜索功能,后续会继续增加功能模块以及流行的技术栈。
Stars: ✭ 476 (+815.38%)
Mutual labels:  springboot2
SpringBoot-Examples
Spring boot 2.X version tutorial,Integrate various middleware to facilitate quick reference and use
Stars: ✭ 23 (-55.77%)
Mutual labels:  springboot2
My Blog
🌴A simple & beautiful blogging system implemented with spring-boot & thymeleaf & mybatis My Blog 是由 SpringBoot + Mybatis + Thymeleaf 等技术实现的 Java 博客系统,页面美观、功能齐全、部署简单及完善的代码,一定会给使用者无与伦比的体验
Stars: ✭ 2,400 (+4515.38%)
Mutual labels:  springboot2
springboot-tutorials
codehome出品SpringBoot2.x基础教程
Stars: ✭ 77 (+48.08%)
Mutual labels:  springboot2
spring-boost
Introduce Clojure and live-coding power to your Spring Boot application!
Stars: ✭ 23 (-55.77%)
Mutual labels:  springboot2
cdk-microservices-labs
Hugo Style Documents
Stars: ✭ 12 (-76.92%)
Mutual labels:  springboot2
fw-boot-admin-eureka
springboot admin 监控springCloud服务eureka版
Stars: ✭ 21 (-59.62%)
Mutual labels:  springboot2
spring-road
【Spring江湖路】持续更新中 !!! 一个 Java 程序员必备 Spring 学习资源库。Java 程序员必备,包含 Web应用快速开发、源码实战、Spring Cloud、响应式编程、事件驱动、批处理等 Spring 全家桶技术知识点。
Stars: ✭ 33 (-36.54%)
Mutual labels:  springboot2
JavaFamily
【Java面试+Java学习指南】 一份涵盖大部分Java程序员所需要掌握的核心知识。
Stars: ✭ 517 (+894.23%)
Mutual labels:  springboot2
xiaoyuanxianyu
基于SpringBoot2.0的校园二手交易平台后台
Stars: ✭ 83 (+59.62%)
Mutual labels:  springboot2
spring-boot-performance-analysis
How to tune Spring Boot + HikariCP for the cloud - avoiding the common mistakes
Stars: ✭ 38 (-26.92%)
Mutual labels:  springboot2
cake shop
基于Springboot、Thymeleaf、AmazeUI、BootStrap实现的一个电商网页
Stars: ✭ 34 (-34.62%)
Mutual labels:  springboot2
Spring Boot Leaning
Spring Boot 2.X 最全课程代码
Stars: ✭ 2,008 (+3761.54%)
Mutual labels:  springboot2
common-datax
基于DataX的通用数据同步微服务,一个Restful接口搞定所有通用数据同步
Stars: ✭ 51 (-1.92%)
Mutual labels:  springboot2
Spring Boot Projects
该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。
Stars: ✭ 4,022 (+7634.62%)
Mutual labels:  springboot2
JavaHub
Java程序员学习之路,持续更新原创内容,欢迎Star
Stars: ✭ 27 (-48.08%)
Mutual labels:  springboot2
dbclient
데이터배이스 관리 / 자동 메일링 / Admin 자동화 / Database IDE Tool. SQL Development Helper. Support DBMS Oracle/Mysql/MS-SQL
Stars: ✭ 35 (-32.69%)
Mutual labels:  springboot2
Spring-Boot-2
Spring Boot 2.x examples
Stars: ✭ 33 (-36.54%)
Mutual labels:  springboot2
BankOfSpring
Production ready maven based Spring Boot starter kit application with example cases of handling transactions with Spring.
Stars: ✭ 39 (-25%)
Mutual labels:  springboot2

自动生成服务端代码

你可以

  1. watch项目,因为还要完善
  2. fork项目,有bug和好建议,然后pull request给我
  3. 有问题,email我:[email protected]

你可以获得

  1. 2秒内生成代码,启动,postman直接调用接口
  2. 从此告别创建xml,bean,controller,service
  3. 节省70%的时间,用来做更意义的事情
  4. 开除所有初级程序员

版本说明

  1. clone请选择1.0.x分支
  2. 从之前的单module变成多module
  3. 直接支持微服务
  4. springboot版本为2.0.x
  5. 其他常见的配置都有:redis集群,邮箱,不同的环境变量

工具的使用范围

  1. 该生成springmvc+spring+mybatis的服务端代码
  2. 生成的模块包括controller、bean、service、mapper、mapperXML
  3. 其中controller为restful接口
  4. 该工具使用了freemarker,大家要可以在我的基础上自定义开发

工具的使用方法

  1. 执行zlinks-sample的CodeGenApp main()方法
  2. 修改jdbc.properties为自己的数据库配置
  3. conf.properties可以配置表的数量、模块的类型。默认为全数据库表,全模块的代码
  4. templates下面为模块的模板文件。

最后的补充

  1. IDE建议用IntelliJ IDEA
  2. zlinks-sample的有建表sql脚本:create.sql

生成的目录结构

目录结构

代码举例

controller

 package com.zlinks.controller;
 import com.zlinks.Routes;
 import com.zlinks.domain.RoleInfo;
 import com.zlinks.service.RoleInfoService;
 import com.zlinks.common.web.BaseController;
 import com.zlinks.common.web.JsonResult;
 import com.zlinks.common.web.PageResult;
 import com.zlinks.common.web.RestDoing;
 import com.zlinks.Routes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 
 /**
  * Copyright (C), 2017-2020, cn.zlinks
  * FileName: RoleInfoController
  * Author:   zhangjh
  * Date:     2018-7-10 19:31:43
  * Description: 控制层
  */
 @RestController
 @RequestMapping(value = Routes.API_VERSION)
 public class RoleInfoController extends BaseController {
 
     private Logger logger = LoggerFactory.getLogger(this.getClass());
 
 
 	@Autowired
 	private RoleInfoService roleInfoService;
 
 
 
 
 	/**
      * @api {post} /roleInfos/save 01. RoleInfo删除
      * @apiPermission Login in Users
      * @apiGroup  RoleInfo
      * @apiVersion 1.0.1
 	 * @apiParam {Number} id <code>必须参数</code> id
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 0,
      *     "data": 1
      *     "desc": "Success",
      *     "timestamp": "2018-7-10 19:31:43:082"
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 110002,
      *     "desc": "Param is null or error",
      *     "timestamp": "2018-7-10 19:31:43:479"
      * }
      */
 	@RequestMapping(value = "/roleInfos/delete/{id}", method = RequestMethod.DELETE)
 	public JsonResult deleteJson(HttpServletRequest request, @PathVariable("id") int id) {
 		RestDoing doing = jsonResult -> {
 
             int counts = roleInfoService.deleteById(id);
             jsonResult.data = counts;
         };
         return doing.go(request, logger);
 	}
 
 
 	/**
      * @api {post} /roleInfos/save 02. RoleInfo详细信息
      * @apiPermission Login in Users
      * @apiGroup  RoleInfo
      * @apiVersion 1.0.1
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {String} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 0,
      *     "data": 1
      *     "desc": "Success",
      *     "timestamp": "2018-7-10 19:31:43:082"
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 110002,
      *     "desc": "Param is null or error",
      *     "timestamp": "2018-7-10 19:31:43:479"
      * }
      */
 	@RequestMapping(value = "/roleInfos/info/{id}")
 	public JsonResult info(HttpServletRequest request, @PathVariable("id") Long id) {
 
 		RestDoing doing = jsonResult -> {
 
 			RoleInfo entity  = roleInfoService.queryInfoById(id);
             jsonResult.data = entity;
         };
         return doing.go(request, logger);
 	}
 
 	/**
      * @api {post} /roleInfos/list 03. RoleInfo列表查询
      * @apiPermission Login in Users
      * @apiGroup  RoleInfo
      * @apiVersion 1.0.1
 	 * @apiParam {Number} pageNo <code>必须参数</code> 页码,从1开始
 	 * @apiParam {Number} pageSize <code>必须参数</code> 页码,每页显示的记录数量
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 0,
      *     "data": 1
      *     "desc": "Success",
      *     "timestamp": "2018-7-10 19:31:43:082"
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 110002,
      *     "desc": "Param is null or error",
      *     "timestamp": "2018-7-10 19:31:43:479"
      * }
      */
 	@RequestMapping(value = "/roleInfos/list")
 	public JsonResult page(HttpServletRequest request, RoleInfo roleInfo) {
 
         RestDoing doing = jsonResult -> {
             RoleInfo pageInfo = getPage(roleInfo, RoleInfo.class);
             PageResult<RoleInfo> pageResult = roleInfoService.findPage(roleInfo);
             jsonResult.data = pageResult;
         };
         return doing.go(request, logger);
 	}
 
 
 	/**
      * @api {post} /roleInfos/save 03. RoleInfo新增
      * @apiPermission Login in Users
      * @apiGroup  RoleInfo
      * @apiVersion 1.0.1
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {String} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 0,
      *     "data": 1
      *     "desc": "Success",
      *     "timestamp": "2018-7-10 19:31:43:082"
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 110002,
      *     "desc": "Param is null or error",
      *     "timestamp": "2018-7-10 19:31:43:479"
      * }
      */
 	@RequestMapping(value = "/roleInfos/save", method = RequestMethod.POST)
 	public JsonResult add(HttpServletRequest request, @RequestBody RoleInfo roleInfo) {
 
   		RestDoing doing = jsonResult -> {
 
             int counts = roleInfoService.add(roleInfo);
             jsonResult.data = counts;
         };
         return doing.go(request, logger);
 	}
 
 
 	/**
      * @api {post} /roleInfos/update/{id} 03. RoleInfo修改
      * @apiPermission Login in Users
      * @apiGroup  RoleInfo
      * @apiVersion 1.0.1
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {Long} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
 	 * @apiParam {String} prop.propertyName <code>必须参数</code> RoleInfo的prop.propertyName
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 0,
      *     "data": 1
      *     "desc": "Success",
      *     "timestamp": "2018-7-10 19:31:43:082"
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 200 OK
      * {
      *     "code": 110002,
      *     "desc": "Param is null or error",
      *     "timestamp": "2018-7-10 19:31:43:479"
      * }
      */
 	@RequestMapping(value = "/roleInfos/save", method = RequestMethod.PUT)
 	public JsonResult update(HttpServletRequest request, @RequestBody RoleInfo roleInfo) {
 
   		RestDoing doing = jsonResult -> {
 
             int counts = roleInfoService.update(roleInfo);
             jsonResult.data = counts;
         };
         return doing.go(request, logger);
 	}
 
 }

bean

package com.zlinks.domain;

import com.alibaba.fastjson.JSON;
import com.zlinks.common.dto.pager.PagerInfo;
/**
* Copyright (C), 2017-2020, cn.zlinks
* FileName: RoleInfo
* Author:   zhangjh
* Date:     2018-7-10 19:31:43
* Description: 表名:role_info,描述:
*/
public class RoleInfo extends PagerInfo  {
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	private Long id;
	/**
	 * 
	 */
	private Long roleId;
	/**
	 * 
	 */
	private String roleName;

	/**
	 * 获取
	 */
	public Long getId() {
		return this.id;
	}

	/**
	 * 设置
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * 获取
	 */
	public Long getRoleId() {
		return this.roleId;
	}

	/**
	 * 设置
	 */
	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	/**
	 * 获取
	 */
	public String getRoleName() {
		return this.roleName;
	}

	/**
	 * 设置
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

    @Override
    public String toString() {
    	return JSON.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss");
    }
}

mapperXml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
	PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zlinks.mapper.RoleInfoMapper">

	<sql id="basicSelectSql">
		`id` AS `id`,
		`role_id` AS `roleId`,
		`role_name` AS `roleName`
	</sql>
	
	<sql id="basicWhereColumn">
			<if test="id != null">
				AND `id` = #{id}
			</if>
			<if test="roleId != null">
				AND `role_id` = #{roleId}
			</if>
			<if test="roleName != null">
				AND `role_name` = #{roleName}
			</if>
	</sql>
	
	<sql id="basicWhereEntitySql">
		<where>
		<include refid="basicWhereColumn"/>
		</where>
	</sql>
	
	<sql id="basicWhereMapSql">
		<where>
		<include refid="basicWhereColumn"/>
		</where>
	</sql>

	<select id="queryInfoById" resultType="com.zlinks.domain.RoleInfo">
		SELECT
		<include refid="basicSelectSql"/>
		FROM `role_info`
		<where>
			`id` = #{id}
		</where>
		LIMIT 1;
	</select>

	<select id="selectCount" resultType="Integer">
		SELECT COUNT(*)
		FROM `role_info`
		;
	</select>

    <select id="selectByCondition" resultType="Integer">
        SELECT COUNT(*)
        FROM `role_info`
        <include refid="basicWhereEntitySql"/>
        ;
    </select>

<select id="getList" resultType="com.zlinks.domain.RoleInfo">
    SELECT
    <include refid="basicSelectSql"/>
    FROM `role_info`
    ;
</select>


	<update id="update">
		UPDATE `role_info`
		<set>
			<if test="roleId != null">
				`role_id` = #{roleId},
			</if>
			<if test="roleName != null">
				`role_name` = #{roleName},
			</if>
		</set>
		<where>
			`id` = #{id}
		</where>
	</update>

	<update id="deleteById">
		UPDATE `role_info`
		SET `isDeleted`=1
		<where>
			`id` = #{id}
		</where>
	</update>

	<insert id="add" useGeneratedKeys="true" keyProperty="id">
		INSERT INTO 
		`role_info`
		(`role_id`,`role_name`)
		VALUES 
		(#{roleId},#{roleName})
	</insert>

	<insert id="addList">
		INSERT INTO
		`role_info`
		(`role_id`,`role_name`)
		VALUES
		<foreach collection="list" item="item" index="index" separator="," >
		(#{item.roleId},#{item.roleName})
		</foreach>
	</insert>

	<sql id="orderSql">
		<if test="orderSql != null and orderSql != ''">
		${orderSql}
		</if>
	</sql>

	<sql id="pageSql">
		<if test="pageSql != null and pageSql != ''">
		${pageSql}
		</if>
	</sql>
	
	<sql id="whereContentAll">
		<where>
		<include refid="basicWhereColumn"/>
			<if test="findSql != null" >
			${findSql}
			</if>
		</where>
	</sql>

	<select id="findByPage" resultType="com.zlinks.domain.RoleInfo" >
		SELECT
			<include refid="basicSelectSql" />
		FROM `role_info`
			<include refid="whereContentAll"/>
			<include refid="orderSql" />
			<include refid="pageSql" />
	</select>

	<select id="findByPageCount" >
		SELECT COUNT(`id`)
		FROM `role_info`
		<include refid="whereContentAll"/>
		<include refid="orderSql" />
	</select>

</mapper>

微信

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].