🎨 Improving structure / format of the code.

This commit is contained in:
lbw 2021-07-31 16:05:28 +08:00
parent 1aa9e1d4b0
commit 850ef630e2

View File

@ -86,7 +86,6 @@ public class CodeGenKits {
/**
* 配置
*
* @param config
* @return
*/
@ -104,7 +103,8 @@ public class CodeGenKits {
if (StyleTypeEnum.AVUE.getStyle().equals(config.getStyle())) {
templates.add("template/avue/index.vue.vm");
templates.add("template/avue/crud.js.vm");
} else {
}
else {
templates.add("template/element/index.vue.vm");
templates.add("template/element/form.vue.vm");
}
@ -114,7 +114,6 @@ public class CodeGenKits {
/**
* 生成代码
*
* @return
*/
@SneakyThrows
@ -129,14 +128,16 @@ public class CodeGenKits {
if (StrUtil.isNotBlank(genConfig.getComments())) {
tableEntity.setComments(genConfig.getComments());
} else {
}
else {
tableEntity.setComments(table.get("tableComment"));
}
String tablePrefix;
if (StrUtil.isNotBlank(genConfig.getTablePrefix())) {
tablePrefix = genConfig.getTablePrefix();
} else {
}
else {
tablePrefix = config.getString("tablePrefix");
}
@ -158,7 +159,8 @@ public class CodeGenKits {
// 隐藏不需要的在接口文档中展示的字段
if (hiddenColumns.contains(column.get("columnName"))) {
columnEntity.setHidden(Boolean.TRUE);
} else {
}
else {
columnEntity.setHidden(Boolean.FALSE);
}
// 列名转换成Java属性名
@ -170,7 +172,8 @@ public class CodeGenKits {
if (StrUtil.isNotBlank(column.get("comments"))) {
// 注意去除换行符号
columnEntity.setComments(StrUtil.removeAllLineBreaks(column.get("comments")));
} else {
}
else {
columnEntity.setComments(columnEntity.getLowerAttrName());
}
@ -208,26 +211,30 @@ public class CodeGenKits {
if (StrUtil.isNotBlank(genConfig.getComments())) {
map.put("comments", genConfig.getComments());
} else {
}
else {
map.put("comments", tableEntity.getComments());
}
if (StrUtil.isNotBlank(genConfig.getAuthor())) {
map.put("author", genConfig.getAuthor());
} else {
}
else {
map.put("author", config.getString("author"));
}
if (StrUtil.isNotBlank(genConfig.getModuleName())) {
map.put("moduleName", genConfig.getModuleName());
} else {
}
else {
map.put("moduleName", config.getString("moduleName"));
}
if (StrUtil.isNotBlank(genConfig.getPackageName())) {
map.put("package", genConfig.getPackageName());
map.put("mainPath", genConfig.getPackageName());
} else {
}
else {
map.put("package", config.getString("package"));
map.put("mainPath", config.getString("mainPath"));
}
@ -238,7 +245,6 @@ public class CodeGenKits {
/**
* 渲染数据
*
* @param genConfig 配置信息
* @param zip 为空直接返回Map
* @param formConf 表单信息
@ -302,7 +308,7 @@ public class CodeGenKits {
* 列名转换成Java属性名
*/
public String columnToJava(String columnName) {
return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", "");
return WordUtils.capitalizeFully(columnName, new char[] { '_' }).replace("_", "");
}
/**
@ -321,7 +327,8 @@ public class CodeGenKits {
public Configuration getConfig() {
try {
return new PropertiesConfiguration("generator.properties");
} catch (ConfigurationException e) {
}
catch (ConfigurationException e) {
throw new CheckedException("获取配置文件失败,", e);
}
}