Commit e05535d8 by bianpeng

修改

parent a42064e6
......@@ -30,7 +30,7 @@
<developerConnection>scm:git:git@github.com:flying-cattle/mybatis-dsc-generator.git</developerConnection>
<url>git@github.com:flying-cattle/mybatis-dsc-generator.git</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
......@@ -41,11 +41,11 @@
<lombok.version>1.16.20</lombok.version>
<freemarker.version>2.3.9</freemarker.version>
<!-- 打包跳过单元测试 -->
<skipTests>true</skipTests>
<skipTests>true</skipTests>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>
<dependencies>
......@@ -77,93 +77,107 @@
<optional>true</optional>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>release</id>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>META-INF/resources/</targetPath>
</resource>
</resources>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<snapshotRepository>
<id>oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>disable-javadoc-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
<profile>
<id>release</id>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>META-INF/resources/</targetPath>
</resource>
</resources>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>META-INF/resources/</targetPath>
</resource>
</resources>
<plugins>
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>META-INF/resources/</targetPath>
</resource>
</resources>
<plugins>
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
/**
* @filename:BasisInfo 2018年06月06日
* @project mybatis-generator flying-cattle V1.0
* Copyright(c) 2018 BianP Co. Ltd.
* All right reserved.
*/
package com.github.mybatis.entity;
import java.io.Serializable;
......@@ -13,105 +7,52 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @Description: BasisInfo 基础信息
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BasisInfo implements Serializable{
private static final long serialVersionUID = 123123L;
/**
* @Description: 项目名字
*/
private String project;
/**
* @Description: 作者名字
*/
private String author;
/**
* @Description: 版本号
*/
private String version;
/**
* @Description: 数据库连接
*/
private String dbUrl;
/**
* @Description: 数据访问账户
*/
private String dbName;
/**
* @Description: 数据访问密码
*/
private String dbPassword;
/**
* @Description: 数据库名
*/
private String database;
/**
* @Description: 数据库表
*/
private String table;
/**
* @Description: 类名
*/
private String entityName;
/**
* @Description: 类对象
*/
private String objectName;
/**
* @Description: 类说明
*/
private String entityComment;
/**
* @Description: 日期时间
*/
private String createTime;
/**
* @Description: 随机数/sql字段
*/
private String agile;
/**
* @Description: 类路径
*/
private String entityUrl;
/**
* @Description: dao路径
*/
private String daoUrl;
/**
* @Description: xml-mapper路径
*/
private String mapperUrl;
/**
* @Description: service路径
*/
private String serviceUrl;
/**
* @Description: serviceImpl路径
*/
private String serviceImplUrl;
/**
* @Description: Controller路径
*/
private String controllerUrl;
/**
* @Description: 类信息
*/
private List<PropertyInfo> cis;
public BasisInfo(String project, String author, String version, String dbUrl, String dbName, String dbPassword,
String database, String createTime, String agile, String entityUrl, String daoUrl, String mapperUrl,
String serviceUrl, String serviceImplUrl, String controllerUrl) {
......
/**
* @filename:GeneratorFileUrl 2018年06月06日
* @project mybatis-generator flying-cattle V1.0
* Copyright(c) 2018 BianP Co. Ltd.
* All right reserved.
*/
package com.github.mybatis.entity;
import java.io.Serializable;
......@@ -11,41 +5,21 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @Description: GeneratorFileUrl 生产文件地址
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GeneratorFileUrl implements Serializable{
private static final long serialVersionUID = 123125L;
/**
* @Description: 实体类路径
*/
private String entityUrl;
/**
* @Description: dao路径
*/
private String daoUrl;
/**
* @Description: mapper配置文件路径
*/
private String mapperUrl;
/**
* @Description: service路径
*/
private String serviceUrl;
/**
* @Description: service实现类路径
*/
private String serviceImplUrl;
/**
* @Description: controller 控制类的
*/
private String controllerUrl;
}
......@@ -14,16 +14,10 @@ import lombok.ToString;
public class JsonResult implements Serializable{
private static final long serialVersionUID = 123126L;
/**
* @Description: 状态码(大于0成功,小于0失败)
*/
private Integer code;
/**
* @Description: 消息说明
*/
private String message;
/**
* @Description: 返回对象
*/
private Object data;
}
/**
* @filename:ClassInfo 2018年06月06日
* @project mybatis-generator flying-cattle V1.0
* Copyright(c) 2018 BianP Co. Ltd.
* All right reserved.
*/
package com.github.mybatis.entity;
import java.io.Serializable;
......@@ -12,38 +6,20 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @Description: ClassInfo 表基础信息
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PropertyInfo implements Serializable{
private static final long serialVersionUID = 123124L;
/**
* @Description: 数据库列名
*/
private String column;
/**
* @Description: 数据库类型
*/
private String jdbcType;
/**
* @Description: 数据库字段注释
*/
private String comment;
/**
* @Description: 属性名
*/
private String property;
/**
* @Description: Java类型
*/
private String javaType;
}
......@@ -10,16 +10,7 @@ import freemarker.template.Configuration;
import freemarker.template.Template;
public class FreemarkerUtil {
/**
* 创建通过模板生成的文件
*
* @param dataModel
* 数据模型
* @param templateName
* 输出模版
* @param filePath
* 输出文件路径
*/
public static JsonResult createFile(BasisInfo dataModel, String templateName, String filePath) {
JsonResult result=new JsonResult();
FileWriter out = null;
......
......@@ -15,34 +15,20 @@ public class Generator {
public static final String SERVICE_IMPL="serviceImpl";
public static final String CONTROLLER="controller";
/**
* @explain ①创建实体类
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//①创建实体类
public static JsonResult createEntity(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getEntityUrl(), bi.getEntityName(), ENTITY);
return FreemarkerUtil.createFile(bi, "entity.ftl", fileUrl);
}
/**
* @explain ②创建DAO
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//②创建DAO
public static JsonResult createDao(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getDaoUrl(), bi.getEntityName(), DAO);
return FreemarkerUtil.createFile(bi, "dao.ftl", fileUrl);
}
/**
* @explain ③创建mapper配置文件
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//③创建mapper配置文件
public static JsonResult createDaoImpl(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getMapperUrl(), bi.getEntityName(), DAO_IMPL);
List<PropertyInfo> list=bi.getCis();
......@@ -55,34 +41,19 @@ public class Generator {
return FreemarkerUtil.createFile(bi, "mapper.ftl", fileUrl);
}
/**
* @explain ④创建SERVICE
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//④创建SERVICE
public static JsonResult createService(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceUrl(), bi.getEntityName(), SERVICE);
return FreemarkerUtil.createFile(bi, "service.ftl", fileUrl);
}
/**
* @explain ⑤创建SERVICE_IMPL
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//⑤创建SERVICE_IMPL
public static JsonResult createServiceImpl(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceImplUrl(), bi.getEntityName(), SERVICE_IMPL);
return FreemarkerUtil.createFile(bi, "serviceImpl.ftl", fileUrl);
}
/**
* @explain ⑥创建CONTROLLER
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
//⑥创建CONTROLLER
public static JsonResult createController(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getControllerUrl(), bi.getEntityName(), CONTROLLER);
return FreemarkerUtil.createFile(bi, "controller.ftl", fileUrl);
......
......@@ -2,16 +2,6 @@ package com.github.mybatis.util;
public class MySqlToJavaUtil {
/**
*
* @Title: firstTocapitalLetters
* @Description: TODO(类名首先字母变大写)
* @param table
* @return 设定文件
* @return String 返回类型
* @author BianPeng
* @date 2018年6月30日
*/
public static String getClassName(String table) {
table=changeToJavaFiled(table);
StringBuilder sbuilder = new StringBuilder();
......@@ -21,16 +11,6 @@ public class MySqlToJavaUtil {
return sbuilder.toString();
}
/**
*
* @Title: changeToJavaFiled
* @Description: TODO(将数据库中带下划线的字段转换为Java常用的驼峰字段)
* @param field
* @return 设定文件
* @return String 返回类型
* @author BianPeng
* @date 2018年6月30日
*/
public static String changeToJavaFiled(String field) {
String[] fields = field.split("_");
StringBuilder sbuilder = new StringBuilder(fields[0]);
......@@ -42,16 +22,6 @@ public class MySqlToJavaUtil {
return sbuilder.toString();
}
/**
*
* @Title: sqlTypeToJavaType
* @Description: TODO(功能:感觉数据类型获得Java的数据类型)
* @param sqlType
* @return javaType
* @return String 返回类型
* @author BianPeng
* @date 2018年6月30日
*/
public static String jdbcTypeToJavaType(String sqlType) {
if (sqlType.equalsIgnoreCase("bit")) {
return "Boolean";
......
......@@ -56,10 +56,10 @@ public class ${entityName}Controller {
@GetMapping("/get${entityName}ById/{id}")
@ApiOperation(value = "获取${entityComment}信息", notes = "获取${entityComment}信息[${objectName}],作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "${entityComment}id", required = true, dataType = "Long")
public JsonResult get{entityName}ById(@PathVariable("id")Long id){
public JsonResult get${entityName}ById(@PathVariable("id")Long id){
JsonResult result=new JsonResult();
try {
{entityName} ${objectName}=${objectName}ServiceImpl.selectByPrimaryKey(id);
${entityName} ${objectName}=${objectName}ServiceImpl.selectByPrimaryKey(id);
if (${objectName}!=null) {
result.setCode(1);
result.setMessage("成功");
......@@ -86,7 +86,7 @@ public class ${entityName}Controller {
*/
@PostMapping("/insertSelective")
@ApiOperation(value = "添加${entityComment}", notes = "添加${entityComment}[${objectName}],作者:${author}")
public JsonResult insertSelective({entityName} ${objectName}){
public JsonResult insertSelective(${entityName} ${objectName}){
JsonResult result=new JsonResult();
try {
int rg=${objectName}ServiceImpl.insertSelective(${objectName});
......@@ -147,7 +147,7 @@ public class ${entityName}Controller {
*/
@ApiOperation(value = "修改${entityComment}", notes = "修改${entityComment}[${objectName}],作者:${author}")
@PostMapping("/updateByPrimaryKeySelective")
public JsonResult updateByPrimaryKeySelective({entityName} ${objectName}){
public JsonResult updateByPrimaryKeySelective(${entityName} ${objectName}){
JsonResult result=new JsonResult();
try {
int reg = ${objectName}ServiceImpl.updateByPrimaryKeySelective(${objectName});
......@@ -171,16 +171,16 @@ public class ${entityName}Controller {
/**
* @explain 获取匹配${entityComment}
* @param 对象参数:${objectName}
* @return List<{entityName}>
* @return List<${entityName}>
* @author ${author}
* @time ${createTime}
*/
@ApiOperation(value = "条件查询${entityComment}", notes = "条件查询[${objectName}],作者:${author}")
@PostMapping("/query{entityName}List")
public JsonResult query{entityName}List({entityName} ${objectName}){
@PostMapping("/query${entityName}List")
public JsonResult query${entityName}List(${entityName} ${objectName}){
JsonResult result=new JsonResult();
try {
List<{entityName}> list = ${objectName}ServiceImpl.query{entityName}List(${objectName});
List<${entityName}> list = ${objectName}ServiceImpl.query${entityName}List(${objectName});
result.setCode(1);
result.setMessage("成功");
result.setData(list);
......@@ -194,28 +194,28 @@ public class ${entityName}Controller {
/**
* @explain 分页条件查询${entityComment}
* @param 对象参数:AppPage<{entityName}>
* @return PageInfo<{entityName}>
* @param 对象参数:AppPage<${entityName}>
* @return PageInfo<${entityName}>
* @author ${author}
* @time ${createTime}
*/
@GetMapping("/getPage{entityName}")
@ApiOperation(value = "分页查询", notes = "分页查询返回对象[PageInfo<{entityName}>],作者:边鹏")
@GetMapping("/getPage${entityName}")
@ApiOperation(value = "分页查询", notes = "分页查询返回对象[PageInfo<${entityName}>],作者:边鹏")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"),
@ApiImplicitParam(paramType="query", name = "pageSize", value = "页行数", required = true, dataType = "int")
})
public JsonResult get{entityName}BySearch(Integer pageNum,Integer pageSize){
public JsonResult get${entityName}BySearch(Integer pageNum,Integer pageSize){
JsonResult result=new JsonResult();
AppPage<{entityName}> page =new AppPage<{entityName}>();
AppPage<${entityName}> page =new AppPage<${entityName}>();
page.setPageNum(pageNum);
page.setPageSize(pageSize);
//其他参数
{entityName} ${objectName}=new {entityName}();
${entityName} ${objectName}=new ${entityName}();
page.setParam(${objectName});
//分页数据
try {
PageInfo<{entityName}> pageInfo = ${objectName}ServiceImpl.get{entityName}BySearch(page);
PageInfo<${entityName}> pageInfo = ${objectName}ServiceImpl.get${entityName}BySearch(page);
result.setCode(1);
result.setMessage("成功");
result.setData(pageInfo);
......
......@@ -70,4 +70,5 @@ public class ${entityName}ServiceImpl implements ${entityName}Service {
List<${entityName}> list=${objectName}Dao.query${entityName}List(page.getParam());
PageInfo<${entityName}> pageInfo = new PageInfo<${entityName}>(list);
return pageInfo;
}
\ No newline at end of file
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment