Commit ac97711f authored by yanzg's avatar yanzg

压缩视频

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