服务和WEB隔离

Former-commit-id: 859de5a586ccff4c987e7d291d954bfcaea5ff86
master
王兵 5 years ago
parent e75fa146a2
commit bb510ef009

@ -50,10 +50,10 @@ import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import xyz.wbsite.dbtool.javafx.po.DataBase; import xyz.wbsite.dbtool.javafx.po.DataBase;
import xyz.wbsite.dbtool.javafx.po.Field; import xyz.wbsite.dbtool.javafx.po.Field;
import xyz.wbsite.dbtool.javafx.po.FieldType; import xyz.wbsite.dbtool.javafx.po.FieldType;
import xyz.wbsite.dbtool.javafx.po.Frame;
import xyz.wbsite.dbtool.javafx.po.Module; import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.Project; import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.Table; import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.javafx.po.Frame;
import xyz.wbsite.dbtool.javafx.tool.Dialog; import xyz.wbsite.dbtool.javafx.tool.Dialog;
import xyz.wbsite.dbtool.javafx.tool.Tool; import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell; import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
@ -158,6 +158,13 @@ public class JavaFxApplication extends Application {
new MenuItem("编辑字典"), new MenuItem("编辑字典"),
new MenuItem("向上调整"), new MenuItem("向上调整"),
new MenuItem("向下调整")); new MenuItem("向下调整"));
} else if (field.getFieldType().equals(FieldType.Select.name())) {
con = new ContextMenu(
new MenuItem("新增"),
new MenuItem("删除"),
new MenuItem("编辑选项"),
new MenuItem("向上调整"),
new MenuItem("向下调整"));
} else { } else {
con = new ContextMenu( con = new ContextMenu(
new MenuItem("新增"), new MenuItem("新增"),
@ -198,9 +205,15 @@ public class JavaFxApplication extends Application {
fields.remove(index + 2); fields.remove(index + 2);
} }
break; break;
case "编辑字典": case "编辑字典": {
Field field = fields.get(index); Field field = fields.get(index);
Dialog.showDictEdit(field); Dialog.showDictEdit(field);
}
break;
case "编辑选项": {
Field field = fields.get(index);
Dialog.showSelectEdit(field);
}
break; break;
} }
JavaFxApplication.this.mFields.getSelectionModel().clearSelection(); JavaFxApplication.this.mFields.getSelectionModel().clearSelection();

@ -0,0 +1,149 @@
package xyz.wbsite.dbtool.javafx.ctrl;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback;
import javafx.util.converter.DefaultStringConverter;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import java.util.ArrayList;
import java.util.List;
public class OptionSelectController {
@FXML
private Button start;
@FXML
private Button cancel;
@FXML
private TableView datas;
@FXML
private Button add;
@FXML
private Button sub;
private List<SelectItem> data = new ArrayList<>();
public List<SelectItem> getData() {
return data;
}
public void setData(List<SelectItem> data) {
this.data = data;
}
public Button getStart() {
return start;
}
public void setStart(Button start) {
this.start = start;
}
public Button getCancel() {
return cancel;
}
public void setCancel(Button cancel) {
this.cancel = cancel;
}
public TableView getDatas() {
return datas;
}
public void setDatas(TableView datas) {
this.datas = datas;
}
public Button getAdd() {
return add;
}
public void setAdd(Button add) {
this.add = add;
}
public Button getSub() {
return sub;
}
public void setSub(Button sub) {
this.sub = sub;
}
public void initData() {
datas.setEditable(true);
datas.setSortPolicy(new Callback<TableView, Boolean>() {
@Override
public Boolean call(TableView param) {
//禁止点击列头排序
return false;
}
});
ObservableList<TableColumn> columns = datas.getColumns();
columns.get(0).setCellValueFactory(new PropertyValueFactory("value"));
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
param.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent>() {
@Override
public void handle(TableColumn.CellEditEvent event) {
int row = event.getTablePosition().getRow();
SelectItem field = data.get(row);
field.setValue((String) event.getNewValue());
}
});
return new TextFieldTableCell(new DefaultStringConverter()) {
@Override
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
int index = this.getTableRow().getIndex();
}
};
}
});
ObservableList<SelectItem> ObservableList = FXCollections.observableArrayList();
ObservableList.addAll(data);
datas.setItems(ObservableList);
}
public void refresh(){
ObservableList<SelectItem> ObservableList = FXCollections.observableArrayList();
ObservableList.addAll(data);
datas.setItems(ObservableList);
}
public SelectItem getNewSelectItem() {
String baseValue = "VALUE";
String value = baseValue;
int k = 0;
do {
int i;
for (i = 0; i < data.size(); i++) {
if (value.equals(data.get(i).getValue())) {
break;
}
}
if (i < data.size()) {
k++;
value = baseValue + k;
} else {
SelectItem SelectItem = new SelectItem();
SelectItem.setValue(value);
return SelectItem;
}
} while (true);
}
}

