This commit is contained in:
ocean 2025-09-10 18:58:33 +08:00
parent 32374b0961
commit c5c9785a96
2 changed files with 2 additions and 8 deletions

View File

@ -9,7 +9,7 @@ interface PdfDocumentDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrUpdate(document: PdfDocumentEntity)
//@Update 不会响应flow
@Update
suspend fun update(document: PdfDocumentEntity)
@ -37,6 +37,7 @@ interface PdfDocumentDao {
@Query("DELETE FROM pdf_documents WHERE filePath = :filePath")
suspend fun deleteByPath(filePath: String)
//@Query 会响应flow
@Query("UPDATE pdf_documents SET filePath = :newFilePath, fileName = :newName WHERE filePath = :oldFilePath")
suspend fun updateFilePathAndFileName(oldFilePath: String, newFilePath: String, newName: String)

View File

@ -43,13 +43,6 @@ class PdfRepository private constructor(context: Context) {
pdfDao.updateFilePathAndFileName(oldFilePath, newFilePath, newName)
}
// suspend fun updateFilePathAndFileName(filePath: String, newFilePath: String, newName: String) {
// val document = pdfDao.getByPath(filePath)?.copy(
// filePath = newFilePath, fileName = newName
// )
// document?.let { pdfDao.update(it) }
// }
suspend fun updateFavoriteStatus(filePath: String, isFavorite: Boolean) {
val document = pdfDao.getByPath(filePath)?.copy(
isFavorite = isFavorite,