Commit e05535d8 by bianpeng

修改

parent a42064e6
...@@ -88,8 +88,18 @@ ...@@ -88,8 +88,18 @@
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<profiles> <profiles>
<profile> <profile>
<id>disable-javadoc-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
<profile>
<id>release</id> <id>release</id>
<build> <build>
<resources> <resources>
...@@ -119,10 +129,14 @@ ...@@ -119,10 +129,14 @@
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
......
/**
* @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; package com.github.mybatis.entity;
import java.io.Serializable; import java.io.Serializable;
...@@ -13,105 +7,52 @@ import lombok.AllArgsConstructor; ...@@ -13,105 +7,52 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/**
*
* @Description: BasisInfo 基础信息
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class BasisInfo implements Serializable{ public class BasisInfo implements Serializable{
private static final long serialVersionUID = 123123L; private static final long serialVersionUID = 123123L;
/**
* @Description: 项目名字
*/
private String project; private String project;
/**
* @Description: 作者名字
*/
private String author; private String author;
/**
* @Description: 版本号
*/
private String version; private String version;
/**
* @Description: 数据库连接
*/
private String dbUrl; private String dbUrl;
/**
* @Description: 数据访问账户
*/
private String dbName; private String dbName;
/**
* @Description: 数据访问密码
*/
private String dbPassword; private String dbPassword;
/**
* @Description: 数据库名
*/
private String database; private String database;
/**
* @Description: 数据库表
*/
private String table; private String table;
/**
* @Description: 类名
*/
private String entityName; private String entityName;
/**
* @Description: 类对象
*/
private String objectName; private String objectName;
/**
* @Description: 类说明
*/
private String entityComment; private String entityComment;
/**
* @Description: 日期时间
*/
private String createTime; private String createTime;
/**
* @Description: 随机数/sql字段
*/
private String agile; private String agile;
/**
* @Description: 类路径
*/
private String entityUrl; private String entityUrl;
/**
* @Description: dao路径
*/
private String daoUrl; private String daoUrl;
/**
* @Description: xml-mapper路径
*/
private String mapperUrl; private String mapperUrl;
/**
* @Description: service路径
*/
private String serviceUrl; private String serviceUrl;
/**
* @Description: serviceImpl路径
*/
private String serviceImplUrl; private String serviceImplUrl;
/**
* @Description: Controller路径
*/
private String controllerUrl; private String controllerUrl;
/**
* @Description: 类信息
*/
private List<PropertyInfo> cis; private List<PropertyInfo> cis;
public BasisInfo(String project, String author, String version, String dbUrl, String dbName, String dbPassword, 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 database, String createTime, String agile, String entityUrl, String daoUrl, String mapperUrl,
String serviceUrl, String serviceImplUrl, String controllerUrl) { 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; package com.github.mybatis.entity;
import java.io.Serializable; import java.io.Serializable;
...@@ -11,41 +5,21 @@ import lombok.AllArgsConstructor; ...@@ -11,41 +5,21 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/**
*
* @Description: GeneratorFileUrl 生产文件地址
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class GeneratorFileUrl implements Serializable{ public class GeneratorFileUrl implements Serializable{
private static final long serialVersionUID = 123125L; private static final long serialVersionUID = 123125L;
/**
* @Description: 实体类路径
*/
private String entityUrl; private String entityUrl;
/**
* @Description: dao路径
*/
private String daoUrl; private String daoUrl;
/**
* @Description: mapper配置文件路径
*/
private String mapperUrl; private String mapperUrl;
/**
* @Description: service路径
*/
private String serviceUrl; private String serviceUrl;
/**
* @Description: service实现类路径
*/
private String serviceImplUrl; private String serviceImplUrl;
/**
* @Description: controller 控制类的
*/
private String controllerUrl; private String controllerUrl;
} }
...@@ -14,16 +14,10 @@ import lombok.ToString; ...@@ -14,16 +14,10 @@ import lombok.ToString;
public class JsonResult implements Serializable{ public class JsonResult implements Serializable{
private static final long serialVersionUID = 123126L; private static final long serialVersionUID = 123126L;
/**
* @Description: 状态码(大于0成功,小于0失败)
*/
private Integer code; private Integer code;
/**
* @Description: 消息说明
*/
private String message; private String message;
/**
* @Description: 返回对象
*/
private Object data; 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; package com.github.mybatis.entity;
import java.io.Serializable; import java.io.Serializable;
...@@ -12,38 +6,20 @@ import lombok.AllArgsConstructor; ...@@ -12,38 +6,20 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/**
*
* @Description: ClassInfo 表基础信息
* @Author: flying-cattle
* @CreateDate: 2018-06-06
* @Version: v1.0
*
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class PropertyInfo implements Serializable{ public class PropertyInfo implements Serializable{
private static final long serialVersionUID = 123124L; private static final long serialVersionUID = 123124L;
/**
* @Description: 数据库列名
*/
private String column; private String column;
/**
* @Description: 数据库类型
*/
private String jdbcType; private String jdbcType;
/**
* @Description: 数据库字段注释
*/
private String comment; private String comment;
/**
* @Description: 属性名
*/
private String property; private String property;
/**
* @Description: Java类型
*/
private String javaType; private String javaType;
} }
...@@ -10,16 +10,7 @@ import freemarker.template.Configuration; ...@@ -10,16 +10,7 @@ import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
public class FreemarkerUtil { public class FreemarkerUtil {
/**
* 创建通过模板生成的文件
*
* @param dataModel
* 数据模型
* @param templateName
* 输出模版
* @param filePath
* 输出文件路径
*/
public static JsonResult createFile(BasisInfo dataModel, String templateName, String filePath) { public static JsonResult createFile(BasisInfo dataModel, String templateName, String filePath) {
JsonResult result=new JsonResult(); JsonResult result=new JsonResult();
FileWriter out = null; FileWriter out = null;
......
...@@ -15,34 +15,20 @@ public class Generator { ...@@ -15,34 +15,20 @@ public class Generator {
public static final String SERVICE_IMPL="serviceImpl"; public static final String SERVICE_IMPL="serviceImpl";
public static final String CONTROLLER="controller"; public static final String CONTROLLER="controller";
/**
* @explain ①创建实体类 //①创建实体类
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createEntity(String url,BasisInfo bi) { public static JsonResult createEntity(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getEntityUrl(), bi.getEntityName(), ENTITY); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getEntityUrl(), bi.getEntityName(), ENTITY);
return FreemarkerUtil.createFile(bi, "entity.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "entity.ftl", fileUrl);
} }
/** //②创建DAO
* @explain ②创建DAO
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createDao(String url,BasisInfo bi) { public static JsonResult createDao(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getDaoUrl(), bi.getEntityName(), DAO); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getDaoUrl(), bi.getEntityName(), DAO);
return FreemarkerUtil.createFile(bi, "dao.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "dao.ftl", fileUrl);
} }
/** //③创建mapper配置文件
* @explain ③创建mapper配置文件
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createDaoImpl(String url,BasisInfo bi) { public static JsonResult createDaoImpl(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getMapperUrl(), bi.getEntityName(), DAO_IMPL); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getMapperUrl(), bi.getEntityName(), DAO_IMPL);
List<PropertyInfo> list=bi.getCis(); List<PropertyInfo> list=bi.getCis();
...@@ -55,34 +41,19 @@ public class Generator { ...@@ -55,34 +41,19 @@ public class Generator {
return FreemarkerUtil.createFile(bi, "mapper.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "mapper.ftl", fileUrl);
} }
/** //④创建SERVICE
* @explain ④创建SERVICE
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createService(String url,BasisInfo bi) { public static JsonResult createService(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceUrl(), bi.getEntityName(), SERVICE); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceUrl(), bi.getEntityName(), SERVICE);
return FreemarkerUtil.createFile(bi, "service.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "service.ftl", fileUrl);
} }
/** //⑤创建SERVICE_IMPL
* @explain ⑤创建SERVICE_IMPL
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createServiceImpl(String url,BasisInfo bi) { public static JsonResult createServiceImpl(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceImplUrl(), bi.getEntityName(), SERVICE_IMPL); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getServiceImplUrl(), bi.getEntityName(), SERVICE_IMPL);
return FreemarkerUtil.createFile(bi, "serviceImpl.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "serviceImpl.ftl", fileUrl);
} }
/** //⑥创建CONTROLLER
* @explain ⑥创建CONTROLLER
* @param 对象参数:url、BasisInfo
* @return JsonResult
* @author BianP
*/
public static JsonResult createController(String url,BasisInfo bi) { public static JsonResult createController(String url,BasisInfo bi) {
String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getControllerUrl(), bi.getEntityName(), CONTROLLER); String fileUrl= EntityInfoUtil.getGeneratorFileUrl(url, bi.getControllerUrl(), bi.getEntityName(), CONTROLLER);
return FreemarkerUtil.createFile(bi, "controller.ftl", fileUrl); return FreemarkerUtil.createFile(bi, "controller.ftl", fileUrl);
......
...@@ -2,16 +2,6 @@ package com.github.mybatis.util; ...@@ -2,16 +2,6 @@ package com.github.mybatis.util;
public class MySqlToJavaUtil { public class MySqlToJavaUtil {
/**
*
* @Title: firstTocapitalLetters
* @Description: TODO(类名首先字母变大写)
* @param table
* @return 设定文件
* @return String 返回类型
* @author BianPeng
* @date 2018年6月30日
*/
public static String getClassName(String table) { public static String getClassName(String table) {
table=changeToJavaFiled(table); table=changeToJavaFiled(table);
StringBuilder sbuilder = new StringBuilder(); StringBuilder sbuilder = new StringBuilder();
...@@ -21,16 +11,6 @@ public class MySqlToJavaUtil { ...@@ -21,16 +11,6 @@ public class MySqlToJavaUtil {
return sbuilder.toString(); 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) { public static String changeToJavaFiled(String field) {
String[] fields = field.split("_"); String[] fields = field.split("_");
StringBuilder sbuilder = new StringBuilder(fields[0]); StringBuilder sbuilder = new StringBuilder(fields[0]);
...@@ -42,16 +22,6 @@ public class MySqlToJavaUtil { ...@@ -42,16 +22,6 @@ public class MySqlToJavaUtil {
return sbuilder.toString(); 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) { public static String jdbcTypeToJavaType(String sqlType) {
if (sqlType.equalsIgnoreCase("bit")) { if (sqlType.equalsIgnoreCase("bit")) {
return "Boolean"; return "Boolean";
......
...@@ -56,10 +56,10 @@ public class ${entityName}Controller { ...@@ -56,10 +56,10 @@ public class ${entityName}Controller {
@GetMapping("/get${entityName}ById/{id}") @GetMapping("/get${entityName}ById/{id}")
@ApiOperation(value = "获取${entityComment}信息", notes = "获取${entityComment}信息[${objectName}],作者:${author}") @ApiOperation(value = "获取${entityComment}信息", notes = "获取${entityComment}信息[${objectName}],作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "${entityComment}id", required = true, dataType = "Long") @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(); JsonResult result=new JsonResult();
try { try {
{entityName} ${objectName}=${objectName}ServiceImpl.selectByPrimaryKey(id); ${entityName} ${objectName}=${objectName}ServiceImpl.selectByPrimaryKey(id);
if (${objectName}!=null) { if (${objectName}!=null) {
result.setCode(1); result.setCode(1);
result.setMessage("成功"); result.setMessage("成功");
...@@ -86,7 +86,7 @@ public class ${entityName}Controller { ...@@ -86,7 +86,7 @@ public class ${entityName}Controller {
*/ */
@PostMapping("/insertSelective") @PostMapping("/insertSelective")
@ApiOperation(value = "添加${entityComment}", notes = "添加${entityComment}[${objectName}],作者:${author}") @ApiOperation(value = "添加${entityComment}", notes = "添加${entityComment}[${objectName}],作者:${author}")
public JsonResult insertSelective({entityName} ${objectName}){ public JsonResult insertSelective(${entityName} ${objectName}){
JsonResult result=new JsonResult(); JsonResult result=new JsonResult();
try { try {
int rg=${objectName}ServiceImpl.insertSelective(${objectName}); int rg=${objectName}ServiceImpl.insertSelective(${objectName});
...@@ -147,7 +147,7 @@ public class ${entityName}Controller { ...@@ -147,7 +147,7 @@ public class ${entityName}Controller {
*/ */
@ApiOperation(value = "修改${entityComment}", notes = "修改${entityComment}[${objectName}],作者:${author}") @ApiOperation(value = "修改${entityComment}", notes = "修改${entityComment}[${objectName}],作者:${author}")
@PostMapping("/updateByPrimaryKeySelective") @PostMapping("/updateByPrimaryKeySelective")
public JsonResult updateByPrimaryKeySelective({entityName} ${objectName}){ public JsonResult updateByPrimaryKeySelective(${entityName} ${objectName}){
JsonResult result=new JsonResult(); JsonResult result=new JsonResult();
try { try {
int reg = ${objectName}ServiceImpl.updateByPrimaryKeySelective(${objectName}); int reg = ${objectName}ServiceImpl.updateByPrimaryKeySelective(${objectName});
...@@ -171,16 +171,16 @@ public class ${entityName}Controller { ...@@ -171,16 +171,16 @@ public class ${entityName}Controller {
/** /**
* @explain 获取匹配${entityComment} * @explain 获取匹配${entityComment}
* @param 对象参数:${objectName} * @param 对象参数:${objectName}
* @return List<{entityName}> * @return List<${entityName}>
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@ApiOperation(value = "条件查询${entityComment}", notes = "条件查询[${objectName}],作者:${author}") @ApiOperation(value = "条件查询${entityComment}", notes = "条件查询[${objectName}],作者:${author}")
@PostMapping("/query{entityName}List") @PostMapping("/query${entityName}List")
public JsonResult query{entityName}List({entityName} ${objectName}){ public JsonResult query${entityName}List(${entityName} ${objectName}){
JsonResult result=new JsonResult(); JsonResult result=new JsonResult();
try { try {
List<{entityName}> list = ${objectName}ServiceImpl.query{entityName}List(${objectName}); List<${entityName}> list = ${objectName}ServiceImpl.query${entityName}List(${objectName});
result.setCode(1); result.setCode(1);
result.setMessage("成功"); result.setMessage("成功");
result.setData(list); result.setData(list);
...@@ -194,28 +194,28 @@ public class ${entityName}Controller { ...@@ -194,28 +194,28 @@ public class ${entityName}Controller {
/** /**
* @explain 分页条件查询${entityComment} * @explain 分页条件查询${entityComment}
* @param 对象参数:AppPage<{entityName}> * @param 对象参数:AppPage<${entityName}>
* @return PageInfo<{entityName}> * @return PageInfo<${entityName}>
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@GetMapping("/getPage{entityName}") @GetMapping("/getPage${entityName}")
@ApiOperation(value = "分页查询", notes = "分页查询返回对象[PageInfo<{entityName}>],作者:边鹏") @ApiOperation(value = "分页查询", notes = "分页查询返回对象[PageInfo<${entityName}>],作者:边鹏")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"),
@ApiImplicitParam(paramType="query", name = "pageSize", 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(); JsonResult result=new JsonResult();
AppPage<{entityName}> page =new AppPage<{entityName}>(); AppPage<${entityName}> page =new AppPage<${entityName}>();
page.setPageNum(pageNum); page.setPageNum(pageNum);
page.setPageSize(pageSize); page.setPageSize(pageSize);
//其他参数 //其他参数
{entityName} ${objectName}=new {entityName}(); ${entityName} ${objectName}=new ${entityName}();
page.setParam(${objectName}); page.setParam(${objectName});
//分页数据 //分页数据
try { try {
PageInfo<{entityName}> pageInfo = ${objectName}ServiceImpl.get{entityName}BySearch(page); PageInfo<${entityName}> pageInfo = ${objectName}ServiceImpl.get${entityName}BySearch(page);
result.setCode(1); result.setCode(1);
result.setMessage("成功"); result.setMessage("成功");
result.setData(pageInfo); result.setData(pageInfo);
......
...@@ -71,3 +71,4 @@ public class ${entityName}ServiceImpl implements ${entityName}Service { ...@@ -71,3 +71,4 @@ public class ${entityName}ServiceImpl implements ${entityName}Service {
PageInfo<${entityName}> pageInfo = new PageInfo<${entityName}>(list); PageInfo<${entityName}> pageInfo = new PageInfo<${entityName}>(list);
return pageInfo; return pageInfo;
} }
}
\ 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