@ -4,6 +4,7 @@ import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.MultiTemplateLoader; import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader; import freemarker.cache.TemplateLoader;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.DefaultListAdapter;
import freemarker.template.Template; import freemarker.template.Template;
import freemarker.template.TemplateException; import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler; import freemarker.template.TemplateExceptionHandler;
@ -11,6 +12,7 @@ import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException; import freemarker.template.TemplateModelException;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.tool.Tool; import xyz.wbsite.dbtool.javafx.tool.Tool;
import java.io.File; import java.io.File;
@ -18,6 +20,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class FreeMarkerManager { public class FreeMarkerManager {
@ -32,6 +35,7 @@ public class FreeMarkerManager {
cfg.setNumberFormat("0.##"); cfg.setNumberFormat("0.##");
cfg.setSharedVariable("print", new Print()); cfg.setSharedVariable("print", new Print());
cfg.setSharedVariable("uuid", new Uuid()); cfg.setSharedVariable("uuid", new Uuid());
cfg.setSharedVariable("toString", new ToString());
MultiTemplateLoader multiTemplateLoader = new MultiTemplateLoader(new TemplateLoader[]{ MultiTemplateLoader multiTemplateLoader = new MultiTemplateLoader(new TemplateLoader[]{
new ClassTemplateLoader(ClassUtils.getDefaultClassLoader(), "/modules"), new ClassTemplateLoader(ClassUtils.getDefaultClassLoader(), "/modules"),
@ -87,4 +91,34 @@ public class FreeMarkerManager {
} }
} }
private class ToString implements TemplateMethodModelEx {
@Override
public Object exec(List list) throws TemplateModelException {
if (list.size() > 0) {
DefaultListAdapter list1 = (DefaultListAdapter) list.get(0);
List wrappedObject = (List) list1.getWrappedObject();
if (wrappedObject.get(0) instanceof SelectItem) {
StringBuffer sb = new StringBuffer("{");
Iterator iterator = wrappedObject.iterator();
while (iterator.hasNext()) {
SelectItem next = (SelectItem) iterator.next();
sb.append("\"");
sb.append(next.getValue());
sb.append("\"");
if (iterator.hasNext()) {
sb.append(", ");
}
}
sb.append("}");
return sb.toString();
}
}
return "";
}
}
} }

@ -13,6 +13,7 @@ import xyz.wbsite.dbtool.javafx.po.Field;
import xyz.wbsite.dbtool.javafx.po.Frame; import xyz.wbsite.dbtool.javafx.po.Frame;
import xyz.wbsite.dbtool.javafx.po.Module; import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.Project; import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.Table; import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.web.frame.utils.ClassUtil; import xyz.wbsite.dbtool.web.frame.utils.ClassUtil;
@ -92,6 +93,14 @@ public class XmlManager {
map(di, dictItem); map(di, dictItem);
field.getDictItems().add(dictItem); field.getDictItems().add(dictItem);
} }
NodeList selectItems = fieldElement.getElementsByTagName("selectItem");
for (int l = 0; l < selectItems.getLength(); l++) {
Element di = (Element) selectItems.item(l);
SelectItem selectItem = new SelectItem();
map(di, selectItem);
field.getSelectItems().add(selectItem);
}
} }
} }
table.setdBhandle(module); table.setdBhandle(module);
@ -141,15 +150,11 @@ public class XmlManager {
modules.appendChild(module); modules.appendChild(module);
map(md, module); map(md, module);
Element tables = doc.createElement("tables");
module.appendChild(tables);
for (Table t : md.getTables()) { for (Table t : md.getTables()) {
// 写入table信息 // 写入table信息
Element table = doc.createElement("table"); Element table = doc.createElement("table");
tables.appendChild(table); module.appendChild(table);
map(t, table); map(t, table);
Element fields = doc.createElement("fields");
table.appendChild(fields);
for (Field f : t.getFields()) { for (Field f : t.getFields()) {
// 写入field信息 // 写入field信息
Element field = doc.createElement("field"); Element field = doc.createElement("field");
@ -157,13 +162,22 @@ public class XmlManager {
if (f.getDictItems().size() > 0) { if (f.getDictItems().size() > 0) {
for (DictItem dictItem : f.getDictItems()) { for (DictItem dictItem : f.getDictItems()) {
// 写入dictItem信息 // 写入DictItem信息
Element dict = doc.createElement("dictItem"); Element dict = doc.createElement("dictItem");
field.appendChild(dict); field.appendChild(dict);
map(dictItem, dict); map(dictItem, dict);
} }
} }
fields.appendChild(field);
if (f.getSelectItems().size() > 0) {
for (SelectItem dictItem : f.getSelectItems()) {
// 写入SelectItem信息
Element dict = doc.createElement("selectItem");
field.appendChild(dict);
map(dictItem, dict);
}
}
table.appendChild(field);
} }
} }
} }

