From e102578ebfc95c27aeb13dce13fb82af53a2bead Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 25 二月 2021 17:07:23 +0800
Subject: [PATCH] 1. 新增夜间施工查询界面 2. 新增夜间施工管理统计界面
---
app/src/main/java/cn/flightfeather/thirdapp/repository/dao/MediaFileDao.kt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/MediaFileDao.kt b/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/MediaFileDao.kt
index e9b7ff7..b7174b8 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/MediaFileDao.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/repository/dao/MediaFileDao.kt
@@ -1,9 +1,14 @@
package cn.flightfeather.thirdapp.repository.dao
+import cn.flightfeather.thirdapp.bean.entity.MediaFileCache
import cn.flightfeather.thirdapp.bean.entity.Mediafile
import cn.flightfeather.thirdapp.common.database.DbFactory
+import cn.flightfeather.thirdapp.common.database.FlatSaveInterface
+import cn.flightfeather.thirdapp.common.database.flatMapDbSaveResult
+import com.ping.greendao.gen.MediaFileCacheDao
import com.ping.greendao.gen.MediafileDao
import io.reactivex.Observable
+import org.greenrobot.greendao.AbstractDao
/**
* @author riku
@@ -70,4 +75,47 @@
true
}
}
+
+ /**
+ * 鑾峰彇缂撳瓨鐨勬枃浠�
+ */
+ fun getFileCache(url: String?): Observable<String> {
+ return DbFactory.getGreenDaoObservable().map {
+ val resultList = it.mediaFileCacheDao.queryBuilder()
+ .where(MediaFileCacheDao.Properties.Url.eq(url))
+ .list()
+ if (resultList.isNotEmpty()) {
+ resultList[0].path
+ } else {
+ ""
+ }
+ }
+ }
+
+ /**
+ * 淇濆瓨缂撳瓨鐨勬枃浠�
+ */
+ fun saveFileCache(url: String, localPath: String, thumbnailPath: String? = null) {
+ flatMapDbSaveResult(DbFactory.getInstance().mediaFileCacheDao,
+ object : FlatSaveInterface<MediaFileCache, Long> {
+ override fun onQuery(dao: AbstractDao<MediaFileCache, Long>): List<MediaFileCache> {
+ return dao.queryBuilder()
+ .where(MediaFileCacheDao.Properties.Url.eq(url))
+ .list()
+ }
+
+ override fun onUpdate(list: List<MediaFileCache>) {
+ list[0].apply {
+ path = localPath
+ }
+ }
+
+ override fun onInsert(): List<MediaFileCache> {
+ return listOf(MediaFileCache().apply {
+ this.url = url
+ this.path = localPath
+ })
+ }
+ })
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3