| | |
| | | package cn.flightfeather.thirdappmodule.repository |
| | | |
| | | import cn.flightfeather.thirdappmodule.bean.entity.Domainitem |
| | | import cn.flightfeather.thirdappmodule.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdappmodule.common.net.ResultObserver |
| | | import cn.flightfeather.thirdappmodule.common.net.RetrofitFactory |
| | | import cn.flightfeather.thirdappmodule.httpservice.CommonService |
| | | import cn.flightfeather.thirdappmodule.httpservice.DomainItemService |
| | | import cn.flightfeather.thirdappmodule.model.enumreation.MediaFileType |
| | | import cn.flightfeather.thirdappmodule.repository.dao.MediaTypeAliasDao |
| | | import io.reactivex.schedulers.Schedulers |
| | |
| | | * Date: 2020/4/23 |
| | | */ |
| | | class CommonRepository { |
| | | companion object { |
| | | @JvmStatic |
| | | val instance: CommonRepository by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { CommonRepository()} |
| | | } |
| | | private val mediaTypeAliasDao = MediaTypeAliasDao() |
| | | val retrofit = RetrofitFactory.instance.retrofit |
| | | |
| | | fun upLoadCrashInfo(accountName: String, file: File, resultCallBack: ResultCallBack<Boolean>) { |
| | | val builder = MultipartBody.Builder() |
| | |
| | | |
| | | /** |
| | | * 获取“任意拍”模块展示的图片类型 |
| | | * @date 2025.7.1 修改为从服务端远程获取,并修改返回类型 |
| | | */ |
| | | fun getMediaFileTypes(sceneTypeId: Int, resultCallBack: ResultCallBack<List<MediaFileType>>) { |
| | | resultCallBack.onSuccess(MediaFileType.getList(sceneTypeId)) |
| | | // resultCallBack.onSuccess(MediaFileType.getList(sceneTypeId)) |
| | | |
| | | val service = retrofit.create(DomainItemService::class.java).getMediaFileType(sceneTypeId) |
| | | |
| | | RetrofitFactory.executeResult(service, object : ResultObserver<Map<String?, String?>>() { |
| | | override fun onSuccess(result: Map<String?, String?>?) { |
| | | val res = mutableListOf<MediaFileType>() |
| | | result?.forEach { (t, u) -> |
| | | if (t == null || u == null) return@forEach |
| | | res.add(MediaFileType(t.toInt(), u)) |
| | | } |
| | | resultCallBack.onSuccess(res) |
| | | } |
| | | |
| | | override fun onFailure(e: Throwable, isNetWorkError: Boolean) { |
| | | resultCallBack.onFailure() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param sceneTypeId 场景id |
| | | * @param mediaFileType 媒体文件类型id |
| | | */ |
| | | fun getAlias(sceneTypeId: Int, mediaFileType: MediaFileType, resultCallBack: ResultCallBack<String>) { |
| | | fun getAlias(sceneTypeId: Int, mediaFileType: Int, resultCallBack: ResultCallBack<String>) { |
| | | val dbService = mediaTypeAliasDao.getAlias(sceneTypeId, mediaFileType) |
| | | .map { Response.success(it) } |
| | | |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 根据值域类别名称,获取具体的选项 |
| | | */ |
| | | fun getDomainItem(name: String, resultCallBack: ResultCallBack<ArrayList<Domainitem>>) { |
| | | val service = retrofit.create(DomainItemService::class.java).getItemByName(name) |
| | | |
| | | RetrofitFactory.executeResult(service, object : ResultObserver<ArrayList<Domainitem>>() { |
| | | override fun onSuccess(result: ArrayList<Domainitem>?) { |
| | | resultCallBack.onSuccess(result) |
| | | } |
| | | |
| | | override fun onFailure(e: Throwable, isNetWorkError: Boolean) { |
| | | resultCallBack.onFailure() |
| | | } |
| | | }) |
| | | } |
| | | } |