@ -199,10 +199,14 @@ public class SpringBootCallable implements Callable {
if (project.getFrame().value() >= Frame..value()) {//生成系统模块 if (project.getFrame().value() >= Frame..value()) {//生成系统模块
File wsys = Tool.createPath(ajax, "wsys"); File wsys = Tool.createPath(ajax, "wsys");
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/action/ajax/wsys/")) { for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/action/ajax/wsys/")) {
freeMarkerManager.outputTemp(Tool.createFile(wsys, name), "SpringBoot/java/action/ajax/wsys/" + name, ctx); freeMarkerManager.outputTemp(Tool.createFile(wsys, name), "SpringBoot/java/action/ajax/wsys/" + name, ctx);
} }
File wmnt = Tool.createPath(ajax, "wmnt");
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/action/ajax/wmnt/")) {
freeMarkerManager.outputTemp(Tool.createFile(wsys, name), "SpringBoot/java/action/ajax/wmnt/" + name, ctx);
}
} }
} }
} }
@ -290,11 +294,11 @@ public class SpringBootCallable implements Callable {
ctx.put("moduleName", module.getModuleName()); ctx.put("moduleName", module.getModuleName());
ctx.put("dataBase", project.getDatabase().toString()); ctx.put("dataBase", project.getDatabase().toString());
File ent = Tool.createFile(Tool.createPath(root, module.getModuleName()), "ent"); File ent = Tool.createPath(Tool.createPath(root, module.getModuleName()), "ent");
File mpr = Tool.createFile(Tool.createPath(root, module.getModuleName()), "mpr"); File mpr = Tool.createPath(Tool.createPath(root, module.getModuleName()), "mpr");
File mgr = Tool.createFile(Tool.createPath(root, module.getModuleName()), "mgr"); File mgr = Tool.createPath(Tool.createPath(root, module.getModuleName()), "mgr");
File req = Tool.createFile(Tool.createPath(root, module.getModuleName()), "req"); File req = Tool.createPath(Tool.createPath(root, module.getModuleName()), "req");
File rsp = Tool.createFile(Tool.createPath(root, module.getModuleName()), "rsp"); File rsp = Tool.createPath(Tool.createPath(root, module.getModuleName()), "rsp");
if (module.getNeedGenerate()) { if (module.getNeedGenerate()) {
module.setProjectAuthor(project.getAuthor()); module.setProjectAuthor(project.getAuthor());
@ -491,10 +495,8 @@ public class SpringBootCallable implements Callable {
//auth //auth
File auth = Tool.createPath(root, "auth"); File auth = Tool.createPath(root, "auth");
freeMarkerManager.outputTemp(Tool.createFile(auth, "LocalData.java"), "SpringBoot/java/frame/auth/LocalData.java", ctx); for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/auth/")) {
freeMarkerManager.outputTemp(Tool.createFile(auth, "Token.java"), "SpringBoot/java/frame/auth/Token.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(auth, name), "SpringBoot/java/frame/auth/" + name, ctx);
if (project.getFrame().value() >= Frame..value()) {
freeMarkerManager.outputTemp(Tool.createFile(auth, "Verification.java"), "SpringBoot/java/frame/auth/Verification.java", ctx);
} }
//base //base
@ -762,6 +764,10 @@ public class SpringBootCallable implements Callable {
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/resources/templates/screen/module/wsys/")) { for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/resources/templates/screen/module/wsys/")) {
Tool.outputResource("SpringBoot/resources/templates/screen/module/wsys/" + name, Tool.createFile(wsys, name)); Tool.outputResource("SpringBoot/resources/templates/screen/module/wsys/" + name, Tool.createFile(wsys, name));
} }
File wmnt = Tool.createPath(screen, "wmnt");
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/resources/templates/screen/module/wmnt/")) {
Tool.outputResource("SpringBoot/resources/templates/screen/module/wmnt/" + name, Tool.createFile(wmnt, name));
}
} }
} }
} }

