From a6b2ac5dcd7e7fb5466c4c63f33ad7425134ce5f Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期五, 28 十月 2022 19:57:35 +0800
Subject: [PATCH] 升级oshi到最新版本6.3.0
---
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
index a674313..733c714 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
@@ -3,8 +3,10 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.velocity.VelocityContext;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
@@ -58,6 +60,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))
{
@@ -73,7 +76,7 @@
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId);
}
@@ -81,7 +84,7 @@
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String treeCode = getTreecode(paramsObj);
String treeParentCode = getTreeParentCode(paramsObj);
String treeName = getTreeName(paramsObj);
@@ -226,8 +229,7 @@
public static String getPackagePrefix(String packageName)
{
int lastIndex = packageName.lastIndexOf(".");
- String basePackage = StringUtils.substring(packageName, 0, lastIndex);
- return basePackage;
+ return StringUtils.substring(packageName, 0, lastIndex);
}
/**
@@ -261,6 +263,44 @@
}
/**
+ * 根据列类型获取字典组
+ *
+ * @param genTable 业务表对象
+ * @return 返回字典组
+ */
+ public static String getDicts(GenTable genTable)
+ {
+ List<GenTableColumn> columns = genTable.getColumns();
+ Set<String> dicts = new HashSet<String>();
+ addDicts(dicts, columns);
+ if (StringUtils.isNotNull(genTable.getSubTable()))
+ {
+ List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
+ addDicts(dicts, subColumns);
+ }
+ return StringUtils.join(dicts, ", ");
+ }
+
+ /**
+ * 添加字典列表
+ *
+ * @param dicts 字典列表
+ * @param columns 列集合
+ */
+ public static void addDicts(Set<String> dicts, List<GenTableColumn> columns)
+ {
+ for (GenTableColumn column : columns)
+ {
+ if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
+ column.getHtmlType(),
+ new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX }))
+ {
+ dicts.add("'" + column.getDictType() + "'");
+ }
+ }
+ }
+
+ /**
* 获取权限前缀
*
* @param moduleName 模块名称
@@ -280,7 +320,8 @@
*/
public static String getParentMenuId(JSONObject paramsObj)
{
- if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
+ if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
+ && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID)))
{
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
}
@@ -341,7 +382,7 @@
public static int getExpandColumn(GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
int num = 0;
for (GenTableColumn column : genTable.getColumns())
--
Gitblit v1.9.2