Commit 1bc03dab by yubaogu

tett

parent 704aa573
...@@ -48,7 +48,7 @@ public class BasisInfo implements Serializable{ ...@@ -48,7 +48,7 @@ public class BasisInfo implements Serializable{
private String database; private String database;
private String table; private String table;
private String entityName; private String entityName;
private String objectName; private String objectName;
...@@ -68,6 +68,10 @@ public class BasisInfo implements Serializable{ ...@@ -68,6 +68,10 @@ public class BasisInfo implements Serializable{
private String serviceUrl; private String serviceUrl;
private String serviceImplUrl; private String serviceImplUrl;
private String facadeUrl;
private String facadeImplUrl;
private String abstractControllerUrl; private String abstractControllerUrl;
...@@ -87,7 +91,7 @@ public class BasisInfo implements Serializable{ ...@@ -87,7 +91,7 @@ public class BasisInfo implements Serializable{
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 isSwagger) { String serviceUrl, String serviceImplUrl,String facadeUrl, String facadeImplUrl, String controllerUrl,String isSwagger) {
super(); super();
this.project = project; this.project = project;
this.author = author; this.author = author;
...@@ -103,6 +107,8 @@ public class BasisInfo implements Serializable{ ...@@ -103,6 +107,8 @@ public class BasisInfo implements Serializable{
this.mapperUrl = mapperUrl; this.mapperUrl = mapperUrl;
this.serviceUrl = serviceUrl; this.serviceUrl = serviceUrl;
this.serviceImplUrl = serviceImplUrl; this.serviceImplUrl = serviceImplUrl;
this.facadeUrl = facadeUrl;
this.facadeImplUrl = facadeImplUrl;
this.controllerUrl = controllerUrl; this.controllerUrl = controllerUrl;
this.abstractControllerUrl = controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".aid"; this.abstractControllerUrl = controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".aid";
this.swaggerConfigUrl=controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".config"; this.swaggerConfigUrl=controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".config";
......
/**
* @filename:${entityName}Service ${createTime}
* @project ${project} ${version}
* Copyright(c) 2020 ${author} Co. Ltd.
* All right reserved.
*/
package ${facadeUrl};
import ${entityUrl}.${entityName};
import java.util.LinkedHashMap;
import java.util.List;
import com.ydl.common.dto.BaseDtoResponse;
/**
* @Description:TODO(${entityComment}服务层)
* @version: ${version}
* @author: ${author}
*
*/
public interface ${entityName}Facade {
}
\ No newline at end of file
/**
* @filename:${entityName}ServiceImpl ${createTime}
* @project ${project} ${version}
* Copyright(c) 2018 ${author} Co. Ltd.
* All right reserved.
*/
package ${serviceImplUrl};
import ${entityUrl}.${entityName};
import ${facadeUrl}.${entityName}Facade;
import org.springframework.stereotype.Service;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
/**
* @Description:TODO(${entityComment}服务实现)
*
* @version: ${version}
* @author: ${author}
*
*/
@Service(version = "1.0.0", interfaceClass = ${entityName}Facade.class)
public class ${entityName}FacadeImpl implements ${entityName}Facade {
}
\ No newline at end of file
...@@ -10,6 +10,7 @@ import java.io.IOException; ...@@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.druid.support.json.JSONUtils;
...@@ -38,15 +39,18 @@ public class MyGenerator implements Serializable { ...@@ -38,15 +39,18 @@ public class MyGenerator implements Serializable {
public static final String DATABASE = "ydl"; public static final String DATABASE = "ydl";
// 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间 // 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间
public static final String TABLE = "doctor"; public static final String TABLE = "doctor";
public static final String[] TABLES = {"doctor"};
public static final String CLASSCOMMENT = "专家"; public static final String CLASSCOMMENT = "专家";
public static final String TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); public static final String TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
public static final String AGILE = new Date().getTime() + ""; public static final String AGILE = new Date().getTime() + "";
// 路径信息,分开路径方便聚合工程项目,微服务项目 // 路径信息,分开路径方便聚合工程项目,微服务项目
public static final String ENTITY_URL = "com.ydl.demo.entity"; public static final String ENTITY_URL = "com.ydl.demo.po";
public static final String DAO_URL = "com.ydl.demo.mapper"; public static final String DAO_URL = "com.ydl.demo.mapper";
public static final String XML_URL = "com.ydl.demo.mapper.xml"; public static final String XML_URL = "com.ydl.demo.mapper.xml";
public static final String SERVICE_URL = "com.ydl.demo.service"; public static final String SERVICE_URL = "com.ydl.demo.service";
public static final String SERVICE_IMPL_URL = "com.ydl.demo.service.impl"; public static final String SERVICE_IMPL_URL = "com.ydl.demo.service.impl";
public static final String FACADE_URL = "com.ydl.demo.facade";
public static final String FACADE_URL_IMPL = "com.ydl.demo.facade";
public static final String CONTROLLER_URL = "com.ydl.demo.api"; public static final String CONTROLLER_URL = "com.ydl.demo.api";
//是否是Swagger配置 //是否是Swagger配置
public static final String IS_SWAGGER = "true"; public static final String IS_SWAGGER = "true";
...@@ -54,35 +58,37 @@ public class MyGenerator implements Serializable { ...@@ -54,35 +58,37 @@ public class MyGenerator implements Serializable {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
System.out.println(MyGenerator.class.getResource("").getPath()); System.out.println(MyGenerator.class.getResource("").getPath());
BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL, 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,IS_SWAGGER); DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL,FACADE_URL, FACADE_URL_IMPL, CONTROLLER_URL,IS_SWAGGER);
bi.setTable(TABLE); for(String table : TABLES) {
bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE)); bi.setTable(table);
bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE)); bi.setEntityName(MySqlToJavaUtil.getClassName(table));
bi.setEntityComment(CLASSCOMMENT); bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(table));
try { bi.setEntityComment(CLASSCOMMENT);
bi = EntityInfoUtil.getInfo(bi); try {
String fileUrl = "D:\\ydlwork\\ydl-demo\\ydl-demo-api\\src\\main\\java\\";// 生成文件存放位置 bi = EntityInfoUtil.getInfo(bi);
//开始生成文件 String fileUrl = "D:\\ydlwork\\ydl-demo\\ydl-demo-api\\src\\main\\java\\";// 生成文件存放位置
//开始生成文件
// String aa1 = Generator.createEntity(fileUrl, bi).toString(); // String aa1 = Generator.createEntity(fileUrl, bi).toString();
// String aa2 = Generator.createDao(fileUrl, bi).toString(); // String aa2 = Generator.createDao(fileUrl, bi).toString();
// String aa3 = Generator.createDaoImpl(fileUrl, bi).toString(); // String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
String aa4 = Generator.createService(fileUrl, bi).toString(); String aa4 = Generator.createService(fileUrl, bi).toString();
String aa5 = Generator.createServiceImpl(fileUrl, bi).toString(); String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
String aa6 = Generator.createController(fileUrl, bi).toString(); String aa6 = Generator.createController(fileUrl, bi).toString();
// 是否创建swagger配置文件 // 是否创建swagger配置文件
// String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString(); // String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();
// System.out.println(aa1); // System.out.println(aa1);
// System.out.println(aa2); // System.out.println(aa2);
// System.out.println(aa3); // System.out.println(aa3);
System.out.println(aa4); System.out.println(aa4);
System.out.println(aa5); System.out.println(aa5);
System.out.println(aa6); System.out.println(aa6);
// System.out.println(aa7); // System.out.println(aa7);
//System.out.println(aa7); //System.out.println(aa7);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); 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