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