18034727885
2026-06-26 253f680fb9666751e0f9a8e5e8f2f9e3eb1894e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.example.smart.ui.projectevent
 
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.basecore.base.BaseContextViewModel
import com.example.basecore.net.http.Result
import com.example.basecore.util.LogUtils
import com.example.smart.reqeust.RetrofitClient
import com.example.smart.ui.projectevent.bean.SystemTreeBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
 
 
class ProjectProblemViewModel : BaseContextViewModel() {
    val systemTreeBean = MutableLiveData<List<SystemTreeBean>>()
 
 
    fun callSystemTree(id: String, fail: (String) -> Unit) {
        viewModelScope.launch(Dispatchers.Main) {
            val result = safeCall { execute(RetrofitClient.api.callSystemTree(id)) }
            if (result is Result.Success) {
                systemTreeBean.value = result.data.children
                LogUtils.e(systemTreeBean.value.toString())
            } else if (result is Result.Error) {
                fail(result.exception.message ?: "未知错误")
            }
        }
    }
 
 
}