|
|
@ -23,6 +23,9 @@ public class VelocityUtils |
|
|
|
|
|
|
|
|
|
|
|
/** mybatis空间路径 */ |
|
|
|
/** mybatis空间路径 */ |
|
|
|
private static final String MYBATIS_PATH = "main/resources/mapper"; |
|
|
|
private static final String MYBATIS_PATH = "main/resources/mapper"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 默认上级菜单,系统工具 */ |
|
|
|
|
|
|
|
private static final String DEFAULT_PARENT_MENU_ID = "3"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置模板变量信息 |
|
|
|
* 设置模板变量信息 |
|
|
@ -55,12 +58,21 @@ public class VelocityUtils |
|
|
|
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); |
|
|
|
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); |
|
|
|
velocityContext.put("columns", genTable.getColumns()); |
|
|
|
velocityContext.put("columns", genTable.getColumns()); |
|
|
|
velocityContext.put("table", genTable); |
|
|
|
velocityContext.put("table", genTable); |
|
|
|
|
|
|
|
setMenuVelocityContext(velocityContext, genTable); |
|
|
|
if (GenConstants.TPL_TREE.equals(tplCategory)) |
|
|
|
if (GenConstants.TPL_TREE.equals(tplCategory)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setTreeVelocityContext(velocityContext, genTable); |
|
|
|
setTreeVelocityContext(velocityContext, genTable); |
|
|
|
} |
|
|
|
} |
|
|
|
return velocityContext; |
|
|
|
return velocityContext; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
String options = genTable.getOptions(); |
|
|
|
|
|
|
|
JSONObject paramsObj = JSONObject.parseObject(options); |
|
|
|
|
|
|
|
String parentMenuId = getParentMenuId(paramsObj); |
|
|
|
|
|
|
|
context.put("parentMenuId", parentMenuId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) |
|
|
|
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -221,7 +233,21 @@ public class VelocityUtils |
|
|
|
public static String getPermissionPrefix(String moduleName, String businessName) |
|
|
|
public static String getPermissionPrefix(String moduleName, String businessName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return StringUtils.format("{}:{}", moduleName, businessName); |
|
|
|
return StringUtils.format("{}:{}", moduleName, businessName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取上级菜单ID字段 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param options 生成其他选项 |
|
|
|
|
|
|
|
* @return 上级菜单ID字段 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static String getParentMenuId(JSONObject paramsObj) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return paramsObj.getString(GenConstants.PARENT_MENU_ID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return DEFAULT_PARENT_MENU_ID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -236,7 +262,7 @@ public class VelocityUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -251,7 +277,7 @@ public class VelocityUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -266,7 +292,7 @@ public class VelocityUtils |
|
|
|
{ |
|
|
|
{ |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); |
|
|
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -295,4 +321,4 @@ public class VelocityUtils |
|
|
|
} |
|
|
|
} |
|
|
|
return num; |
|
|
|
return num; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|