master
周文涛 2 years ago
parent 537759af7e
commit 9965bf2e56

@ -69,4 +69,22 @@
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -59,33 +59,38 @@ public class Main {
private static String dbType = "postgresql";
public static void main(String[] args) throws Exception {
//1.数据库配置
String driver = "org.postgresql.Driver";
String url = "jdbc:postgresql://10.201.145.19:35432/enjoy-oqc?stringtype=unspecified&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false";
String user = "enjoy";
String password = "Nomi1234";
List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, "oqc_project");
generate(bussi_package, "oqc_spot_check_record", "OqcSpotCheckRecord","抽检记录表", tableEntityVoList);
//2.选择表配置
String table= "oqc_spot_check_record";
String entityName="OqcSpotCheckRecord";//实体类
String description = "抽检记录表";//备注
String primaryKeyField = "id";//主键
List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, table);
//3.生成
generate(bussi_package, table,primaryKeyField,entityName,description, tableEntityVoList);
}
/**
*
* @param bussiPackage
* @param tableName
* @param entityName
* @param originalColumns
*/
private static void generate(String bussiPackage, String tableName, String entityName,String description, List<TableEntityVo> originalColumns) {
private static void generate(String bussiPackage,String tableName,String primaryKeyField,String entityName,String description, List<TableEntityVo> originalColumns) {
TableVo tableVo = new TableVo();
tableVo.setFtlDescription(description);
//包名
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("bussiPackage", bussiPackage);//包
dataMap.put("entityPackage", "domain");
dataMap.put("entityPackage", "domain");//实体类包名 domain/entity
dataMap.put("tableName", tableName);//表名称
dataMap.put("tableVo", tableVo);//表属性
//主键
dataMap.put("primaryKeyField", "id");
dataMap.put("primaryKeyField",primaryKeyField);
dataMap.put("entityName", entityName);//实体类名称
dataMap.put("author", author);//作者

@ -22,7 +22,7 @@ public class MarkerGenerate {
public static void generate(String basePackagePath,String templateName,String parsePath,String fileName,Map<String,Object> dataMap) {
String entityName = (String) dataMap.get("entityName");
if (StringUtils.isNotBlank(entityName)) {
dataMap.put("uncap_first",StringUtils.uncapitalize(entityName));
dataMap.put("uncap_first",StringUtils.uncapitalize(entityName));//实体类首字母缩写参数
}
// 创建生成文件所在目录
@ -62,30 +62,14 @@ public class MarkerGenerate {
if (StringUtils.isNotBlank(folder)) {
File file =new File(folder);
if (file.exists()) {
if (file.isDirectory()) {
System.out.println("dir exists");
}
if (file.isDirectory()) {/*System.out.println("dir exists");*/}
else {
System.out.println("the same name file exists, can not create dir");
}
} else {
System.out.println("dir not exists, create it ...");
//System.out.println("目录不存在,创建");
file.mkdirs();
}
/*String[] folderSpilt = folder.split(File.separator);
StringBuffer sb=new StringBuffer();
for (String f : folderSpilt) {
sb=sb.append(f);
File file=new File(sb.toString());
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
}
}
}

Loading…
Cancel
Save