|
@@ -7,6 +7,7 @@ import com.framework.app.base.IRepository
|
|
|
import com.framework.mvvm.model.data.Data
|
|
|
import com.framework.mvvm.model.data.dataSource
|
|
|
import com.framework.mvvm.model.data.request
|
|
|
+import com.framework.mvvm.model.data.toDb
|
|
|
import com.framework.mvvm.model.db.AdmDatabase
|
|
|
import com.framework.mvvm.model.db.entity.ProjectEntity
|
|
|
import com.framework.mvvm.model.vo.FrameRequest
|
|
@@ -20,7 +21,7 @@ class FrameRepository(
|
|
|
return dataSource(
|
|
|
fromDb = { db.projectDao().getProjects() },
|
|
|
fromNt = { request { api.getFrame(request) } },
|
|
|
- isFromNt = {true},
|
|
|
+ isFromNt = { true },
|
|
|
onSuccess = { frame ->
|
|
|
val projects = frame.projects
|
|
|
val bafs = frame.buildingsAndFloors
|
|
@@ -45,5 +46,36 @@ class FrameRepository(
|
|
|
return db.projectDao().insProject(projects)
|
|
|
}
|
|
|
|
|
|
+ suspend fun requestDict(request: FrameRequest) {
|
|
|
+ toDb(
|
|
|
+ from = { api.getDefine(request) },
|
|
|
+ to = { define ->
|
|
|
+
|
|
|
+ val pipeConfig = define.pipeConfig
|
|
|
+ val infosConfig = define.infosConfig
|
|
|
+ val config = define.config
|
|
|
+ val m2dTypes = define.m2dTypes
|
|
|
+ val relConfig = define.relConfig
|
|
|
+ val system = define.dict.system
|
|
|
+ val equipment = define.dict.equipment
|
|
|
+ val relation = define.dict.relation
|
|
|
+ val major = define.dict.major
|
|
|
+
|
|
|
+ try {
|
|
|
+ db.pipeConfigDao().insConfigs(pipeConfig)
|
|
|
+ db.infosConfigDao().insConfigs(infosConfig) // wu
|
|
|
+ db.configDao().insConfigs(config)
|
|
|
+ db.m2dEquipDao().insM2ds(m2dTypes)
|
|
|
+ db.relConfigDao().insConfigs(relConfig)
|
|
|
+ db.systemDao().insSystems(system)
|
|
|
+ db.equipmentDao().insEquipments(equipment)
|
|
|
+ db.relationDictDao().insRelationDicts(relation)
|
|
|
+ db.majorDao().insMajors(major)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ Log.d("requestDict", e.message!!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
}
|