【update】注释代码与重命名变量
This commit is contained in:
+9
-1
@@ -5,7 +5,15 @@ import com.jero.codegenerate.properties.CodeConfigProperties;
|
||||
public class CodegenDatasourceConfig {
|
||||
public CodegenDatasourceConfig() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载配置
|
||||
* @date 2021/4/2 10:29
|
||||
* @param DIVERNAME
|
||||
* @param URL
|
||||
* @param USERNAME
|
||||
* @param PASSWORD
|
||||
* @return void
|
||||
*/
|
||||
public static void initDbConfig(String DIVERNAME, String URL, String USERNAME, String PASSWORD) {
|
||||
CodeConfigProperties.driverName = DIVERNAME;
|
||||
CodeConfigProperties.databaseUrl = URL;
|
||||
|
||||
+6
-1
@@ -432,7 +432,12 @@ public class DbReadTableUtil {
|
||||
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将外键字符串下划线间隔命名转换为驼峰命名
|
||||
* @date 2021/4/2 10:52
|
||||
* @param foreignKey
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String convertForeignKeyToCamelCase(String foreignKey) {
|
||||
String[] foreignKeyWords = foreignKey.split("_");
|
||||
foreignKey = "";
|
||||
|
||||
+6
-1
@@ -22,7 +22,12 @@ public class CreateFileConfig {
|
||||
private void setFileList(File file) {
|
||||
this.convertArrToList(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件数组转换为文件集合
|
||||
* @date 2021/4/2 10:30
|
||||
* @param files
|
||||
* @return void
|
||||
*/
|
||||
private void convertArrToList(File... files) {
|
||||
this.fileList = Arrays.asList(files);
|
||||
}
|
||||
|
||||
+22
-6
@@ -20,13 +20,15 @@ import com.jero.codegenerate.generate.util.NonceUtils;
|
||||
@Slf4j
|
||||
public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate {
|
||||
private static String f;
|
||||
public static String a = "A";
|
||||
public static String b = "B";
|
||||
public static String A = "A";
|
||||
public static String B = "B";
|
||||
// 主表vo
|
||||
private MainTableVo mainTableVo;
|
||||
private List<ColumnVo> mainColumns;
|
||||
private List<ColumnVo> originalMainColumns;
|
||||
// 从表集合
|
||||
private List<SubTableVo> subTables;
|
||||
private static DbReadTableUtil k = new DbReadTableUtil();
|
||||
private static DbReadTableUtil dbReadTableUtil = new DbReadTableUtil();
|
||||
|
||||
public CodeGenerateOneToMany(MainTableVo mainTableVo, List<SubTableVo> subTables) {
|
||||
this.subTables = subTables;
|
||||
@@ -39,15 +41,25 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
this.originalMainColumns = originalMainColumns;
|
||||
this.subTables = subTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代码生成器的配置 map
|
||||
* @date 2021/4/2 10:39
|
||||
* @param
|
||||
* @return java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getCodeGenerateConfig() throws Exception {
|
||||
HashMap hashMap = new HashMap();
|
||||
// 包名
|
||||
hashMap.put("bussiPackage", com.jero.codegenerate.properties.CodeConfigProperties.packageName);
|
||||
// 实体包名
|
||||
hashMap.put("entityPackage", this.mainTableVo.getEntityPackage());
|
||||
// 实体名
|
||||
hashMap.put("entityName", this.mainTableVo.getEntityName());
|
||||
// 表名
|
||||
hashMap.put("tableName", this.mainTableVo.getTableName());
|
||||
hashMap.put("ftl_description", this.mainTableVo.getFtlDescription());
|
||||
// 主键名
|
||||
hashMap.put("primaryKeyField", com.jero.codegenerate.properties.CodeConfigProperties.dbTableId);
|
||||
if (this.mainTableVo.getFieldRequiredNum() == null) {
|
||||
this.mainTableVo.setFieldRequiredNum(StringUtils.isNotEmpty(com.jero.codegenerate.properties.CodeConfigProperties.fieldRequiredNum) ? Integer.parseInt(com.jero.codegenerate.properties.CodeConfigProperties.fieldRequiredNum) : -1);
|
||||
@@ -60,7 +72,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
if (this.mainTableVo.getFieldRowNum() == null) {
|
||||
this.mainTableVo.setFieldRowNum(Integer.parseInt(com.jero.codegenerate.properties.CodeConfigProperties.fieldRowNum));
|
||||
}
|
||||
|
||||
// put主表
|
||||
hashMap.put("tableVo", this.mainTableVo);
|
||||
|
||||
try {
|
||||
@@ -78,6 +90,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
ColumnVo columnVo = (ColumnVo)iterator.next();
|
||||
// 主键类型
|
||||
if (columnVo.getFieldName().toLowerCase().equals(com.jero.codegenerate.properties.CodeConfigProperties.dbTableId.toLowerCase())) {
|
||||
hashMap.put("primaryKeyPolicy", columnVo.getFieldType());
|
||||
}
|
||||
@@ -86,6 +99,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
iterator = this.subTables.iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
// 从表(局部变量)
|
||||
SubTableVo subTableVo = (SubTableVo)iterator.next();
|
||||
List originalColumns;
|
||||
if (subTableVo.getColums() == null || subTableVo.getColums().size() == 0) {
|
||||
@@ -97,7 +111,7 @@ 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;
|
||||
@@ -123,6 +137,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateCodeFile(String stylePath) throws Exception {
|
||||
String var2 = com.jero.codegenerate.properties.CodeConfigProperties.projectPath;
|
||||
Map var3 = this.getCodeGenerateConfig();
|
||||
@@ -139,6 +154,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
return this.list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateCodeFile(String projectPath, String templatePath, String stylePath) throws Exception {
|
||||
if (projectPath != null && !"".equals(projectPath)) {
|
||||
com.jero.codegenerate.properties.CodeConfigProperties.a(projectPath);
|
||||
|
||||
+1
@@ -116,6 +116,7 @@ public class MainTableVo {
|
||||
this.sequenceCode = sequenceCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"entityPackage\":\"" + this.entityPackage + "\",\"tableName\":\"" + this.tableName + "\",\"entityName\":\"" + this.entityName + "\",\"ftlDescription\":\"" + this.ftlDescription + "\",\"primaryKeyPolicy\":\"" + this.primaryKeyPolicy + "\",\"sequenceCode\":\"" + this.sequenceCode + "\",\"ftl_mode\":\"" + this.ftl_mode + "\",\"subTables\":" + this.subTables + ",\"fieldRowNum\":\"" + this.fieldRowNum + "\",\"searchFieldNum\":\"" + this.searchFieldNum + "\",\"fieldRequiredNum\":\"" + this.fieldRequiredNum + "\"}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user