From 3a2a1b216473758944d1a1e71b14401506303afe Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期五, 17 九月 2021 15:37:41 +0800 Subject: [PATCH] 使用vue-data-dict简化数据字典使用 --- src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java index 0d05572..0b39b75 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java +++ b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java @@ -58,6 +58,7 @@ velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); velocityContext.put("columns", genTable.getColumns()); velocityContext.put("table", genTable); + velocityContext.put("dicts", getDicts(genTable)); setMenuVelocityContext(velocityContext, genTable); if (GenConstants.TPL_TREE.equals(tplCategory)) { @@ -260,6 +261,27 @@ } /** + * 鏍规嵁鍒楃被鍨嬭幏鍙栧瓧鍏哥粍 + * + * @param genTable 涓氬姟琛ㄥ璞� + * @return 杩斿洖瀛楀吀缁� + */ + public static String getDicts(GenTable genTable) + { + List<GenTableColumn> columns = genTable.getColumns(); + List<String> dicts = new ArrayList<String>(); + for (GenTableColumn column : columns) + { + if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( + column.getHtmlType(), new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO })) + { + dicts.add("'" + column.getDictType() + "'"); + } + } + return StringUtils.join(dicts, ", "); + } + + /** * 鑾峰彇鏉冮檺鍓嶇紑 * * @param moduleName 妯″潡鍚嶇О -- Gitblit v1.9.3