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/CommonRepository.kt | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/repository/CommonRepository.kt b/app/src/main/java/cn/flightfeather/thirdapp/repository/CommonRepository.kt
index b3d7970..40e8692 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/repository/CommonRepository.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/repository/CommonRepository.kt
@@ -1,12 +1,16 @@
package cn.flightfeather.thirdapp.repository
import cn.flightfeather.thirdapp.common.net.ResultCallBack
+import cn.flightfeather.thirdapp.common.net.ResultObserver
import cn.flightfeather.thirdapp.common.net.RetrofitFactory
import cn.flightfeather.thirdapp.httpservice.CommonService
+import cn.flightfeather.thirdapp.model.enumreation.MediaFileType
+import cn.flightfeather.thirdapp.repository.dao.MediaTypeAliasDao
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
+import retrofit2.Response
import java.io.File
/**
@@ -14,6 +18,7 @@
* Date: 2020/4/23
*/
class CommonRepository {
+ private val mediaTypeAliasDao = MediaTypeAliasDao()
fun upLoadCrashInfo(accountName: String, file: File, resultCallBack: ResultCallBack<Boolean>) {
val builder = MultipartBody.Builder()
@@ -28,6 +33,59 @@
.upLoadCrashInfo(accountName, partList)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.trampoline())
- .subscribe()
+ .subscribe({
+ resultCallBack.onSuccess(it.body())
+ }, {
+ resultCallBack.onFailure()
+ })
+ }
+
+
+ /**
+ * 鑾峰彇鈥滀换鎰忔媿鈥濇ā鍧楀睍绀虹殑鍥剧墖绫诲瀷
+ */
+ fun getMediaFileTypes(sceneTypeId: Int, resultCallBack: ResultCallBack<List<MediaFileType>>) {
+ resultCallBack.onSuccess(MediaFileType.getList(sceneTypeId))
+ }
+
+ /**
+ * 鑾峰彇濯掍綋鏂囦欢绫诲瀷鐨勫埆鍚�
+ * @param sceneTypeId 鍦烘櫙id
+ * @param mediaFileType 濯掍綋鏂囦欢绫诲瀷id
+ */
+ fun getAlias(sceneTypeId: Int, mediaFileType: MediaFileType, resultCallBack: ResultCallBack<String>) {
+ val dbService = mediaTypeAliasDao.getAlias(sceneTypeId, mediaFileType)
+ .map { Response.success(it) }
+
+ RetrofitFactory.executeResult(dbService, object : ResultObserver<String>() {
+ override fun onSuccess(result: String?) {
+ resultCallBack.onSuccess(result)
+ }
+
+ override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
+ resultCallBack.onFailure()
+ }
+ })
+ }
+
+ /**
+ * 鏇存柊濯掍綋鏂囦欢绫诲瀷鐨勫埆鍚�
+ * @param sceneTypeId 鍦烘櫙id
+ * @param mediaFileType 濯掍綋鏂囦欢绫诲瀷id
+ * @param alias 鍒悕
+ */
+ fun updateAlias(sceneTypeId: Int, mediaFileType: MediaFileType, alias: String, resultCallBack: ResultCallBack<Boolean>) {
+ val dbService = mediaTypeAliasDao.updateAlias(sceneTypeId, mediaFileType, alias)
+ .map { Response.success(it) }
+
+ RetrofitFactory.executeResult(dbService, object : ResultObserver<Boolean>() {
+ override fun onSuccess(result: Boolean?) {
+ resultCallBack.onSuccess(result)
+ }
+
+ override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
+ resultCallBack.onFailure()
+ }
+ })
}
}
\ No newline at end of file
--
Gitblit v1.9.3