@ -211,6 +211,16 @@ public class Field extends Table {
this.dictItems = dictItems; this.dictItems = dictItems;
} }
private List<SelectItem> selectItems = new ArrayList<>();
public List<SelectItem> getSelectItems() {
return selectItems;
}
public void setSelectItems(List<SelectItem> selectItems) {
this.selectItems = selectItems;
}
public String getTestValue() { public String getTestValue() {
String value = ""; String value = "";
if (fieldType.get().matches("String_\\d+")) { if (fieldType.get().matches("String_\\d+")) {
@ -311,6 +321,7 @@ public class Field extends Table {
public String getFieldTypeJava() { public String getFieldTypeJava() {
return FieldType.parse(getFieldType()).javaType(); return FieldType.parse(getFieldType()).javaType();
} }
public String getFieldTypeJdbc() { public String getFieldTypeJdbc() {
return FieldType.parse(getFieldType()).jdbcType(); return FieldType.parse(getFieldType()).jdbcType();
} }

@ -13,6 +13,7 @@ public enum FieldType {
Date(0),//日期时间 Date(0),//日期时间
BigDecimal(0),//高精度 BigDecimal(0),//高精度
Dict(20),//字典 Dict(20),//字典
Select(20),//选项
String_1(1),//字符1 String_1(1),//字符1
String_10(10),//字符10 String_10(10),//字符10
String_var(20, false),//字符20 String_var(20, false),//字符20
@ -119,6 +120,8 @@ public enum FieldType {
return "BigDecimal"; return "BigDecimal";
} else if (Dict.name().equals(this.name())) { } else if (Dict.name().equals(this.name())) {
return "Dict"; return "Dict";
} else if (Select.name().equals(this.name())) {
return "Select";
} else if (String_1.name().equals(this.name())) { } else if (String_1.name().equals(this.name())) {
return "String_1"; return "String_1";
} else if (String_10.name().equals(this.name())) { } else if (String_10.name().equals(this.name())) {
@ -169,6 +172,8 @@ public enum FieldType {
return "BigDecimal"; return "BigDecimal";
} else if (Dict.name().equals(this.name())) { } else if (Dict.name().equals(this.name())) {
return "String"; return "String";
}else if (Select.name().equals(this.name())) {
return "String";
} else if (String_1.name().equals(this.name())) { } else if (String_1.name().equals(this.name())) {
return "String"; return "String";
} else if (String_10.name().equals(this.name())) { } else if (String_10.name().equals(this.name())) {
@ -219,6 +224,8 @@ public enum FieldType {
return "NUMERIC"; return "NUMERIC";
} else if (Dict.name().equals(this.name())) { } else if (Dict.name().equals(this.name())) {
return "VARCHAR"; return "VARCHAR";
}else if (Select.name().equals(this.name())) {
return "VARCHAR";
} else if (String_1.name().equals(this.name())) { } else if (String_1.name().equals(this.name())) {
return "CHAR"; return "CHAR";
} else if (String_10.name().equals(this.name())) { } else if (String_10.name().equals(this.name())) {

@ -34,6 +34,9 @@ public class MySQLDBmapper extends AbstractDBmapper {
} else if (FieldType.Dict.name().equals(type)) { } else if (FieldType.Dict.name().equals(type)) {
Integer fieldLength = field.getFieldLength(); Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")"); sb.append("VARCHAR(" + fieldLength + ")");
}else if (FieldType.Select.name().equals(type)) {
Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.String_1.name().equals(type)) { } else if (FieldType.String_1.name().equals(type)) {
sb.append("CHAR(1)"); sb.append("CHAR(1)");
} else if (FieldType.String_10.name().equals(type)) { } else if (FieldType.String_10.name().equals(type)) {
@ -118,6 +121,8 @@ public class MySQLDBmapper extends AbstractDBmapper {
return "NUMERIC"; return "NUMERIC";
} else if (FieldType.Dict.name().equals(type.name())) { } else if (FieldType.Dict.name().equals(type.name())) {
return "VARCHAR"; return "VARCHAR";
} else if (FieldType.Select.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_1.name().equals(type.name())) { } else if (FieldType.String_1.name().equals(type.name())) {
return "CHAR"; return "CHAR";
} else if (FieldType.String_10.name().equals(type.name())) { } else if (FieldType.String_10.name().equals(type.name())) {

@ -34,6 +34,9 @@ public class OracleDBmapper extends AbstractDBmapper {
} else if (FieldType.Dict.name().equals(type)) { } else if (FieldType.Dict.name().equals(type)) {
Integer fieldLength = field.getFieldLength(); Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")"); sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.Select.name().equals(type)) {
Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.String_1.name().equals(type)) { } else if (FieldType.String_1.name().equals(type)) {
sb.append("CHAR(1)"); sb.append("CHAR(1)");
} else if (FieldType.String_10.name().equals(type)) { } else if (FieldType.String_10.name().equals(type)) {
@ -65,16 +68,22 @@ public class OracleDBmapper extends AbstractDBmapper {
} }
return sb.toString(); return sb.toString();
} }
@Override @Override
public DataBase getDataBase() { public DataBase getDataBase() {
return DataBase.Oracle; return DataBase.Oracle;
} }
@Override @Override
public String getDataBaseType(FieldType type) { public String getDataBaseType(FieldType type) {
if (FieldType.Boolean.name().equals(type.name())) { if (FieldType.Boolean.name().equals(type.name())) {
return "CHAR"; return "CHAR";
} else if (FieldType.Byte.name().equals(type.name())) { } else if (FieldType.Byte.name().equals(type.name())) {
return "NUMBER"; return "NUMBER";
}else if (FieldType.Bytes.name().equals(type.name())) {
return "BLOB";
} else if (FieldType.Character.name().equals(type.name())) {
return "NUMBER";
} else if (FieldType.Short.name().equals(type.name())) { } else if (FieldType.Short.name().equals(type.name())) {
return "NUMBER"; return "NUMBER";
} else if (FieldType.Integer.name().equals(type.name())) { } else if (FieldType.Integer.name().equals(type.name())) {
@ -87,8 +96,12 @@ public class OracleDBmapper extends AbstractDBmapper {
return "NUMBER"; return "NUMBER";
} else if (FieldType.Date.name().equals(type.name())) { } else if (FieldType.Date.name().equals(type.name())) {
return "TIMESTAMP"; return "TIMESTAMP";
} else if (FieldType.Bytes.name().equals(type.name())) { } else if (FieldType.BigDecimal.name().equals(type.name())) {
return "BLOB"; return "NUMBER";
} else if (FieldType.Dict.name().equals(type.name())) {
return "VARCHAR2";
} else if (FieldType.Select.name().equals(type.name())) {
return "VARCHAR2";
} else if (FieldType.String_1.name().equals(type.name())) { } else if (FieldType.String_1.name().equals(type.name())) {
return "CHAR"; return "CHAR";
} else if (FieldType.String_10.name().equals(type.name())) { } else if (FieldType.String_10.name().equals(type.name())) {

@ -34,6 +34,9 @@ public class SQLiteDBmapper extends AbstractDBmapper {
} else if (FieldType.Dict.name().equals(type)) { } else if (FieldType.Dict.name().equals(type)) {
Integer fieldLength = field.getFieldLength(); Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")"); sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.Select.name().equals(type)) {
Integer fieldLength = field.getFieldLength();
sb.append("VARCHAR(" + fieldLength + ")");
} else if (FieldType.String_1.name().equals(type)) { } else if (FieldType.String_1.name().equals(type)) {
sb.append("CHAR(1)"); sb.append("CHAR(1)");
} else if (FieldType.String_10.name().equals(type)) { } else if (FieldType.String_10.name().equals(type)) {
@ -103,7 +106,9 @@ public class SQLiteDBmapper extends AbstractDBmapper {
} else if (FieldType.BigDecimal.name().equals(type.name())) { } else if (FieldType.BigDecimal.name().equals(type.name())) {
return "INTEGER"; return "INTEGER";
} else if (FieldType.Dict.name().equals(type.name())) { } else if (FieldType.Dict.name().equals(type.name())) {
return "CHARACTER"; return "VARCHAR";
} else if (FieldType.Select.name().equals(type.name())) {
return "VARCHAR";
} else if (FieldType.String_1.name().equals(type.name())) { } else if (FieldType.String_1.name().equals(type.name())) {
return "CHARACTER"; return "CHARACTER";
} else if (FieldType.String_10.name().equals(type.name())) { } else if (FieldType.String_10.name().equals(type.name())) {

@ -0,0 +1,17 @@
package xyz.wbsite.dbtool.javafx.po;
import xyz.wbsite.dbtool.javafx.annotation.Property;
public class SelectItem {
@Property("value")
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -33,6 +33,7 @@ import xyz.wbsite.dbtool.javafx.ctrl.OptionAndroidController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionApiController; import xyz.wbsite.dbtool.javafx.ctrl.OptionApiController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionDictController; import xyz.wbsite.dbtool.javafx.ctrl.OptionDictController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionDocController; import xyz.wbsite.dbtool.javafx.ctrl.OptionDocController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionSelectController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionVueController; import xyz.wbsite.dbtool.javafx.ctrl.OptionVueController;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager; import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
@ -42,6 +43,7 @@ import xyz.wbsite.dbtool.javafx.po.DictItem;
import xyz.wbsite.dbtool.javafx.po.Doc; import xyz.wbsite.dbtool.javafx.po.Doc;
import xyz.wbsite.dbtool.javafx.po.Field; import xyz.wbsite.dbtool.javafx.po.Field;
import xyz.wbsite.dbtool.javafx.po.Module; import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.VueOption; import xyz.wbsite.dbtool.javafx.po.VueOption;
import java.io.File; import java.io.File;
@ -758,6 +760,74 @@ public class Dialog {
} }
} }
public static void showSelectEdit(Field field) {
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/OptionSelect.fxml"));
try {
dbdetailloader.load();
Parent root = dbdetailloader.getRoot();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("编辑字典项");
OptionSelectController controller = dbdetailloader.getController();
controller.setData(field.getSelectItems());
Button add = controller.getAdd();
add.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
SelectItem newSelectItem = controller.getNewSelectItem();
controller.getData().add(newSelectItem);
controller.refresh();
}
});
Button sub = controller.getSub();
sub.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
int selectedIndex = controller.getDatas().getSelectionModel().getSelectedIndex();
if (selectedIndex > -1) {
controller.getData().remove(selectedIndex);
controller.getDatas().getSelectionModel().clearSelection();
controller.refresh();
}
}
});
Button start = controller.getStart();
start.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Dialog.stopPopup();
Platform.runLater(new Runnable() {
@Override
public void run() {
stage.close();
}
});
}
});
Button cancel = controller.getCancel();
cancel.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stage.close();
}
});
controller.initData();
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void showAndroid() { public static void showAndroid() {
FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/OptionAndroid.fxml")); FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/OptionAndroid.fxml"));

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane fx:controller="xyz.wbsite.dbtool.javafx.ctrl.OptionSelectController"
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="200.0" prefWidth="300.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<ToolBar prefHeight="30.0" prefWidth="300.0" BorderPane.alignment="CENTER">
<items>
<Button fx:id="add" mnemonicParsing="false" text=" + "/>
<Button fx:id="sub" mnemonicParsing="false" text=" - "/>
</items>
</ToolBar>
</top>
<opaqueInsets>
<Insets/>
</opaqueInsets>
<BorderPane.margin>
<Insets top="20.0"/>
</BorderPane.margin>
<center>
<TableView fx:id="datas" prefHeight="170.0" prefWidth="300.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn prefWidth="198.0" text="选项值"/>
</columns>
</TableView>
</center>
<bottom>
<GridPane prefHeight="45.0" prefWidth="300.0" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="80.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="80.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Button fx:id="start" mnemonicParsing="false" text="确认" GridPane.halignment="CENTER"
GridPane.valignment="CENTER"/>
<Button fx:id="cancel" mnemonicParsing="false" text="取消" GridPane.columnIndex="1"
GridPane.halignment="CENTER"
GridPane.valignment="CENTER"/>
</children>
</GridPane>
</bottom>
</BorderPane>

@ -1,4 +1,4 @@
package ${domain}.action.ajax.wsys; package ${domain}.action.ajax.wmnt;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;

@ -1,4 +1,4 @@
package ${domain}.action.ajax.wsys; package ${domain}.action.ajax.wmnt;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import ${domain}.frame.base.ErrorType; import ${domain}.frame.base.ErrorType;

@ -1,6 +1,4 @@
package ${domain}.frame.auth; package ${domain}.frame.validation;
import ${domain}.frame.validation.DictValidator;
import javax.validation.Constraint; import javax.validation.Constraint;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
@ -8,10 +6,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target({ElementType.METHOD}) @Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = DictValidator.class) @Constraint(validatedBy = SelectValidator.class)
public @interface Verification { public @interface Select {
String name() default ""; String message() default "选项验证错误";
String[] value() default {};
} }

