Former-commit-id: 80326574504daa927c5226e4e6b096d9124244f6
master
wangbingit@outlook.com 4 years ago
parent ec575773cf
commit fcf593c13c

@ -202,7 +202,6 @@ public class JavaFxApplication extends Application {
Dialog.showDictEdit(field);
break;
}
//refreshTable();
JavaFxApplication.this.mFields.getSelectionModel().clearSelection();
}
}
@ -577,7 +576,6 @@ public class JavaFxApplication extends Application {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
currentTable.setSys(newValue);
//refreshTable();
}
});
}
@ -590,10 +588,11 @@ public class JavaFxApplication extends Application {
private void addField() {
if (currentTable != null && mFields != null) {
List<Field> fields = currentTable.getFields();
String fieldName = projectManager.getNewFieldName(fields);
System.out.println("新增字段-" + fieldName + "成功!");
this.mFields.getSelectionModel().select(fields.size() - 1);
//refreshTable();
int i = projectManager.getNewFieldName(fields);
Field field = fields.get(i);
System.out.println("新增字段-" + field.getFieldName() + "成功!");
this.mFields.getSelectionModel().select(i);
this.mFields.getFocusModel().focus(i);
}
}
@ -603,7 +602,6 @@ public class JavaFxApplication extends Application {
if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
currentTable.getFields().remove(selectedIndex);
mFields.getSelectionModel().clearSelection();
//refreshTable();
}
}
@ -641,7 +639,7 @@ public class JavaFxApplication extends Application {
return level;
}
private void loadingModule() {
private void loadingModule() {
if (currentMD == null) {
return;
}
@ -656,7 +654,7 @@ public class JavaFxApplication extends Application {
mDetail.getChildren().add(gridPane);
}
if (mFields != null && mFields.getItems() != null) {
mFields.getItems().clear();
mFields.setItems(null);
}
}
@ -685,7 +683,7 @@ public class JavaFxApplication extends Application {
mDetail.getChildren().add(gridPane);
}
if (mFields != null && mFields.getItems() != null) {
mFields.getItems().clear();
mFields.setItems(null);
}
}
@ -738,7 +736,6 @@ public class JavaFxApplication extends Application {
if (newValue.toUpperCase().endsWith("_TYPE")) {
field.setFieldType(FieldType.Dict);
}
//refreshTable();
}
});
@ -839,7 +836,6 @@ public class JavaFxApplication extends Application {
currentTable.getFields().add(i2, t1);
currentTable.getFields().remove(i2 + 1);
}
//refreshTable();
}
event.setDropCompleted(true);
event.consume();

@ -237,7 +237,7 @@ public class ProjectManager {
} while (true);
}
public String getNewFieldName(List<Field> fields) {
public int getNewFieldName(List<Field> fields) {
String base = "NEW_FIELD";
String name = base;
int k = 0;
@ -266,7 +266,7 @@ public class ProjectManager {
}
}
fields.add(j, field);
return name;
return j;
}
} while (true);
}

