Commit ab999614 by flying-cattle

版本大改动,包名变化,控制器父类抽离

parent 7a22e083
......@@ -6,7 +6,7 @@
<groupId>com.github.flying-cattle</groupId>
<artifactId>mybatis-dsc-generator</artifactId>
<version>3.0.1.RELEASE</version>
<version>3.0.2.RELEASE</version>
<packaging>jar</packaging>
<name>mybatis-dsc-generator</name>
......
package com.github.flying.cattle.mdg.aid;
/**
* @author BianP
* @explain 常量类
*/
public class Const {
/********************** 响应 ****************************/
public static final String CODE_SUCCESS = "200"; // 成功
public static final String CODE_FAILED = "0"; // 失败
public static final String OPERATE_SUCCESS = "success"; // 成功
public static final String OPERATE_FAILED = "failed"; // 失败
public static final String HANDLE_PATH = ".*/((index.html)|(index.jsp)).*";
}
package com.github.flying.cattle.mdg.aid;
import java.io.Serializable;
import java.net.ConnectException;
import java.sql.SQLException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 用户服务层</P>
* @version: V1.0
* @author: BianPeng
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2019/4/9 flying-cattle V1.0 initialize
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult<T> implements Serializable{
private static final long serialVersionUID = 1071681926787951549L;
/**
*<p>状态码</p>
*/
private String code;
/**
* <p>业务码</p>
*/
private String operate;
/**
*<p> 状态说明</p>
*/
private String message;
/**
* <p>返回数据</p>
*/
private T data;
/**
* <p>返回成功,有数据</p>
*/
public JsonResult<T> success(T data) {
this.setCode(Const.CODE_SUCCESS);
this.setOperate(Const.OPERATE_SUCCESS);
this.setMessage("操作成功!");
this.setData(data);
return this;
}
/**
* <p>返回成功,无数据</p>
*/
public JsonResult<T> success() {
this.setCode(Const.CODE_SUCCESS);
this.setOperate(Const.OPERATE_SUCCESS);
this.setMessage("操作成功!");
this.setData(null);
return this;
}
/**
* <p>返回成功,无数据</p>
*/
public JsonResult<T> error(String message) {
this.setCode(Const.CODE_FAILED);
this.setOperate(Const.OPERATE_FAILED);
this.setMessage(message);
this.setData(null);
return this;
}
public JsonResult(Throwable throwable) {
this.operate=Const.OPERATE_FAILED;
if(throwable instanceof NullPointerException){
this.code= "1001";
this.message="空指针:"+throwable;
}else if(throwable instanceof ClassCastException ){
this.code= "1002";
this.message="类型强制转换异常:"+throwable;
}else if(throwable instanceof ConnectException){
this.code= "1003";
this.message="链接失败:"+throwable;
}else if(throwable instanceof IllegalArgumentException ){
this.code= "1004";
this.message="传递非法参数异常:"+throwable;
}else if(throwable instanceof NumberFormatException){
this.code= "1005";
this.message="数字格式异常:"+throwable;
}else if(throwable instanceof IndexOutOfBoundsException){
this.code= "1006";
this.message="下标越界异常:"+throwable;
}else if(throwable instanceof SecurityException){
this.code= "1007";
this.message="安全异常:"+throwable;
}else if(throwable instanceof SQLException){
this.code= "1008";
this.message="数据库异常:"+throwable;
}else if(throwable instanceof ArithmeticException){
this.code= "1009";
this.message="算术运算异常:"+throwable;
}else if(throwable instanceof RuntimeException){
this.code= "1010";
this.message="运行时异常:"+throwable;
}else if(throwable instanceof Exception){
this.code= "9999";
this.message="未知异常"+throwable;
}
}
}
/**
* @filename:Const 2018年6月30日
* @project 紫马 边鹏 V1.0
* Copyright(c) 2017 BianP Co. Ltd.
* All right reserved.
*/
package com.github.flying.cattle.mdg.aid;
import java.io.Serializable;
import lombok.Data;
/**
* app分页组件
* @author bianP
* @version $Id: AppPage.java, v 0.1 2018年06月20日 下午2:31:23
*/
@Data
public class PageParam<T> implements Serializable{
private static final long serialVersionUID = -7248374800878487522L;
/**
* <p>当前页</p>
*/
private int pageNum=1;
/**
* <p>每页记录数</p>
*/
private int pageSize=10;
/**
* <p>分页外的其它参数</p>
*/
private T param;
}
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.convert;
package com.github.flying.cattle.mdg.convert;
/**
* Copyright: Copyright (c) 2019
......
......@@ -5,7 +5,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.convert;
package com.github.flying.cattle.mdg.convert;
/**
* Copyright: Copyright (c) 2019
......
......@@ -7,7 +7,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:09:35
*/
package com.github.mybatis.fl.convert;
package com.github.flying.cattle.mdg.convert;
/**
* Copyright: Copyright (c) 2019
......
......@@ -7,7 +7,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:06:16
*/
package com.github.mybatis.fl.convert;
package com.github.flying.cattle.mdg.convert;
/**
* Copyright: Copyright (c) 2019
......
......@@ -5,9 +5,9 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:13:13
*/
package com.github.mybatis.fl.convert;
package com.github.flying.cattle.mdg.convert;
import com.github.mybatis.fl.convert.ITypeConvert;
import com.github.flying.cattle.mdg.convert.ITypeConvert;
/**
* Copyright: Copyright (c) 2019
*
......
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.entity;
package com.github.flying.cattle.mdg.entity;
import java.io.Serializable;
import java.util.List;
......@@ -67,6 +67,8 @@ public class BasisInfo implements Serializable{
private String serviceImplUrl;
private String abstractControllerUrl;
private String controllerUrl;
private String swaggerConfigUrl;
......@@ -96,6 +98,7 @@ public class BasisInfo implements Serializable{
this.serviceUrl = serviceUrl;
this.serviceImplUrl = serviceImplUrl;
this.controllerUrl = controllerUrl;
this.abstractControllerUrl = controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".aid";
this.swaggerConfigUrl=controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".config";
}
}
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.entity;
package com.github.flying.cattle.mdg.entity;
import java.io.Serializable;
import lombok.AllArgsConstructor;
......
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.entity;
package com.github.flying.cattle.mdg.entity;
import java.io.Serializable;
......
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.entity;
package com.github.flying.cattle.mdg.entity;
import java.io.Serializable;
......@@ -28,7 +28,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult implements Serializable{
public class ResultJson implements Serializable{
private static final long serialVersionUID = 123126L;
......
......@@ -4,7 +4,7 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.util;
package com.github.flying.cattle.mdg.util;
import java.sql.Connection;
import java.sql.DriverManager;
......@@ -14,8 +14,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.github.mybatis.fl.entity.BasisInfo;
import com.github.mybatis.fl.entity.PropertyInfo;
import com.github.flying.cattle.mdg.entity.BasisInfo;
import com.github.flying.cattle.mdg.entity.PropertyInfo;
/**
* Copyright: Copyright (c) 2019
*
......
......@@ -4,14 +4,14 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.util;
package com.github.flying.cattle.mdg.util;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.github.mybatis.fl.entity.BasisInfo;
import com.github.mybatis.fl.entity.JsonResult;
import com.github.flying.cattle.mdg.entity.BasisInfo;
import com.github.flying.cattle.mdg.entity.ResultJson;
import freemarker.template.Configuration;
import freemarker.template.Template;
......@@ -30,8 +30,8 @@ import freemarker.template.Template;
*/
public class FreemarkerUtil {
public static JsonResult createFile(BasisInfo dataModel, String templateName, String filePath) {
JsonResult result=new JsonResult();
public static ResultJson createFile(BasisInfo dataModel, String templateName, String filePath) {
ResultJson result=new ResultJson();
FileWriter out = null;
String fileName=dataModel.getEntityName()+messageStr(templateName);
try {
......
......@@ -4,13 +4,13 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.util;
package com.github.flying.cattle.mdg.util;
import java.util.List;
import com.github.mybatis.fl.entity.BasisInfo;
import com.github.mybatis.fl.entity.JsonResult;
import com.github.mybatis.fl.entity.PropertyInfo;
import com.github.flying.cattle.mdg.entity.BasisInfo;
import com.github.flying.cattle.mdg.entity.ResultJson;
import com.github.flying.cattle.mdg.entity.PropertyInfo;
/**
* Copyright: Copyright (c) 2019
......@@ -35,19 +35,19 @@ public class Generator {
public static final String SWAGGER_CONFIG="swaggerConfig";
//①创建实体类
public static JsonResult createEntity(String url,BasisInfo bi) {
public static ResultJson createEntity(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getEntityUrl(), bi.getEntityName(), ENTITY);
return FreemarkerUtil.createFile(bi, "entity.ftl", fileUrl);
}
//②创建DAO
public static JsonResult createDao(String url,BasisInfo bi) {
public static ResultJson createDao(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getDaoUrl(), bi.getEntityName(), DAO);
return FreemarkerUtil.createFile(bi, "dao.ftl", fileUrl);
}
//③创建mapper配置文件
public static JsonResult createDaoImpl(String url,BasisInfo bi) {
public static ResultJson createDaoImpl(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getMapperUrl(), bi.getEntityName(), DAO_IMPL);
List<PropertyInfo> list=bi.getCis();
String agile="";
......@@ -60,24 +60,32 @@ public class Generator {
}
//④创建SERVICE
public static JsonResult createService(String url,BasisInfo bi) {
public static ResultJson createService(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getServiceUrl(), bi.getEntityName(), SERVICE);
return FreemarkerUtil.createFile(bi, "service.ftl", fileUrl);
}
//⑤创建SERVICE_IMPL
public static JsonResult createServiceImpl(String url,BasisInfo bi) {
public static ResultJson createServiceImpl(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getServiceImplUrl(), bi.getEntityName(), SERVICE_IMPL);
return FreemarkerUtil.createFile(bi, "serviceImpl.ftl", fileUrl);
}
//⑥创建CONTROLLER
public static JsonResult createController(String url,BasisInfo bi) {
public static ResultJson createController(String url,BasisInfo bi) {
createAbstractController( url, bi); //保证父类一直存在
String fileUrl= getGeneratorFileUrl(url, bi.getControllerUrl(), bi.getEntityName(), CONTROLLER);
return FreemarkerUtil.createFile(bi, "controller.ftl", fileUrl);
}
//⑥创建CONTROLLER
public static JsonResult createSwaggerConfig(String url,BasisInfo bi) {
//⑦创建抽象的CONTROLLER
public static ResultJson createAbstractController(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url, bi.getAbstractControllerUrl(),"Abstract", CONTROLLER);
return FreemarkerUtil.createFile(bi, "AbstractController.ftl", fileUrl);
}
//⑧创建CONTROLLER
public static ResultJson createSwaggerConfig(String url,BasisInfo bi) {
String fileUrl= getGeneratorFileUrl(url,bi.getSwaggerConfigUrl(), "Swagger", SWAGGER_CONFIG);
return FreemarkerUtil.createFile(bi, "SwaggerConfig.ftl", fileUrl);
}
......
......@@ -4,10 +4,10 @@
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.util;
package com.github.flying.cattle.mdg.util;
import com.github.mybatis.fl.convert.DateType;
import com.github.mybatis.fl.convert.MySqlTypeConvert;
import com.github.flying.cattle.mdg.convert.DateType;
import com.github.flying.cattle.mdg.convert.MySqlTypeConvert;
/**
* Copyright: Copyright (c) 2019
*
......
/**
* @filename:${entityName}Controller ${createTime}
* @project ${project} ${version}
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${abstractControllerUrl};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.flying.cattle.mdg.aid.JsonResult;
import com.github.flying.cattle.mdg.aid.PageParam;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
/**
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}API接口层</P>
* @version: ${version}
* @author: ${author}
*
*/
public class AbstractController<S extends IService<T>,T>{
@Autowired
protected S baseService;
protected JsonResult<T> result = new JsonResult<T>();
/**
* @explain 查询对象 <swagger GET请求>
* @param 对象参数:id
* @return JsonResult
* @author ${author}
* @time 201949
*/
@GetMapping("/getById/{id}")
@ApiOperation(value = "获取对象", notes = "作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "对象id", required = true, dataType = "Long")
public JsonResult<T> getUserById(@PathVariable("id")Long id){
T obj=baseService.getById(id);
if (null!=obj ) {
result.success(obj);
}else {
result.error("查询对象不存在!");
}
return result;
}
/**
* @explain 删除对象
* @param 对象参数:id
* @return JsonResult
* @author ${author}
* @time 201949
*/
@PostMapping("/deleteById")
@ApiOperation(value = "删除", notes = "作者:${author}")
@ApiImplicitParam(paramType="query", name = "id", value = "对象id", required = true, dataType = "Long")
public JsonResult<T> deleteById(Long id){
JsonResult<T> result=new JsonResult<T>();
T obj=baseService.getById(id);
if (null!=obj) {
boolean rsg = baseService.removeById(id);
if (rsg) {
result.success();
}else {
result.error("删除失败!");
}
}else {
result.error("删除的对象不存在!");
}
return result;
}
/**
* @explain 添加
* @param 对象参数:T
* @return Boolean
* @author ${author}
* @time 201949
*/
@PostMapping("/insert")
@ApiOperation(value = "添加", notes = "作者:${author}")
public JsonResult<T> insert(T entity){
JsonResult<T> result=new JsonResult<T>();
if (null!=entity) {
boolean rsg = baseService.save(entity);
if (rsg) {
result.success();
}else {
result.error("添加失败!");
}
}else {
result.error("请传入正确参数!");
}
return result;
}
/**
* @explain 修改
* @param 对象参数:T
* @return Boolean
* @author ${author}
* @time 201949
*/
@PostMapping("/update")
@ApiOperation(value = "修改", notes = "作者:${author}")
public JsonResult<T> update(T entity){
JsonResult<T> result=new JsonResult<T>();
if (null!=entity) {
boolean rsg = baseService.updateById(entity);
if (rsg) {
result.success();
}else {
result.error("修改失败!");
}
}else {
result.error("请传入正确参数!");
}
return result;
}
/**
* @explain 分页条件查询用户
* @param 对象参数:AppPage<User>
* @return PageInfo<User>
* @author ${author}
* @time 2019520
*/
@GetMapping("/getPages")
@ApiOperation(value = "分页查询", notes = "分页查询返回[IPage<T>],作者:边鹏")
public JsonResult<IPage<T>> getUserPages(PageParam<T> param){
JsonResult<IPage<T>> returnPage=new JsonResult<IPage<T>>();
Page<T> page=new Page<T>(param.getPageNum(),param.getPageSize());
QueryWrapper<T> queryWrapper =new QueryWrapper<T>();
queryWrapper.setEntity(param.getParam());
//分页数据
IPage<T> pageData=baseService.page(page, queryWrapper);
returnPage.success(pageData);
return returnPage;
}
}
......@@ -18,6 +18,7 @@ import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* <p>自动生成工具:mybatis-dsc-generator</p>
* Swagger核心配置文件
* ========================
* @author ${author}
......
/**
* @filename:${entityName}Controller ${createTime}
* @project ${project} ${version}
* Copyright(c) 2018 ${author} Co. Ltd.
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${controllerUrl};
import com.item.util.JsonResult;
import ${abstractControllerUrl}.AbstractController;
import ${entityUrl}.${entityName};
import ${serviceUrl}.${entityName}Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Copyright: Copyright (c) 2019
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}API接口层</P>
* @version: ${version}
* @author: ${author}
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* ${createTime} ${author} ${version} initialize
*
*/
@Api(description = "${entityComment}",value="${entityComment}" )
@RestController
@RequestMapping("/${objectName}")
public class ${entityName}Controller {
public class ${entityName}Controller extends AbstractController<${entityName}Service,${entityName}>{
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
public ${entityName}Service ${objectName}ServiceImpl;
/**
* @explain 查询${entityComment}对象 <swagger GET请求>
* @param 对象参数:id
* @return ${objectName}
* @author ${author}
* @time ${createTime}
*/
@GetMapping("/getById/{id}")
@ApiOperation(value = "获取${entityComment}信息", notes = "获取${entityComment}信息[${objectName}],作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "${entityComment}id", required = true, dataType = "${idType}")
public JsonResult<${entityName}> getById(@PathVariable("id")${idType} id){
JsonResult<${entityName}> result=new JsonResult<${entityName}>();
try {
${entityName} ${objectName}=${objectName}ServiceImpl.getById(id);
if (${objectName}!=null) {
result.setType("success");
result.setMessage("成功");
result.setData(${objectName});
} else {
logger.error("获取${entityComment}失败ID:"+id);
result.setType("fail");
result.setMessage("你获取的${entityComment}不存在");
}
} catch (Exception e) {
logger.error("获取${entityComment}执行异常:"+e.getMessage());
result=new JsonResult<${entityName}>(e);
}
return result;
}
/**
* @explain 添加或者更新${entityComment}对象
* @param 对象参数:${objectName}
* @return int
* @author ${author}
* @time ${createTime}
*/
@PostMapping("/saveOrUpdate")
@ApiOperation(value = "添加${entityComment}", notes = "添加${entityComment}[${objectName}],作者:${author}")
public JsonResult<${entityName}> saveOrUpdate(${entityName} ${objectName}){
JsonResult<${entityName}> result=new JsonResult<${entityName}>();
try {
boolean rg=${objectName}ServiceImpl.saveOrUpdate(${objectName});
if (rg) {
result.setType("success");
result.setMessage("成功");
result.setData(${objectName});
} else {
logger.error("添加${entityComment}执行失败:"+${objectName}.toString());
result.setType("fail");
result.setMessage("执行失败,请稍后重试");
}
} catch (Exception e) {
logger.error("添加${entityComment}执行异常:"+e.getMessage());
result=new JsonResult<${entityName}>(e);
}
return result;
}
/**
* @explain 删除${entityComment}对象
* @param 对象参数:id
* @return int
* @author ${author}
* @time ${createTime}
*/
@PostMapping("/deleteByPrimaryKey")
@ApiOperation(value = "删除${entityComment}", notes = "删除${entityComment},作者:${author}")
@ApiImplicitParam(paramType="query", name = "id", value = "${entityComment}id", required = true, dataType = "${idType}")
public JsonResult<Object> deleteByPrimaryKey(${idType} id){
JsonResult<Object> result=new JsonResult<Object>();
try {
boolean reg=${objectName}ServiceImpl.removeById(id);
if (reg) {
result.setType("success");
result.setMessage("成功");
result.setData(id);
} else {
logger.error("删除${entityComment}失败ID:"+id);
result.setType("fail");
result.setMessage("执行错误,请稍后重试");
}
} catch (Exception e) {
logger.error("删除${entityComment}执行异常:"+e.getMessage());
result=new JsonResult<Object>(e);
}
return result;
}
/**
* @explain 分页条件查询${entityComment}
* @param 对象参数:AppPage<${entityName}>
* @return PageInfo<${entityName}>
* @author ${author}
* @time ${createTime}
*/
@GetMapping("/get${entityName}Pages")
@ApiOperation(value = "分页查询", notes = "分页查询返回对象[IPage<${entityName}>],作者:边鹏")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"),
@ApiImplicitParam(paramType="query", name = "pageSize", value = "页行数", required = true, dataType = "int")
})
public JsonResult<IPage<${entityName}>> get${entityName}Pages(Integer pageNum,Integer pageSize){
JsonResult<IPage<${entityName}>> result=new JsonResult<IPage<${entityName}>>();
Page<${entityName}> page=new Page<${entityName}>(pageNum,pageSize);
QueryWrapper<${entityName}> queryWrapper =new QueryWrapper<${entityName}>();
//分页数据
try {
IPage<${entityName}> pageInfo=${objectName}ServiceImpl.page(page, queryWrapper);
result.setType("success");
result.setMessage("成功");
result.setData(pageInfo);
} catch (Exception e) {
logger.error("分页查询${entityComment}执行异常:"+e.getMessage());
result=new JsonResult<IPage<${entityName}>>(e);
}
return result;
}
}
\ No newline at end of file
/**
* @filename:${entityName}Dao ${createTime}
* @project ${project} ${version}
* Copyright(c) 2018 ${author} Co. Ltd.
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${daoUrl};
......@@ -11,16 +11,12 @@ import org.apache.ibatis.annotations.Mapper;
import ${entityUrl}.${entityName};
/**
* Copyright: Copyright (c) 2019
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}数据访问层</P>
* <p>说明: ${entityComment}数据访问层</p>
* @version: ${version}
* @author: ${author}
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* ${createTime} ${author} ${version} initialize
*/
@Mapper
public interface ${entityName}Dao extends BaseMapper<${entityName}> {
......
/**
* @filename:${entityName} ${createTime}
* @project ${project} ${version}
* Copyright(c) 2018 ${author} Co. Ltd.
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${entityUrl};
......@@ -19,16 +19,12 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* Copyright: Copyright (c) 2019
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}实体类</P>
* @version: ${version}
* @author: ${author}
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* ${createTime} ${author} ${version} initialize
*/
@Data
@EqualsAndHashCode(callSuper = false)
......
/**
* @filename:${entityName}Service ${createTime}
* @project ${project} ${version}
* Copyright(c) 2018 ${author} Co. Ltd.
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${serviceUrl};
......@@ -9,16 +9,12 @@ package ${serviceUrl};
import ${entityUrl}.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
/**
* Copyright: Copyright (c) 2019
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}服务层</P>
* @version: ${version}
* @author: ${author}
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* ${createTime} ${author} ${version} initialize
*/
public interface ${entityName}Service extends IService<${entityName}> {
......
......@@ -13,16 +13,12 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* Copyright: Copyright (c) 2019
* <p>自动生成工具:mybatis-dsc-generator</p>
*
* <p>说明: ${entityComment}服务实现层</P>
* @version: ${version}
* @author: ${author}
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* ${createTime} ${author} ${version} initialize
*/
@Service
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Dao, ${entityName}> implements ${entityName}Service {
......
/**
* @filename:UserController 2019年4月9日
* @project wallet-manage V1.0
* Copyright(c) 2018 BianPeng Co. Ltd.
* All right reserved.
*/
package com.flying.cattle.mdg;
import java.sql.SQLException;
import java.util.Date;
import com.github.flying.cattle.mdg.entity.BasisInfo;
import com.github.flying.cattle.mdg.util.EntityInfoUtil;
import com.github.flying.cattle.mdg.util.Generator;
import com.github.flying.cattle.mdg.util.MySqlToJavaUtil;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 自动生成工具</P>
* <p>源码地址:https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
*/
public class MyGenerator {
// 基础信息
public static final String PROJECT = "springboot-mybatis";
public static final String AUTHOR = "BianPeng";
public static final String VERSION = "V1.0";
// 数据库连接信息
public static final String URL = "jdbc:mysql://192.168.9.246:3306/buybit_wallet?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC";
public static final String NAME = "buybit_wallet";
public static final String PASS = "buybit_wallet3M!";
public static final String DATABASE = "buybit_wallet";
// 类信息
public static final String TABLE = "user";
public static final String CLASSNAME = "User";
public static final String CLASSCOMMENT = "用户";
public static final String TIME = "2019年5月20日";
public static final String AGILE = new Date().getTime() + "";
// 路径信息,分开路径方便聚合工程项目,微服务项目
public static final String ENTITY_URL = "com.flying.cattle.entity";
public static final String DAO_URL = "com.flying.cattle.dao";
public static final String XML_URL = "com.flying.cattle.dao.impl";
public static final String SERVICE_URL = "com.flying.cattle.service";
public static final String SERVICE_IMPL_URL = "com.flying.cattle.service.impl";
public static final String CONTROLLER_URL = "com.flying.cattle.web";
public static void main(String[] args) {
BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL,
DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL);
bi.setTable(TABLE);
bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE));
bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE));
bi.setEntityComment(CLASSCOMMENT);
try {
bi = EntityInfoUtil.getInfo(bi);
String fileUrl = "E:\\b_mdg\\infrastructure\\springboot-mybatis\\springboot-mybatis-web\\src\\main\\java\\";// 生成文件存放位置
String aa1 = Generator.createEntity(fileUrl, bi).toString();
String aa2 = Generator.createDao(fileUrl, bi).toString();
String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
String aa4 = Generator.createService(fileUrl, bi).toString();
String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
String aa6 = Generator.createController(fileUrl, bi).toString();
// 是否创建swagger配置文件
String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();
System.out.println(aa1);
System.out.println(aa2); System.out.println(aa3); System.out.println(aa4);
System.out.println(aa5); System.out.println(aa6); System.out.println(aa7);
//System.out.println(aa7);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* Copyright © 2019 dream horse Info. Tech Ltd. All rights reserved.
* @Package: com.github.mybatis.fl.convert
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package com.github.mybatis.fl.test;
import java.sql.SQLException;
import java.util.Date;
import com.github.mybatis.fl.entity.BasisInfo;
import com.github.mybatis.fl.util.EntityInfoUtil;
import com.github.mybatis.fl.util.Generator;
import com.github.mybatis.fl.util.MySqlToJavaUtil;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 自动生成工具</P>
* <p>源码地址:https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
*/
public class TestMain {
//基础信息
public static final String PROJECT="user_center";
public static final String AUTHOR="BianPeng";
public static final String VERSION="V1.0";
//数据库连接信息
public static final String URL="jdbc:mysql://127.0.0.1:3306/earn_knife?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC";
public static final String NAME="root";
public static final String PASS="pwd2020";
public static final String DATABASE="earn_knife";
//类信息
public static final String TABLE="user";
public static final String CLASSNAME="User";
public static final String CLASSCOMMENT="用户";
public static final String TIME="2019年4月9日";
public static final String AGILE=new Date().getTime()+"";
//路径信息,分开路径方便聚合工程项目,微服务项目
public static final String ENTITY_URL="com.xin.usercenter.entity";
public static final String DAO_URL="com.xin.usercenter.dao";
public static final String XML_URL="com.xin.usercenter.dao.impl";
public static final String SERVICE_URL="com.xin.usercenter.service";
public static final String SERVICE_IMPL_URL="com.xin.usercenter.service.impl";
public static final String CONTROLLER_URL="com.xin.usercenter.webApi";
public static void main(String[] args) {
BasisInfo bi=new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL, DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL);
bi.setTable(TABLE);
bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE));
bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE));
bi.setEntityComment(CLASSCOMMENT);
try {
bi=EntityInfoUtil.getInfo(bi);
String fileUrl="E:\\b_test_work\\";//生成文件存放位置
String aa1=Generator.createEntity(fileUrl, bi).toString();
String aa2=Generator.createDao(fileUrl, bi).toString();
String aa3=Generator.createDaoImpl(fileUrl, bi).toString();
String aa4=Generator.createService(fileUrl, bi).toString();
String aa5=Generator.createServiceImpl(fileUrl, bi).toString();
String aa6=Generator.createController(fileUrl, bi).toString();
//是否创建swagger配置文件
String aa7=Generator.createSwaggerConfig(fileUrl, bi).toString();
System.out.println(aa1);
System.out.println(aa2);
System.out.println(aa3);
System.out.println(aa4);
System.out.println(aa5);
System.out.println(aa6);
System.out.println(aa7);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
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