@ -0,0 +1,55 @@
package ${domain}.frame.validation;
import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl;
import ${domain}.frame.utils.StringUtil;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Locale;
public class SelectValidator implements ConstraintValidator<Select, String> {
private String[] values;
@Override
public void initialize(Select constraintAnnotation) {
values = constraintAnnotation.value();
}
@Override
public boolean isValid(String o, ConstraintValidatorContext constraintValidatorContext) {
String fieldName = "";
if (constraintValidatorContext instanceof ConstraintValidatorContextImpl) {
ConstraintValidatorContextImpl validatorContext = (ConstraintValidatorContextImpl) constraintValidatorContext;
if (validatorContext.getConstraintViolationCreationContexts() != null
&& validatorContext.getConstraintViolationCreationContexts().size() > 0
&& validatorContext.getConstraintViolationCreationContexts().get(0).getPath() != null) {
fieldName = validatorContext.getConstraintViolationCreationContexts().get(0).getPath().asString();
}
}
if (StringUtil.isEmpty(o)) {
return true;
} else {
if (values.length == 0) {
String message = String.format(Locale.CHINESE, "%s 指定枚举为空!", fieldName);
constraintValidatorContext.buildConstraintViolationWithTemplate(message).addConstraintViolation();
return false;
}
int i = 0;
for (; i < values.length; i++) {
if (o.equals(values[i])) {
break;
}
}
if (i < values.length) {
return true;
} else {
String message = String.format(Locale.CHINESE, "%s 指定枚举组 [ %s ] 中,未找到枚举值(%s)", fieldName, String.join(",", values), o);
constraintValidatorContext.buildConstraintViolationWithTemplate(message).addConstraintViolation();
return false;
}
}
}
}