@ -243,7 +243,7 @@ public class XmlManager {
Element field = doc.createElement("field");
field.setAttribute("fieldName", f.getFieldName());
field.setAttribute("fieldType", f.getFieldType().name());
field.setAttribute("fieldLength", f.getFieldLength().toString());
field.setAttribute("fieldLength", String.valueOf(f.getFieldLength()));
field.setAttribute("fieldComment", f.getFieldComment());
field.setAttribute("defaultValue", f.getDefaultValue());
field.setAttribute("isPrimaryKey", String.valueOf(f.getIsPrimaryKey()));

@ -1,7 +1,9 @@
package xyz.wbsite.dbtool.javafx.po;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import org.springframework.util.StringUtils;
import xyz.wbsite.dbtool.javafx.tool.Tool;
@ -28,10 +30,6 @@ public class Field extends Table {
*
*/
private FieldType fieldType = FieldType.String_var50;
/**
*
*/
private int fieldLength = 0;
/**
*
@ -93,7 +91,7 @@ public class Field extends Table {
sb.append("\"");
value = sb.toString();
} else {
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > getFieldLength() ? getFieldLength() : this.fieldComment.length()) + "\"";
}
}
@ -111,12 +109,12 @@ public class Field extends Table {
sb.append("\"");
value = sb.toString();
} else {
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > getFieldLength() ? getFieldLength() : this.fieldComment.length()) + "\"";
}
}
} else if (fieldType.name().equals("String_var")) {
int len = fieldLength;
int len = getFieldLength();
if (StringUtils.isEmpty(this.fieldComment)) {
StringBuilder sb = new StringBuilder("");
sb.append("\"");
@ -124,7 +122,7 @@ public class Field extends Table {
sb.append("\"");
value = sb.toString();
} else {
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > getFieldLength() ? getFieldLength() : this.fieldComment.length()) + "\"";
}
} else if (fieldType.name().matches("Boolean")) {
@ -181,6 +179,21 @@ public class Field extends Table {
return "set" + Tool.ABB2Abb(this.fieldName);
}
// 字段长度
private final IntegerProperty fieldLength = new SimpleIntegerProperty();
public IntegerProperty fieldLengthProperty() {
return fieldLength;
}
public int getFieldLength() {
return fieldLength.get();
}
public void setFieldLength(int fieldLength) {
this.fieldLength.set(fieldLength);
}
// isUnique
private final BooleanProperty isUnique = new SimpleBooleanProperty();
@ -227,14 +240,6 @@ public class Field extends Table {
this.fieldType = fieldType;
}
public Integer getFieldLength() {
return fieldLength;
}
public void setFieldLength(Integer fieldLength) {
this.fieldLength = fieldLength;
}
public String getFieldComment() {
return fieldComment;
}

@ -54,6 +54,23 @@ public class ${table.getCName()}ManagerImpl implements ${table.getCName()}Manage
if (response.hasError()) {
return response;
}
<#list table.fields as field>
<#if field.isUnique>
{// ${field.fieldComment}唯一检查
${table.getCName()}FindRequest ${table.getFName()}FindRequest = new ${table.getCName()}FindRequest();
${table.getFName()}FindRequest.${field.setterName()}(request.${field.getterName()}());
${table.getCName()}FindResponse ${table.getFName()}FindResponse = this.find(${table.getFName()}FindRequest, token);
if (usersFindResponse.hasError()) {
response.addErrors(${table.getFName()}FindResponse.getErrors());
return response;
} else if (${table.getFName()}FindResponse.getTotalCount() > 0) {
response.addError(ErrorType.UNIQUENESS_ERROR, "[${field.getFName()}]${field.fieldComment}已存在,请检查!");
return response;
}
}
</#if>
</#list>
<#if table.sys>
long id = IDgenerator.nextId();

@ -1,30 +1,25 @@
public class TestTool {
public static void main(String[] args) {
String s = "INSERT INTO DPT_RY_JBXX (\"RYBH\", \"GMSFHM\", \"XM\", \"XMPY\", \"CYM\", \"CYMPY\", \"YWX\", \"YWM\", \"ZJZL\", \"ZJHM\", \"BMCH\", \"BMCHPY\", \"XB\", \"MZ\", \"CSRQ\", \"CSSJ\", \"CSZMBH\", \"CSDQ\", \"CSQX\", \"CSXZ\", \"JGDQ\", \"JGQX\", \"JGXZ\", \"ZJXY\", \"ZZMM\", \"WHCD\", \"HYZK\", \"BYZK\", \"SG\", \"XX\", \"SF\", \"ZC\", \"ZW\", \"ZY\", \"ZYLB\", \"FWCS\", \"LXDH\", \"ZWSP\", \"SWRQ\", \"SWZMBH\", \"GJDQ\", \"HJQH\", \"HJZRQ\", \"HJXZ\", \"XXJB\", \"RYLB\", \"RYSX\", \"RYZZBH\", \"ZWBH\", \"DNABH\", \"DJR\", \"DJSJ\", \"DJDW\", \"XZZZRQ\", \"XZZQH\", \"XZZXZ\", \"DJDWMC\", \"DJRXM\", \"XGSJ\", \"XGR\", \"XGDW\", \"XGRXM\", \"XGDWMC\", \"HJQHMC\", \"XZZQHMC\", \"RYTBBS\", \"RYCJFS\", \"SJLY\", \"TZ\") VALUES ('R32059421702060001', 'null', 'null', NULL, NULL, NULL, NULL, NULL, NULL, 'null', NULL, NULL, 'null', NULL, 'null', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'null', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '126614', '2017-01-23 13:00:59', 'null', NULL, NULL, NULL, 'null', '王月干', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
System.out.println(s.replaceAll("'null'","NULL"));
// ArrayList<Table> tables = new ArrayList<>();
// {
// Table table = new Table();
// table.setTableName("NEW TABLE");
// tables.add(table);
// }
// {
// Table table = new Table();
// table.setTableName("NEW TABLE(1)");
// tables.add(table);
// }
// {
// Table table = new Table();
// table.setTableName("NEW TABLE2");
// tables.add(table);
// }
import xyz.wbsite.dbtool.javafx.po.Table;
import java.util.ArrayList;
public class TestTool {
public static void main(String[] args) {
ArrayList<Table> tables = new ArrayList<>();
{
Table table = new Table();
table.setTableName("NEW TABLE");
tables.add(table);
}
{
Table table = new Table();
table.setTableName("NEW TABLE(1)");
tables.add(table);
}
{
Table table = new Table();
table.setTableName("NEW TABLE2");
tables.add(table);
}
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.