feat: 优化代码

pull/133/head
kunfei 5 years ago
parent e117e54894
commit df14e99bf3
  1. 16
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 3
      app/src/main/java/io/legado/app/data/entities/BookProgress.kt
  3. 3
      app/src/main/java/io/legado/app/help/storage/SyncBookProgress.kt

@ -69,9 +69,19 @@ interface BookDao {
@Query("update books set `group` = :newGroupId where `group` = :oldGroupId") @Query("update books set `group` = :newGroupId where `group` = :oldGroupId")
fun upGroup(oldGroupId: Int, newGroupId: Int) fun upGroup(oldGroupId: Int, newGroupId: Int)
@get:Query("select bookUrl, durChapterIndex, durChapterPos from books") @get:Query("select bookUrl, durChapterIndex, durChapterPos, durChapterTime from books")
val allBookProgress: List<BookProgress> val allBookProgress: List<BookProgress>
@Query("update books set durChapterIndex = :durChapterIndex, durChapterPos = :durChapterPos where bookUrl = :bookUrl") @Query(
fun upBookProgress(bookUrl: String, durChapterIndex: Int, durChapterPos: Int) """
update books set durChapterIndex = :durChapterIndex, durChapterPos = :durChapterPos
where bookUrl = :bookUrl and durChapterTime < :durChapterTime
"""
)
fun upBookProgress(
bookUrl: String,
durChapterIndex: Int,
durChapterPos: Int,
durChapterTime: Int
)
} }

@ -3,5 +3,6 @@ package io.legado.app.data.entities
data class BookProgress( data class BookProgress(
val bookUrl: String, val bookUrl: String,
val durChapterIndex: Int, val durChapterIndex: Int,
var durChapterPos: Int var durChapterPos: Int,
var durChapterTime: Int
) )

@ -32,7 +32,8 @@ object SyncBookProgress {
App.db.bookDao().upBookProgress( App.db.bookDao().upBookProgress(
it.bookUrl, it.bookUrl,
it.durChapterIndex, it.durChapterIndex,
it.durChapterPos it.durChapterPos,
it.durChapterTime
) )
} }
} }

Loading…
Cancel
Save