Commit ac97711f authored by yanzg's avatar yanzg

压缩视频

parent cbc824d5
...@@ -168,9 +168,20 @@ public class SqlData { ...@@ -168,9 +168,20 @@ public class SqlData {
* @return * @return
*/ */
public SqlData add(Class<?> clsModel, String tag) { public SqlData add(Class<?> clsModel, String tag) {
return this.add(clsModel, tag, false);
}
/**
* 按照一种类型添加SQL语句
*
* @param clsModel 实体
* @param tag 标签
* @return
*/
public SqlData add(Class<?> clsModel, String tag, boolean removeFlag) {
// 生成表结构 // 生成表结构
TableStruct table = new TableStruct(StringHelper.EMPTY, clsModel); TableStruct table = new TableStruct(StringHelper.EMPTY, clsModel);
table.addWhereExtend(this, tag); table.addWhereExtend(this, tag, removeFlag);
return this; return this;
} }
......
...@@ -557,7 +557,7 @@ public class TableStruct { ...@@ -557,7 +557,7 @@ public class TableStruct {
* @return 生成的语句 * @return 生成的语句
*/ */
private void addWhereField(SqlData sql, String tag, boolean isRemove) { private void addWhereField(SqlData sql, String tag, boolean isRemove) {
addWhereBase(sql, tag, isRemove); addWhereBase(sql, tag, isRemove, false);
// 查询时,不能查询到非删除的字段 // 查询时,不能查询到非删除的字段
addWhereRemove(sql); addWhereRemove(sql);
} }
...@@ -568,12 +568,12 @@ public class TableStruct { ...@@ -568,12 +568,12 @@ public class TableStruct {
* @param sql 需要扩展的SQL语句 * @param sql 需要扩展的SQL语句
* @param tag 扩展标签 * @param tag 扩展标签
*/ */
public void addWhereExtend(SqlData sql, String tag) { public void addWhereExtend(SqlData sql, String tag, boolean removeHistory) {
addWhereBase(sql, tag, false); addWhereBase(sql, tag, false, removeHistory);
} }
private void addWhereBase(SqlData sql, String tag, boolean isRemove) { private void addWhereBase(SqlData sql, String tag, boolean isRemove, boolean removeHistory) {
addWhereFieldCommon(sql, this.getKey(), tag); addWhereFieldCommon(sql, this.getKey(), tag, removeHistory);
// Where条件包含的字段 // Where条件包含的字段
List<TableFieldVo> fields; List<TableFieldVo> fields;
...@@ -586,24 +586,30 @@ public class TableStruct { ...@@ -586,24 +586,30 @@ public class TableStruct {
} }
// 添加普通的Where条件 // 添加普通的Where条件
for (TableFieldVo field : fields) { for (TableFieldVo field : fields) {
addWhereFieldCommon(sql, field, tag); addWhereFieldCommon(sql, field, tag, removeHistory);
} }
} }
private void addWhereFieldCommon(SqlData sql, TableFieldVo field, String tag) { private void addWhereFieldCommon(SqlData sql, TableFieldVo field, String tag, boolean removeHistory) {
addWhereFieldNotExtend(sql, field.inputName, String.format(DaoConst.CODE_WHERE_EQUALS, tag, field.name, DaoConst.CODE_PARA)); addWhereFieldNotExtend(sql, field.inputName, String.format(DaoConst.CODE_WHERE_EQUALS, tag, field.name, DaoConst.CODE_PARA), removeHistory);
// 添加in条件 // 添加in条件
String sqlIn = String.format(DaoConst.CODE_WHERE_IN, tag, field.name, DaoConst.CODE_PARA); String sqlIn = String.format(DaoConst.CODE_WHERE_IN, tag, field.name, DaoConst.CODE_PARA);
if (field.inputLName.endsWith(DaoConst.CODE_WHERE_IN_END)) { if (field.inputLName.endsWith(DaoConst.CODE_WHERE_IN_END)) {
addWhereFieldNotExtend(sql, field.inputName + DaoConst.CODE_WHERE_IN_END_ES, sqlIn); addWhereFieldNotExtend(sql, field.inputName + DaoConst.CODE_WHERE_IN_END_ES, sqlIn, removeHistory);
} else { } else {
addWhereFieldNotExtend(sql, field.inputName + DaoConst.CODE_WHERE_IN_END, sqlIn); addWhereFieldNotExtend(sql, field.inputName + DaoConst.CODE_WHERE_IN_END, sqlIn, removeHistory);
} }
} }
private void addWhereFieldNotExtend(SqlData sql, String inputName, String sqlWhere) { private void addWhereFieldNotExtend(SqlData sql, String inputName, String sqlWhere, boolean removeHistory) {
if (sql.getField(inputName) == null) { SqlDataField field = sql.getField(inputName);
// 添加等于条件 if (field == null) {
// 添加新的条件
sql.add(inputName, sqlWhere);
} else if (removeHistory) {
// 删除历史条件
sql.removeField(inputName);
// 添加新的条件
sql.add(inputName, sqlWhere); sql.add(inputName, sqlWhere);
} }
} }
......
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