Conflicts:
	ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
	ruoyi-generator/src/main/resources/vm/sql/sql.vm
	ruoyi-ui/src/utils/index.js
	ruoyi-ui/src/utils/ruoyi.js
	ruoyi-ui/src/views/tool/gen/editTable.vue
	ruoyi-ui/src/views/tool/gen/genInfoForm.vue
	ruoyi-ui/src/views/tool/gen/importTable.vue
This commit is contained in:
疯狂的狮子li
2020-07-23 09:54:57 +08:00
16 changed files with 262 additions and 31 deletions

View File

@ -178,6 +178,8 @@ public class GenController extends BaseController
private void genCode(HttpServletResponse response, byte[] data) throws IOException
{
response.reset();
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");

View File

@ -74,6 +74,12 @@ public class GenTable extends BaseEntity
/** 树名称字段 */
private String treeName;
/** 上级菜单ID字段 */
private String parentMenuId;
/** 上级菜单名称字段 */
private String parentMenuName;
public Long getTableId()
{
return tableId;
@ -234,6 +240,26 @@ public class GenTable extends BaseEntity
this.treeName = treeName;
}
public String getParentMenuId()
{
return parentMenuId;
}
public void setParentMenuId(String parentMenuId)
{
this.parentMenuId = parentMenuId;
}
public String getParentMenuName()
{
return parentMenuName;
}
public void setParentMenuName(String parentMenuName)
{
this.parentMenuName = parentMenuName;
}
public boolean isTree()
{
return isTree(this.tplCategory);
@ -268,4 +294,4 @@ public class GenTable extends BaseEntity
}
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
}
}
}

View File

@ -337,9 +337,14 @@ public class GenTableServiceImpl implements IGenTableService
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
genTable.setTreeCode(treeCode);
genTable.setTreeParentCode(treeParentCode);
genTable.setTreeName(treeName);
genTable.setParentMenuId(parentMenuId);
genTable.setParentMenuName(parentMenuName);
}
}
}
}

View File

@ -11,18 +11,16 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
/**
* 代码生成模板处理
*
* @author ruoyi
*/
public class VelocityUtils
{
/** 项目空间路径 */
private static final String PROJECT_PATH = "main/java";
/** mybatis空间路径 */
private static final String MYBATIS_PATH = "main/resources/mapper";
private static final String MYBATIS_PATH = "main/resources/mybatis";
/** 默认上级菜单,系统工具 */
private static final String DEFAULT_PARENT_MENU_ID = "3";
/**
* 设置模板变量信息
@ -55,6 +53,7 @@ public class VelocityUtils
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
velocityContext.put("columns", genTable.getColumns());
velocityContext.put("table", genTable);
setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory))
{
setTreeVelocityContext(velocityContext, genTable);
@ -62,6 +61,14 @@ public class VelocityUtils
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)
{
String options = genTable.getOptions();
@ -224,6 +231,21 @@ public class VelocityUtils
}
/**
* 获取上级菜单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 +258,7 @@ public class VelocityUtils
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
}
return "";
return StringUtils.EMPTY;
}
/**
@ -251,7 +273,7 @@ public class VelocityUtils
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
return "";
return StringUtils.EMPTY;
}
/**
@ -266,7 +288,7 @@ public class VelocityUtils
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
}
return "";
return StringUtils.EMPTY;
}
/**
@ -295,4 +317,4 @@ public class VelocityUtils
}
return num;
}
}
}

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();