【update】注释代码与重命名变量
This commit is contained in:
+2
-2
@@ -90,7 +90,7 @@ public class CodeGenerateOne extends BaseCodeGenerate implements IGenerate {
|
|||||||
String templateUrl = com.jero.codegenerate.properties.CodeConfigProperties.templateUrl;
|
String templateUrl = com.jero.codegenerate.properties.CodeConfigProperties.templateUrl;
|
||||||
if (dealAndGetTemplateUrl(templateUrl, "/").equals("jero/code-template")) {
|
if (dealAndGetTemplateUrl(templateUrl, "/").equals("jero/code-template")) {
|
||||||
templateUrl = "/" + dealAndGetTemplateUrl(templateUrl, "/") + "/one";
|
templateUrl = "/" + dealAndGetTemplateUrl(templateUrl, "/") + "/one";
|
||||||
com.jero.codegenerate.properties.CodeConfigProperties.b(templateUrl);
|
com.jero.codegenerate.properties.CodeConfigProperties.setTemplateUrl(templateUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateFileConfig createFileConfig = new CreateFileConfig(templateUrl);
|
CreateFileConfig createFileConfig = new CreateFileConfig(templateUrl);
|
||||||
@@ -106,7 +106,7 @@ public class CodeGenerateOne extends BaseCodeGenerate implements IGenerate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (templatePath != null && !"".equals(templatePath)) {
|
if (templatePath != null && !"".equals(templatePath)) {
|
||||||
com.jero.codegenerate.properties.CodeConfigProperties.b(templatePath);
|
com.jero.codegenerate.properties.CodeConfigProperties.setTemplateUrl(templatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.generateCodeFile(stylePath);
|
this.generateCodeFile(stylePath);
|
||||||
|
|||||||
+14
-13
@@ -111,8 +111,9 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
|||||||
originalColumns = DbReadTableUtil.listOriginalColumns(subTableVo.getTableName());
|
originalColumns = DbReadTableUtil.listOriginalColumns(subTableVo.getTableName());
|
||||||
subTableVo.setOriginalColumns(originalColumns);
|
subTableVo.setOriginalColumns(originalColumns);
|
||||||
}
|
}
|
||||||
//从表外键
|
// 从表外键
|
||||||
String[] foreignKeys = subTableVo.getForeignKeys();
|
String[] foreignKeys = subTableVo.getForeignKeys();
|
||||||
|
// 存储外键的集合
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
String[] foreignKeys1 = foreignKeys;
|
String[] foreignKeys1 = foreignKeys;
|
||||||
int length = foreignKeys.length;
|
int length = foreignKeys.length;
|
||||||
@@ -121,11 +122,11 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
|||||||
String foreignKey = foreignKeys1[i];
|
String foreignKey = foreignKeys1[i];
|
||||||
list.add(DbReadTableUtil.convertForeignKeyToCamelCase(foreignKey));
|
list.add(DbReadTableUtil.convertForeignKeyToCamelCase(foreignKey));
|
||||||
}
|
}
|
||||||
|
// put外键数组
|
||||||
subTableVo.setForeignKeys((String[])list.toArray(new String[0]));
|
subTableVo.setForeignKeys((String[])list.toArray(new String[0]));
|
||||||
subTableVo.setOriginalForeignKeys(foreignKeys);
|
subTableVo.setOriginalForeignKeys(foreignKeys);
|
||||||
}
|
}
|
||||||
|
// put从表集合
|
||||||
hashMap.put("subTables", this.subTables);
|
hashMap.put("subTables", this.subTables);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -139,17 +140,17 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> generateCodeFile(String stylePath) throws Exception {
|
public List<String> generateCodeFile(String stylePath) throws Exception {
|
||||||
String var2 = com.jero.codegenerate.properties.CodeConfigProperties.projectPath;
|
String projectPath = com.jero.codegenerate.properties.CodeConfigProperties.projectPath;
|
||||||
Map var3 = this.getCodeGenerateConfig();
|
Map configMap = this.getCodeGenerateConfig();
|
||||||
String var4 = com.jero.codegenerate.properties.CodeConfigProperties.templateUrl;
|
String templateUrl = com.jero.codegenerate.properties.CodeConfigProperties.templateUrl;
|
||||||
if (dealAndGetTemplateUrl(var4, "/").equals("jero/code-template")) {
|
if (dealAndGetTemplateUrl(templateUrl, "/").equals("jero/code-template")) {
|
||||||
var4 = "/" + dealAndGetTemplateUrl(var4, "/") + "/onetomany";
|
templateUrl = "/" + dealAndGetTemplateUrl(templateUrl, "/") + "/onetomany";
|
||||||
com.jero.codegenerate.properties.CodeConfigProperties.b(var4);
|
com.jero.codegenerate.properties.CodeConfigProperties.setTemplateUrl(templateUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateFileConfig var5 = new CreateFileConfig(var4);
|
CreateFileConfig createFileConfig = new CreateFileConfig(templateUrl);
|
||||||
var5.setStylePath(stylePath);
|
createFileConfig.setStylePath(stylePath);
|
||||||
this.a(var5, var2, var3);
|
this.a(createFileConfig, projectPath, configMap);
|
||||||
log.info("----- jero-boot ---- generate code success =======> 主表名:" + this.mainTableVo.getTableName());
|
log.info("----- jero-boot ---- generate code success =======> 主表名:" + this.mainTableVo.getTableName());
|
||||||
return this.list;
|
return this.list;
|
||||||
}
|
}
|
||||||
@@ -161,7 +162,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (templatePath != null && !"".equals(templatePath)) {
|
if (templatePath != null && !"".equals(templatePath)) {
|
||||||
com.jero.codegenerate.properties.CodeConfigProperties.b(templatePath);
|
com.jero.codegenerate.properties.CodeConfigProperties.setTemplateUrl(templatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.generateCodeFile(stylePath);
|
this.generateCodeFile(stylePath);
|
||||||
|
|||||||
+7
-7
@@ -29,28 +29,28 @@ public class BaseCodeGenerate {
|
|||||||
public BaseCodeGenerate() {
|
public BaseCodeGenerate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void a(CreateFileConfig createFileConfig, String projectPath, Map<String, Object> var3) throws Exception {
|
protected void a(CreateFileConfig createFileConfig, String projectPath, Map<String, Object> configMap) throws Exception {
|
||||||
log.debug("--------generate----projectPath--------" + projectPath);
|
log.debug("--------generate----projectPath--------" + projectPath);
|
||||||
|
|
||||||
for(int i = 0; i < createFileConfig.listFile().size(); ++i) {
|
for(int i = 0; i < createFileConfig.listFile().size(); ++i) {
|
||||||
File file = (File)createFileConfig.listFile().get(i);
|
File file = (File)createFileConfig.listFile().get(i);
|
||||||
this.a(projectPath, file, var3, createFileConfig);
|
this.a(projectPath, file, configMap, createFileConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void a(String var1, File var2, Map<String, Object> var3, CreateFileConfig var4) throws Exception {
|
protected void a(String projectPath, File dir, Map<String, Object> configMap, CreateFileConfig createFileConfig) throws Exception {
|
||||||
if (var2 == null) {
|
if (dir == null) {
|
||||||
throw new IllegalStateException("'templateRootDir' must be not null");
|
throw new IllegalStateException("'templateRootDir' must be not null");
|
||||||
} else {
|
} else {
|
||||||
log.info(" load template from templateRootDir = '" + var2.getAbsolutePath() + "',stylePath ='" + var4.getStylePath() + "', out GenerateRootDir:" + com.jero.codegenerate.properties.CodeConfigProperties.projectPath);
|
log.info(" load template from templateRootDir = '" + dir.getAbsolutePath() + "',stylePath ='" + createFileConfig.getStylePath() + "', out GenerateRootDir:" + com.jero.codegenerate.properties.CodeConfigProperties.projectPath);
|
||||||
List var5 = FileHelper.a(var2);
|
List var5 = FileHelper.a(dir);
|
||||||
log.debug("----srcFiles----size-----------" + var5.size());
|
log.debug("----srcFiles----size-----------" + var5.size());
|
||||||
log.debug("----srcFiles----list------------" + var5.toString());
|
log.debug("----srcFiles----list------------" + var5.toString());
|
||||||
|
|
||||||
for(int var6 = 0; var6 < var5.size(); ++var6) {
|
for(int var6 = 0; var6 < var5.size(); ++var6) {
|
||||||
File var7 = (File)var5.get(var6);
|
File var7 = (File)var5.get(var6);
|
||||||
this.a(var1, var2, var3, var7, var4);
|
this.a(projectPath, dir, configMap, var7, createFileConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+44
-33
@@ -12,46 +12,47 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class FileHelper {
|
public class FileHelper {
|
||||||
public static List<String> a = new ArrayList();
|
public static List<String> dirNameList = new ArrayList();
|
||||||
public static List<String> b = new ArrayList();
|
public static List<String> fileSuffixList = new ArrayList();
|
||||||
|
|
||||||
public FileHelper() {
|
public FileHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
a.add(".svn");
|
dirNameList.add(".svn");
|
||||||
a.add("CVS");
|
dirNameList.add("CVS");
|
||||||
a.add(".cvsignore");
|
dirNameList.add(".cvsignore");
|
||||||
a.add(".copyarea.db");
|
dirNameList.add(".copyarea.db");
|
||||||
a.add("SCCS");
|
dirNameList.add("SCCS");
|
||||||
a.add("vssver.scc");
|
dirNameList.add("vssver.scc");
|
||||||
a.add(".DS_Store");
|
dirNameList.add(".DS_Store");
|
||||||
a.add(".git");
|
dirNameList.add(".git");
|
||||||
a.add(".gitignore");
|
dirNameList.add(".gitignore");
|
||||||
b.add(".ftl");
|
fileSuffixList.add(".ftl");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> a(File var0) throws IOException {
|
public static List<File> a(File dir) throws IOException {
|
||||||
ArrayList var1 = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
a(var0, (List)var1);
|
dfsAndAddFile(dir, (List)list);
|
||||||
Collections.sort(var1, new Comparator<File>() {
|
Collections.sort(list, new Comparator<File>() {
|
||||||
|
@Override
|
||||||
public int compare(File var1, File var2) {
|
public int compare(File var1, File var2) {
|
||||||
return var1.getAbsolutePath().compareTo(var2.getAbsolutePath());
|
return var1.getAbsolutePath().compareTo(var2.getAbsolutePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return var1;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void a(File var0, List<File> var1) throws IOException {
|
public static void dfsAndAddFile(File dir, List<File> list) throws IOException {
|
||||||
log.debug("---------dir------------path: " + var0.getPath() + " -- isHidden --: " + var0.isHidden() + " -- isDirectory --: " + var0.isDirectory());
|
log.debug("---------dir------------path: " + dir.getPath() + " -- isHidden --: " + dir.isHidden() + " -- isDirectory --: " + dir.isDirectory());
|
||||||
if (!var0.isHidden() && var0.isDirectory() && !d(var0)) {
|
if (!dir.isHidden() && dir.isDirectory() && !isContainDir(dir)) {
|
||||||
File[] var2 = var0.listFiles();
|
File[] files = dir.listFiles();
|
||||||
|
|
||||||
for(int var3 = 0; var3 < var2.length; ++var3) {
|
for(int i = 0; i < files.length; ++i) {
|
||||||
a(var2[var3], var1);
|
dfsAndAddFile(files[i], list);
|
||||||
}
|
}
|
||||||
} else if (!e(var0) && !d(var0)) {
|
} else if (!isSuffixContain(dir) && !isContainDir(dir)) {
|
||||||
var1.add(var0);
|
list.add(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -97,20 +98,30 @@ public class FileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
private static boolean d(File var0) {
|
* 是否目录集合包含指定目录
|
||||||
for(int var1 = 0; var1 < a.size(); ++var1) {
|
* @date 2021/4/2 11:22
|
||||||
if (var0.getName().equals(a.get(var1))) {
|
* @param dir
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static boolean isContainDir(File dir) {
|
||||||
|
for(int i = 0; i < dirNameList.size(); ++i) {
|
||||||
|
if (dir.getName().equals(dirNameList.get(i))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
private static boolean e(File var0) {
|
* 是否后缀名集合包含指定文件后缀名
|
||||||
for(int var1 = 0; var1 < b.size(); ++var1) {
|
* @date 2021/4/2 11:21
|
||||||
if (var0.getName().endsWith((String)b.get(var1))) {
|
* @param file
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static boolean isSuffixContain(File file) {
|
||||||
|
for(int i = 0; i < fileSuffixList.size(); ++i) {
|
||||||
|
if (file.getName().endsWith((String) fileSuffixList.get(i))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-3
@@ -8,7 +8,12 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.PropertyResourceBundle;
|
import java.util.PropertyResourceBundle;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
/**
|
||||||
|
* 配置文件
|
||||||
|
* @date 2021/4/2 11:01
|
||||||
|
* @param null
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CodeConfigProperties {
|
public class CodeConfigProperties {
|
||||||
|
|
||||||
@@ -130,8 +135,8 @@ public class CodeConfigProperties {
|
|||||||
projectPath = var0;
|
projectPath = var0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void b(String var0) {
|
public static void setTemplateUrl(String templateUrl) {
|
||||||
templateUrl = var0;
|
CodeConfigProperties.templateUrl = templateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
Reference in New Issue
Block a user