@ -10,6 +10,9 @@ import java.util.Date;
<#if table.has('Dict')> <#if table.has('Dict')>
import ${domain}.frame.validation.Dict; import ${domain}.frame.validation.Dict;
</#if> </#if>
<#if table.has('Select')>
import ${domain}.frame.validation.Select;
</#if>
/** /**
* ${table.getCName()}CreateRequest - ${table.tableComment}新增 * ${table.getCName()}CreateRequest - ${table.tableComment}新增
@ -37,6 +40,9 @@ public class ${table.getCName()}CreateRequest extends BaseRequest {
<#if field.fieldType?contains("Dict")> <#if field.fieldType?contains("Dict")>
@Dict(name = "${field.getFieldName()}") @Dict(name = "${field.getFieldName()}")
</#if> </#if>
<#if field.fieldType?contains("Select")>
@Select(${toString(field.selectItems)})
</#if>
private ${field.getFieldTypeJava()} ${field.getFName()}; private ${field.getFieldTypeJava()} ${field.getFName()};
</#if> </#if>
</#list> </#list>

@ -5,6 +5,9 @@ import java.util.Date;
<#if table.has('Dict')> <#if table.has('Dict')>
import ${domain}.frame.validation.Dict; import ${domain}.frame.validation.Dict;
</#if> </#if>
<#if table.has('Select')>
import ${domain}.frame.validation.Select;
</#if>
/** /**
* ${table.getCName()}FindRequest - ${table.tableComment}查询 * ${table.getCName()}FindRequest - ${table.tableComment}查询
@ -23,6 +26,9 @@ public class ${table.getCName()}FindRequest extends BaseFindRequest {
<#if field.fieldType?contains("Dict")> <#if field.fieldType?contains("Dict")>
@Dict(name = "${field.getFieldName()}") @Dict(name = "${field.getFieldName()}")
</#if> </#if>
<#if field.fieldType?contains("Select")>
@Select(${toString(field.selectItems)})
</#if>
private ${field.getFieldTypeJava()} ${field.getFName()}; private ${field.getFieldTypeJava()} ${field.getFName()};
</#if> </#if>
</#list> </#list>

@ -11,6 +11,9 @@ import java.util.Date;
<#if table.has('Dict')> <#if table.has('Dict')>
import ${domain}.frame.validation.Dict; import ${domain}.frame.validation.Dict;
</#if> </#if>
<#if table.has('Select')>
import ${domain}.frame.validation.Select;
</#if>
/** /**
* ${table.getCName()}UpdateRequest - ${table.tableComment}更新 * ${table.getCName()}UpdateRequest - ${table.tableComment}更新
@ -38,6 +41,9 @@ public class ${table.getCName()}UpdateRequest extends BaseUpdateRequest {
<#if field.fieldType?contains("Dict")> <#if field.fieldType?contains("Dict")>
@Dict(name = "${field.getFieldName()}") @Dict(name = "${field.getFieldName()}")
</#if> </#if>
<#if field.fieldType?contains("Select")>
@Select(${toString(field.selectItems)})
</#if>
private ${field.getFieldTypeJava()} ${field.getFName()}; private ${field.getFieldTypeJava()} ${field.getFName()};
</#if> </#if>
</#list> </#list>

@ -25,7 +25,7 @@
<el-submenu index="${uuid()}" > <el-submenu index="${uuid()}" >
<template slot="title"> <template slot="title">
<i class="el-icon-help"></i> <i class="el-icon-help"></i>
<span slot="title">开发设置</span> <span slot="title">核心设置</span>
</template> </template>
${print('<#if token.hasRes("DEV_PROFILES")>')} ${print('<#if token.hasRes("DEV_PROFILES")>')}
<el-menu-item index="${uuid()}" @click="addTab({title: '系统配置', name: 'profiles', url: '${r'${context}'}/wsys/profiles.htm'})">系统配置</el-menu-item> <el-menu-item index="${uuid()}" @click="addTab({title: '系统配置', name: 'profiles', url: '${r'${context}'}/wsys/profiles.htm'})">系统配置</el-menu-item>
@ -48,10 +48,10 @@
<span slot="title">监控运行</span> <span slot="title">监控运行</span>
</template> </template>
${print('<#if token.hasRes("OBS_SCHEDULE")>')} ${print('<#if token.hasRes("OBS_SCHEDULE")>')}
<el-menu-item index="${uuid()}" @click="addTab({title: '调度监控', name: 'schedule', url: '${r'${context}'}/wsys/schedule.htm'})">调度监控</el-menu-item> <el-menu-item index="${uuid()}" @click="addTab({title: '调度监控', name: 'schedule', url: '${r'${context}'}/wmnt/schedule.htm'})">调度监控</el-menu-item>
${print('</#if>')} ${print('</#if>')}
${print('<#if token.hasRes("OBS_LOG_ERR")>')} ${print('<#if token.hasRes("OBS_LOG_ERR")>')}
<el-menu-item index="${uuid()}" @click="addTab({title: '错误日志', name: 'logErr', url: '${r'${context}'}/wsys/logErr.htm'})">错误日志</el-menu-item> <el-menu-item index="${uuid()}" @click="addTab({title: '错误日志', name: 'logErr', url: '${r'${context}'}/wmnt/logErr.htm'})">错误日志</el-menu-item>
${print('</#if>')} ${print('</#if>')}
</el-submenu> </el-submenu>
${print('</#if>')} ${print('</#if>')}

@ -134,7 +134,7 @@
mixins: [mixin], mixins: [mixin],
el: "#app", el: "#app",
data: { data: {
module: 'wsys', module: 'wmnt',
target: 'logErr', target: 'logErr',
vm: {//条件及分页参数 vm: {//条件及分页参数
logErrType: null, logErrType: null,

@ -78,7 +78,7 @@
mixins: [mixin], mixins: [mixin],
el: "#app", el: "#app",
data: { data: {
module: 'wsys', module: 'wmnt',
target: 'schedule', target: 'schedule',
vm: {//条件及分页参数 vm: {//条件及分页参数
taskId: null, taskId: null,
Loading…
Cancel
Save

Powered by TurnKey Linux.