增加模糊查询下载任务的对象方法

pull/330/head
Bitter 6 years ago
parent 0b095b9b11
commit 5c15ba41dc
  1. 13
      Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
  2. 20
      Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
  3. 7
      Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java

@ -102,6 +102,19 @@ public abstract class DbEntity {
return util.findData(clazz, expression);
}
/**
* 模糊查询一组数据
* <code>
* DownloadEntity.findDatas(DownloadEntity.class, "downloadUrl like http://");
* </code>
*
* @return 没有数据返回null
*/
public static <T extends DbEntity> List<T> findDataByFuzzy(Class<T> clazz, String conditions) {
DelegateWrapper util = DelegateWrapper.getInstance();
return util.findDataByFuzzy(clazz, conditions);
}
/**
* 查询一行数据
* <code>

@ -355,6 +355,26 @@ class DelegateFind extends AbsDelegate {
return data;
}
/**
* 模糊查寻数据
*/
<T extends DbEntity> List<T> findDataByFuzzy(SQLiteDatabase db, Class<T> clazz, String conditions) {
db = checkDb(db);
if(TextUtils.isEmpty(conditions)){
throw new IllegalArgumentException("sql语句表达式不能为null或\"\"");
}
if(!conditions.toUpperCase().contains("LIKE")){
throw new IllegalArgumentException("sql语句表达式未包含LIEK");
}
String sql =
"SELECT rowid, * FROM " + CommonUtil.getClassName(clazz) + " WHERE "+conditions;
print(FIND_DATA, sql);
Cursor cursor = db.rawQuery(sql, null);
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(clazz, cursor) : null;
closeCursor(cursor);
close(db);
return data;
}
/**
* 查找表的所有数据
*/

@ -118,6 +118,13 @@ public class DelegateWrapper {
return mDManager.getDelegate(DelegateFind.class).findData(mDb, clazz, expression);
}
/**
* 模糊查寻数据
*/
<T extends DbEntity> List<T> findDataByFuzzy(Class<T> clazz, String conditions) {
return mDManager.getDelegate(DelegateFind.class).findDataByFuzzy(mDb, clazz, conditions);
}
/**
* 通过rowId判断数据是否存在
*/

Loading…
Cancel
Save