1.添加生成Vue配置文件页面的模板;
2.修改后端Controller模板中findPage返回结果为PageBean; 3.修改后端JavaBean模板中日期格式
This commit is contained in:
parent
a1eac7cfdd
commit
b9ae618855
4
pom.xml
4
pom.xml
@ -38,12 +38,12 @@
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.4</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>7.0.47</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jfinal</groupId>
|
||||
<artifactId>enjoy</artifactId>
|
||||
|
@ -69,14 +69,14 @@
|
||||
<tr>
|
||||
<th>后端模板选择</th>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" name="a" value="" checked> <span>mybaits</span></label>
|
||||
<label class="radio-inline"><input type="radio" name="a" value="" disabled> <span>hibernate</span></label>
|
||||
<label class="radio-inline"><input type="radio" v-model="row.serviceTpl" value="mb" v-checked="true"> <span>mybaits</span></label>
|
||||
<label class="radio-inline"><input type="radio" v-model="row.serviceTpl" value="hb"> <span>hibernate</span></label>
|
||||
|
||||
</td>
|
||||
<th>前端模板选择</th>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" name="b" value="" checked> <span>angularjs</span></label>
|
||||
<label class="radio-inline"><input type="radio" name="b" value="" disabled> <span>vue</span></label>
|
||||
<label class="radio-inline"><input type="radio" v-model="row.fontTpl" value="a" v-checked="true"> <span>angularjs</span></label>
|
||||
<label class="radio-inline"><input type="radio" v-model="row.fontTpl" value="v" > <span>vue</span></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -167,7 +167,7 @@
|
||||
red.setData("cfg_" + fileName, n);
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
//历史上传的文件数据(文件存贮在用户本地)
|
||||
@ -297,7 +297,7 @@
|
||||
pageModel: "abx",
|
||||
author: "EverCA",
|
||||
ca:["service"],
|
||||
sheetNames: ["message_finger"]
|
||||
sheetNames: ["message_finger"],
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -2,8 +2,14 @@ package com.eversec.kit.creator;
|
||||
|
||||
import com.eversec.common.FileKit;
|
||||
import com.eversec.common.Kv;
|
||||
import com.eversec.kit.creator.impl.*;
|
||||
import com.eversec.kit.creator.impl.ControllerKit;
|
||||
import com.eversec.kit.creator.impl.DaoMapper;
|
||||
import com.eversec.kit.creator.impl.JavaBeanKit;
|
||||
import com.eversec.kit.creator.impl.ServiceImplKit;
|
||||
import com.eversec.kit.creator.impl.ServiceKit;
|
||||
import com.eversec.kit.creator.impl.SqlKit;
|
||||
import com.eversec.kit.creator.impl.page.*;
|
||||
import com.eversec.kit.creator.impl.XmlSqlKit;
|
||||
import com.eversec.service.CfgBean;
|
||||
|
||||
import java.io.File;
|
||||
@ -22,24 +28,32 @@ public class Runner {
|
||||
List<String> ca = cfgBean.getCa();
|
||||
ca.forEach(x -> {
|
||||
if ("service".equalsIgnoreCase(x)) {
|
||||
creators.add(new JavaBeanKit());// JavaBean
|
||||
creators.add(new XmlSqlKit());// 生成mysql 版本的xml配置文件, 如果要生成Es使用对应的实例对象即可
|
||||
creators.add(new ControllerKit());// Controller
|
||||
creators.add(new ServiceKit());//service
|
||||
creators.add(new ServiceImplKit());//ServiceImpl
|
||||
creators.add(new DaoMapper());// Mapper.java文件 针对使用Mybites创建对应的xxxMapper.java
|
||||
if ("mb".equalsIgnoreCase(cfgBean.getServiceTpl())){
|
||||
creators.add(new JavaBeanKit());// JavaBean
|
||||
creators.add(new XmlSqlKit());// 生成mysql 版本的xml配置文件, 如果要生成Es使用对应的实例对象即可
|
||||
creators.add(new ControllerKit());// Controller
|
||||
creators.add(new ServiceKit());//service
|
||||
creators.add(new ServiceImplKit());//ServiceImpl
|
||||
creators.add(new DaoMapper());// Mapper.java文件 针对使用Mybites创建对应的xxxMapper.java
|
||||
}else if ("hb".equalsIgnoreCase(cfgBean.getServiceTpl())){
|
||||
|
||||
}
|
||||
}
|
||||
if ("ddl".equalsIgnoreCase(x)) {
|
||||
creators.add(new SqlKit());// Mysql 建表语句,【提示Es或者其他建表语句可自行创建对应的实现】
|
||||
}
|
||||
if ("front".equalsIgnoreCase(x)) {
|
||||
creators.add(new CtrlKit());
|
||||
creators.add(new ListKit());
|
||||
creators.add(new EditKit());
|
||||
creators.add(new EditCtrlKit());
|
||||
creators.add(new ConditionKit());
|
||||
creators.add(new DetailKit());
|
||||
creators.add(new DetailCtrlKit());
|
||||
if ("a".equalsIgnoreCase(cfgBean.getFontTpl())){
|
||||
creators.add(new CtrlKit());
|
||||
creators.add(new ListKit());
|
||||
creators.add(new EditKit());
|
||||
creators.add(new EditCtrlKit());
|
||||
creators.add(new ConditionKit());
|
||||
creators.add(new DetailKit());
|
||||
creators.add(new DetailCtrlKit());
|
||||
}else if ("v".equalsIgnoreCase(cfgBean.getFontTpl())){
|
||||
creators.add(new VueKit());
|
||||
}
|
||||
}
|
||||
});
|
||||
return creators;
|
||||
@ -50,6 +64,7 @@ public class Runner {
|
||||
|
||||
StringBuilder sqlBuf = new StringBuilder();
|
||||
List<Kv> ctrList = new ArrayList<>();
|
||||
List<Kv> vueRouterList = new ArrayList<>();
|
||||
|
||||
infoBuf.append("------------ start ... ------------\n");
|
||||
infoBuf.append("create service code path:" + ICreator.dirPath + "\n");
|
||||
@ -82,6 +97,14 @@ public class Runner {
|
||||
else if (x instanceof SqlKit){
|
||||
sqlBuf.append(x.createStr(clazz, list, para));
|
||||
}
|
||||
else if (x instanceof VueKit){
|
||||
Kv kt = new Kv();
|
||||
kt.put("name",ICreator.toLowerCaseFirst(clazz));
|
||||
kt.put("title",remark);
|
||||
vueRouterList.add(kt);
|
||||
|
||||
x.createFile(x.createStr(clazz, list, para), clazz);
|
||||
}
|
||||
else {
|
||||
x.createFile(x.createStr(clazz, list, para), clazz);
|
||||
}
|
||||
@ -109,6 +132,12 @@ public class Runner {
|
||||
String strList = ICreator.engine.getTemplate(ICreator.tplPath + "front/ext/listExtTpl.html").renderToString(Kv.of("data", ctrList));
|
||||
FileKit.strToFile(strList, new File("tmp/list.html"));
|
||||
}
|
||||
|
||||
if (vueRouterList.size() > 0){
|
||||
String vList = ICreator.engine.getTemplate(ICreator.tplPath + "front/VueRouterTpl.js").renderToString(Kv.of("cfg", vueRouterList));
|
||||
FileKit.strToFile(vList, new File(ICreator.pageDirPath + "/kit/routerConfig.js"));
|
||||
}
|
||||
|
||||
infoBuf.append("------------ complete! -----------\n");
|
||||
|
||||
System.out.println(infoBuf.toString());
|
||||
|
126
src/com/eversec/kit/creator/impl/page/VueKit.java
Normal file
126
src/com/eversec/kit/creator/impl/page/VueKit.java
Normal file
@ -0,0 +1,126 @@
|
||||
package com.eversec.kit.creator.impl.page;
|
||||
|
||||
import com.eversec.common.Kv;
|
||||
import com.eversec.kit.creator.ICreator;
|
||||
import com.eversec.kit.creator.impl.page.PageKit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class VueKit extends PageKit {
|
||||
|
||||
@Override
|
||||
public File getFile(String clazz) {
|
||||
return new File(filePath(clazz) + "/kit/" + ICreator.toLowerCaseFirst(clazz) + ".vue");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createStr(String clazz, List<Map> fieldList, Map para) {
|
||||
List<String> sc = new ArrayList<>();
|
||||
List<Map> filterList = new ArrayList<>();
|
||||
List<String> detailsList = new ArrayList<>();
|
||||
List<Map> editsList = new ArrayList<>();
|
||||
fieldList.forEach(x -> {
|
||||
x.put("field", (x.get("field") + "").trim());
|
||||
x.put("isMust", isMust(x));
|
||||
x.put("fieldType", getFiledType(x.get("cate")+""));
|
||||
x.put("fieldV",createFiled(x));
|
||||
if ("1".equals(x.get("column"))){
|
||||
sc.add((x.get("field") + "").trim());
|
||||
}
|
||||
if ("1".equals(x.get("filter"))){
|
||||
Map map = new HashMap();
|
||||
map.put("name",(x.get("field") + "").trim());
|
||||
map.put("label",x.get("remark1"));
|
||||
map.put("col","EQUAL");
|
||||
map.put("remark","等于");
|
||||
filterList.add(map);
|
||||
}
|
||||
if ("like".equals(x.get("filter"))){
|
||||
Map map = new HashMap();
|
||||
map.put("name",(x.get("field") + "").trim());
|
||||
map.put("label",x.get("remark1"));
|
||||
map.put("col","LIKE");
|
||||
map.put("remark","LIKE");
|
||||
filterList.add(map);
|
||||
}
|
||||
if ("1".equals(x.get("xqzs"))){
|
||||
detailsList.add((x.get("field") + "").trim());
|
||||
}
|
||||
if ("1".equals(x.get("edit"))){
|
||||
Map map = new HashMap();
|
||||
if ("id".equals((x.get("field") + "").trim())){
|
||||
map.put("col",(x.get("field") + "").trim());
|
||||
map.put("upAttr","hidden");
|
||||
map.put("addAttr","none");
|
||||
|
||||
}else {
|
||||
map.put("col",(x.get("field") + "").trim());
|
||||
if ("1".equals(x.get("ck"))){
|
||||
map.put("ck",(x.get("field") + "").trim());
|
||||
}
|
||||
}
|
||||
editsList.add(map);
|
||||
}
|
||||
|
||||
});
|
||||
Kv kv = createTplData(clazz);
|
||||
kv.set("remark", para.get("remark"));
|
||||
kv.set("fieldList", fieldList);
|
||||
kv.set("showCol",sc);
|
||||
kv.set("fs",filterList);
|
||||
kv.set("detailsList",detailsList);
|
||||
kv.set("editsList",editsList);
|
||||
kv.set("conditionLabel", getConditionLabel(fieldList, para));
|
||||
|
||||
return engine.getTemplate(tplPath + "front/VueTpl.vue").renderToString(kv);
|
||||
}
|
||||
|
||||
protected String createFiled(Map x){
|
||||
String res = "";
|
||||
if ("2".equals(String.valueOf(x.get("edit")))) {
|
||||
res = x.get("field") + "||" + x.get("selects");
|
||||
} else if ("SELECT".equalsIgnoreCase(String.valueOf(x.get("tag")))) {
|
||||
res = x.get("field") + "=" + x.get("field");
|
||||
} else if ("SELECT_EXT".equalsIgnoreCase(String.valueOf(x.get("tag")))) {
|
||||
res = x.get("field") + "|" + x.get("selects");
|
||||
} else if ("INPUT_DT".equalsIgnoreCase(String.valueOf(x.get("tag")))) {
|
||||
res = x.get("field") + "=dt";
|
||||
} else if ("FILE_EXT".equalsIgnoreCase(String.valueOf(x.get("tag")))) {
|
||||
res = x.get("selects") + "";
|
||||
} else {
|
||||
res = x.get("field") + "";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filePath(String clazz) {
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
//获取设置了关键字查询的 字段“描述”
|
||||
private String getConditionLabel(List<Map> fieldList, Map para) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (para.get("condition") != null){
|
||||
List<String> conditions = asList((String[]) para.get("condition"));
|
||||
fieldList.forEach(m->{
|
||||
for (String str : conditions) {
|
||||
//字段有大小写转换,这里需要使用 equalsIgnoreCase 进行比较
|
||||
if ((m.get("field")+"").trim().equalsIgnoreCase(str)) {
|
||||
buf.append(m.get("remark1")+"/");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (buf.length() > 0){
|
||||
buf.deleteCharAt(buf.length()-1);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
@ -19,6 +19,8 @@ public class CfgBean {
|
||||
private String pkg;
|
||||
private String pageModel;
|
||||
private String author;
|
||||
private String fontTpl;
|
||||
private String serviceTpl;
|
||||
private List<String> ca;
|
||||
private List<String> sheetNames;
|
||||
|
||||
@ -86,6 +88,22 @@ public class CfgBean {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getFontTpl() {
|
||||
return fontTpl;
|
||||
}
|
||||
|
||||
public void setFontTpl(String fontTpl) {
|
||||
this.fontTpl = fontTpl;
|
||||
}
|
||||
|
||||
public String getServiceTpl() {
|
||||
return serviceTpl;
|
||||
}
|
||||
|
||||
public void setServiceTpl(String serviceTpl) {
|
||||
this.serviceTpl = serviceTpl;
|
||||
}
|
||||
|
||||
public List<String> getCa() {
|
||||
return ca;
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package #(pkg).controller;
|
||||
import com.eversec.common.AbstractBaseController;
|
||||
import com.eversec.common.JBean;
|
||||
import com.eversec.common.Domain;
|
||||
import com.eversec.common.PageBean;
|
||||
import #(pkg).domain.#(bean);
|
||||
import #(pkg).service.#(bean)Service;
|
||||
import com.eversec.framework.core.data.QueryResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
@ -99,7 +99,7 @@ public class #(bean)Controller extends AbstractBaseController {
|
||||
#end
|
||||
#end
|
||||
|
||||
QueryResult pageBean = #(beanFL)Service.findPage(m);
|
||||
PageBean pageBean = #(beanFL)Service.findPage(m);
|
||||
return JBean.by(200, "成功", pageBean).toJson();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class #(bean) extends Domain {
|
||||
,field=field.substring(0, 1).toLowerCase() + field.substring(1)
|
||||
)
|
||||
#if(x.fieldType == "Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
#end
|
||||
private #(x.fieldType) #(field); //#(x.remark)
|
||||
#end
|
||||
|
14
tpl/front/VueRouterTpl.js
Normal file
14
tpl/front/VueRouterTpl.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 工具模板路由配置信息
|
||||
*/
|
||||
export default [
|
||||
#for(x : cfg)
|
||||
#set(name=x.name,
|
||||
title=x.title)
|
||||
{
|
||||
name: '#(name)',
|
||||
title: '#(title)'
|
||||
}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
]
|
108
tpl/front/VueTpl.vue
Normal file
108
tpl/front/VueTpl.vue
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
<template>
|
||||
<kit-common-list :componentListCfg="componentListCfg"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "kit-#(beanFL)",
|
||||
data(){
|
||||
return {
|
||||
componentListCfg: {
|
||||
apiCfg: {
|
||||
|
||||
title: "#(remark)",
|
||||
|
||||
conditionLabel: "#(conditionLabel)",
|
||||
|
||||
url: "/#(bean.toLowerCase())",
|
||||
|
||||
items: {
|
||||
#for(x : fieldList)
|
||||
#set(field=x.field,field=field.substring(0, 1).toLowerCase() + field.substring(1)
|
||||
,selects=x.selects
|
||||
,tag=x.tag
|
||||
,remark=x.remark1
|
||||
,fieldV=x.fieldV
|
||||
)
|
||||
"#(field)": {
|
||||
"col": "#(field)",
|
||||
"label": "#(remark)",
|
||||
"inExt": "#(selects)",
|
||||
"inType": "#(tag)",
|
||||
"expr": "#(fieldV)"
|
||||
}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
},
|
||||
|
||||
shows: [
|
||||
#for(x : showCol)
|
||||
#set(col=x
|
||||
)
|
||||
{
|
||||
"col": "#(col)",
|
||||
"order": false
|
||||
}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
],
|
||||
|
||||
filters: [
|
||||
#for(x : fs)
|
||||
#set(name=x.name,
|
||||
label=x.label,
|
||||
col=x.col,
|
||||
remark=x.remark
|
||||
)
|
||||
{
|
||||
name: "#(name)",
|
||||
label: "#(label)",
|
||||
filterType: [
|
||||
{
|
||||
col: "#(col)",
|
||||
remark: "#(remark)"
|
||||
}
|
||||
],
|
||||
checked: false
|
||||
}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
],
|
||||
|
||||
edits: [
|
||||
#for(x : editsList)
|
||||
#set(col=x.col,
|
||||
upAttr=x.upAttr,
|
||||
addAttr=x.addAttr,
|
||||
ck=x.ck
|
||||
)
|
||||
{
|
||||
col: "#(col)",
|
||||
#if(null!=upAttr)
|
||||
upAttr: "#(upAttr)",
|
||||
#end
|
||||
#if(null!=addAttr)
|
||||
addAttr: "#(addAttr)",
|
||||
#end
|
||||
#if(null!=ck)
|
||||
ck: "#(ck)"
|
||||
#end
|
||||
}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
],
|
||||
|
||||
details: [
|
||||
#for(x : detailsList)
|
||||
#set(col=x)
|
||||
{col: "#(col)"}#if(!(for.last)),
|
||||
#end
|
||||
#end
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user