Commit 1bf8e4b6 authored by yanzg's avatar yanzg

1.3版本修改,增加删除功能

parent 0cb7ca51
......@@ -482,13 +482,9 @@ public class TableStruct {
*/
private SqlData releaseSqlUpdate() {
// 生成添加的SQL语句
String text = SQL_UPDATE.replace(CODE_TABLE, this.name);
SqlData sql = new SqlData(UPDATE, text);
sql.setSqlType(SQL_TYPE_UPDATE);
TableFieldVo key = this.getKey();
SqlData sql = getUpdateSql(UPDATE, SQL_TYPE_UPDATE);
// 主键字段操作
sql.addCode(CODE_FIELD, String.format(CODE_UPDATE_PRIMARY, key.name, key.name));
TableFieldVo key = this.getKey();
sql.addConst(key.inputName, String.format(CODE_WHERE_EQUALS_PARA, key.name));
// 增加普通代码片段字段
......@@ -500,10 +496,6 @@ public class TableStruct {
);
}
// 添加删除字段
// addWhereRemove(sql);
addUpdateRemoveField(sql);
addUpdateVersionField(sql);
// 添加版本号条件
if (getVersion() != null) {
sql.addConst(getVersion().inputName, String.format(CODE_WHERE_EQUALS_PARA, getVersion().name));
......@@ -519,14 +511,7 @@ public class TableStruct {
private SqlData releaseSqlRemove() {
TableFieldVo remove = this.getRemove();
if (remove != null) {
// 生成添加的SQL语句
String text = SQL_UPDATE.replace(CODE_TABLE, this.name);
SqlData sql = new SqlData(REMOVE, text);
sql.setSqlType(SQL_TYPE_REMOVE);
// 设置删除字段标记
addUpdateRemoveField(sql);
// 增加版本号字段的值
addUpdateVersionField(sql);
SqlData sql = getUpdateSql(REMOVE, SQL_TYPE_REMOVE);
// 设置删除时需要修改的字段的值
for (TableFieldVo field : this.getFieldActionList(FIELD_REMOVE_UPDATE)) {
sql.addParaConst(field.inputName,
......@@ -545,6 +530,22 @@ public class TableStruct {
}
}
private SqlData getUpdateSql(String sqlName, int sqlType) {
// 生成添加的SQL语句
String text = SQL_UPDATE.replace(CODE_TABLE, this.name);
SqlData sql = new SqlData(sqlName, text);
sql.setSqlType(SQL_TYPE_REMOVE);
TableFieldVo key = this.getKey();
// 主键字段操作
sql.addCode(CODE_FIELD, String.format(CODE_UPDATE_PRIMARY, key.name, key.name));
// 设置删除字段标记
addUpdateRemoveField(sql);
// 增加版本号字段的值
addUpdateVersionField(sql);
return sql;
}
private SqlData releaseSqlQuery(String sqlName, int sqlType) {
// 生成添加的SQL语句
String text = SQL_LOAD.replace(CODE_TABLE, this.name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment