diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java index 6d57ffa8..4720bab1 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java @@ -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,12 +114,11 @@ public class CodeGenKits { /** * 生成代码 - * * @return */ @SneakyThrows public Map generatorCode(GenConfig genConfig, Map table, - List> columns, ZipOutputStream zip, GenFormConf formConf) { + List> columns, ZipOutputStream zip, GenFormConf formConf) { // 配置信息 Configuration config = getConfig(); boolean hasBigDecimal = false; @@ -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,17 +245,16 @@ public class CodeGenKits { /** * 渲染数据 - * - * @param genConfig 配置信息 - * @param zip 流 (为空,直接返回Map) - * @param formConf 表单信息 + * @param genConfig 配置信息 + * @param zip 流 (为空,直接返回Map) + * @param formConf 表单信息 * @param tableEntity 表基本信息 - * @param map 模板参数 + * @param map 模板参数 * @return map key-filename value-contents * @throws IOException */ private Map renderData(GenConfig genConfig, ZipOutputStream zip, GenFormConf formConf, - TableEntity tableEntity, Map map) throws IOException { + TableEntity tableEntity, Map map) throws IOException { // 设置velocity资源加载器 Properties prop = new Properties(); prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); @@ -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); } }