pull/32/head
gedoor 6 years ago
parent f5045bdc08
commit d1aab66034
  1. 18
      app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt

@ -13,31 +13,31 @@ interface ReplaceRuleDao {
@Query("SELECT * FROM ${DbTable.replace_rules} ORDER BY sortOrder ASC")
fun observeAll(): DataSource.Factory<Int, ReplaceRule>
@Query("SELECT id FROM replace_rules ORDER BY sortOrder ASC")
@Query("SELECT id FROM ${DbTable.replace_rules} ORDER BY sortOrder ASC")
fun observeAllIds(): LiveData<List<Int>>
@get:Query("SELECT MAX(sortOrder) FROM replace_rules")
@get:Query("SELECT MAX(sortOrder) FROM ${DbTable.replace_rules}")
val maxOrder: Int
@get:Query("SELECT * FROM replace_rules ORDER BY sortOrder ASC")
@get:Query("SELECT * FROM ${DbTable.replace_rules} ORDER BY sortOrder ASC")
val all: List<ReplaceRule>
@get:Query("SELECT * FROM replace_rules WHERE isEnabled = 1 ORDER BY sortOrder ASC")
@get:Query("SELECT * FROM ${DbTable.replace_rules} WHERE isEnabled = 1 ORDER BY sortOrder ASC")
val allEnabled: List<ReplaceRule>
@Query("SELECT * FROM replace_rules WHERE id = :id")
@Query("SELECT * FROM ${DbTable.replace_rules} WHERE id = :id")
fun findById(id: Int): ReplaceRule?
@Query("SELECT * FROM replace_rules WHERE id in (:ids)")
@Query("SELECT * FROM ${DbTable.replace_rules} WHERE id in (:ids)")
fun findByIds(vararg ids: Int): List<ReplaceRule>
@Query("SELECT * FROM replace_rules WHERE isEnabled = 1 AND scope LIKE '%' || :scope || '%'")
@Query("SELECT * FROM ${DbTable.replace_rules} WHERE isEnabled = 1 AND scope LIKE '%' || :scope || '%'")
fun findEnabledByScope(scope: String): List<ReplaceRule>
@get:Query("SELECT COUNT(*) - SUM(isEnabled) FROM replace_rules")
@get:Query("SELECT COUNT(*) - SUM(isEnabled) FROM ${DbTable.replace_rules}")
val summary: Int
@Query("UPDATE replace_rules SET isEnabled = :enable")
@Query("UPDATE ${DbTable.replace_rules} SET isEnabled = :enable")
fun enableAll(enable: Boolean)
@Insert(onConflict = OnConflictStrategy.REPLACE)

Loading…
Cancel
Save