1.添加生成Vue配置文件页面的模板;
2.修改后端Controller模板中findPage返回结果为PageBean; 3.修改后端JavaBean模板中日期格式
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user