代码生成支持选择前端模板类型
This commit is contained in:
@ -41,6 +41,9 @@ public class GenTable extends BaseEntity
|
||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||
private String tplCategory;
|
||||
|
||||
/** 前端类型(element-ui模版 element-plus模版) */
|
||||
private String tplWebType;
|
||||
|
||||
/** 生成包路径 */
|
||||
@NotBlank(message = "生成包路径不能为空")
|
||||
private String packageName;
|
||||
@ -165,6 +168,16 @@ public class GenTable extends BaseEntity
|
||||
this.tplCategory = tplCategory;
|
||||
}
|
||||
|
||||
public String getTplWebType()
|
||||
{
|
||||
return tplWebType;
|
||||
}
|
||||
|
||||
public void setTplWebType(String tplWebType)
|
||||
{
|
||||
this.tplWebType = tplWebType;
|
||||
}
|
||||
|
||||
public String getPackageName()
|
||||
{
|
||||
return packageName;
|
||||
|
@ -206,7 +206,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
// 获取模板列表
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
||||
for (String template : templates)
|
||||
{
|
||||
// 渲染模板
|
||||
@ -254,7 +254,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
// 获取模板列表
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
||||
for (String template : templates)
|
||||
{
|
||||
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
|
||||
@ -367,7 +367,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
// 获取模板列表
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
||||
for (String template : templates)
|
||||
{
|
||||
// 渲染模板
|
||||
|
@ -123,11 +123,17 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 获取模板信息
|
||||
*
|
||||
* @param tplCategory 生成的模板
|
||||
* @param tplWebType 前端类型
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static List<String> getTemplateList(String tplCategory)
|
||||
public static List<String> getTemplateList(String tplCategory, String tplWebType)
|
||||
{
|
||||
String useWebType = "vm/vue";
|
||||
if ("element-plus".equals(tplWebType))
|
||||
{
|
||||
useWebType = "vm/vue/v3";
|
||||
}
|
||||
List<String> templates = new ArrayList<String>();
|
||||
templates.add("vm/java/domain.java.vm");
|
||||
templates.add("vm/java/mapper.java.vm");
|
||||
@ -139,15 +145,15 @@ public class VelocityUtils
|
||||
templates.add("vm/js/api.js.vm");
|
||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add(useWebType + "/index.vue.vm");
|
||||
}
|
||||
else if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index-tree.vue.vm");
|
||||
templates.add(useWebType + "/index-tree.vue.vm");
|
||||
}
|
||||
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add(useWebType + "/index.vue.vm");
|
||||
templates.add("vm/java/sub-domain.java.vm");
|
||||
}
|
||||
return templates;
|
||||
|
Reference in New Issue
Block a user