Commit 9535b246 authored by yanzg's avatar yanzg

压缩视频

parent b9385cbb
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
* *
* @author 颜佐光 * @author 颜佐光
*/ */
public interface SqlCond { public interface SqlCond<T extends SqlCond> {
/** /**
* 条件不满足 * 条件不满足
...@@ -29,14 +29,6 @@ public interface SqlCond { ...@@ -29,14 +29,6 @@ public interface SqlCond {
*/ */
int COND_TYPE_CODE_COND = 2; int COND_TYPE_CODE_COND = 2;
/**
* 判断字段是否相等
*
* @return
*/
boolean isField(String... field);
/** /**
* 获取字段值 * 获取字段值
* *
...@@ -62,4 +54,12 @@ public interface SqlCond { ...@@ -62,4 +54,12 @@ public interface SqlCond {
* @return * @return
*/ */
SqlCond copy(); SqlCond copy();
/**
* 判断条件是否相等
*
* @param cond
* @return
*/
boolean equals(T cond);
} }
...@@ -17,7 +17,7 @@ import java.util.Map; ...@@ -17,7 +17,7 @@ import java.util.Map;
* *
* @author 颜佐光 * @author 颜佐光
*/ */
public abstract class SqlCondBase implements SqlCond { public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> {
protected List<String> fields = new ArrayList<>(); protected List<String> fields = new ArrayList<>();
...@@ -34,26 +34,6 @@ public abstract class SqlCondBase implements SqlCond { ...@@ -34,26 +34,6 @@ public abstract class SqlCondBase implements SqlCond {
} }
} }
/**
* 判断字段是否相等
*
* @param toFields
* @return
*/
@Override
public boolean isField(String... toFields) {
Map<String, Boolean> fromFields = new HashMap<>();
for (String fromField : this.fields) {
String from = fromField.toLowerCase().replaceAll("_", "");
fromFields.put(from, true);
}
for (String toField : toFields) {
String to = toField.toLowerCase().replaceAll("_", "");
fromFields.remove(to);
}
return fromFields.isEmpty();
}
/** /**
* 获取字段值 * 获取字段值
* *
...@@ -139,4 +119,43 @@ public abstract class SqlCondBase implements SqlCond { ...@@ -139,4 +119,43 @@ public abstract class SqlCondBase implements SqlCond {
List<String> arr = codeMap.get(name); List<String> arr = codeMap.get(name);
arr.add(code); arr.add(code);
} }
/**
* 判断字段集合是否相等
*
* @param fromFields 来源字段
* @param toFields 目标字段
* @return
*/
protected static boolean eqaulsField(List<String> fromFields, List<String> toFields) {
Map<String, Boolean> mapField = new HashMap<>();
for (String fromField : fromFields) {
String from = fromField.toLowerCase().replaceAll("_", "");
mapField.put(from, true);
}
for (String toField : toFields) {
String to = toField.toLowerCase().replaceAll("_", "");
mapField.remove(to);
}
return mapField.isEmpty();
}
@Override
public boolean equals(Object to) {
if (to != null && to.getClass() == this.getClass()) {
this.equals((T) to);
}
return super.equals(to);
}
/**
* 判断条件是否相等
*
* @param cond
* @return
*/
@Override
public boolean equals(SqlCondBase cond) {
return SqlCondBase.eqaulsField(this.fields, cond.fields);
}
} }
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
* *
* @author 颜佐光 * @author 颜佐光
*/ */
public class SqlCondDefault extends SqlCondBase { public class SqlCondDefault extends SqlCondBase<SqlCondDefault> {
public SqlCondDefault(String... field) { public SqlCondDefault(String... field) {
this(Arrays.asList(field)); this(Arrays.asList(field));
......
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
* *
* @author 颜佐光 * @author 颜佐光
*/ */
public class SqlCondEquals extends SqlCondBase { public class SqlCondEquals extends SqlCondBase<SqlCondEquals> {
public Object val; public Object val;
...@@ -62,4 +62,15 @@ public class SqlCondEquals extends SqlCondBase { ...@@ -62,4 +62,15 @@ public class SqlCondEquals extends SqlCondBase {
SqlCondEquals cond = new SqlCondEquals(this.fields, this.val); SqlCondEquals cond = new SqlCondEquals(this.fields, this.val);
return cond; return cond;
} }
/**
* 判断条件是否相等
*
* @param cond
* @return
*/
@Override
public boolean equals(SqlCondEquals cond) {
return SqlCondBase.eqaulsField(this.fields, cond.fields) && StringHelper.compare(this.val, cond.val);
}
} }
...@@ -140,8 +140,20 @@ public class SqlData { ...@@ -140,8 +140,20 @@ public class SqlData {
* @return * @return
*/ */
public SqlDataField getField(String fieldName) { public SqlDataField getField(String fieldName) {
SqlCondDefault cond = new SqlCondDefault(fieldName);
return getField(cond);
}
/**
* 根据字段名称获取字段
*
* @param sqlCond
* @return
*/
public SqlDataField getField(SqlCond sqlCond) {
for (SqlDataField sqlDataField : this.sqlDataFields) { for (SqlDataField sqlDataField : this.sqlDataFields) {
if (sqlDataField.getCond().isField(fieldName)) { if (sqlDataField.getCond().equals(sqlCond)) {
return sqlDataField; return sqlDataField;
} }
} }
......
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