package com.cheng.blzb.ui.fragment.home.zzdb

import androidx.lifecycle.MutableLiveData
import com.cheng.blzb.bean.ZZDBInfoEntity
import com.cheng.blzb.net.ApiFactory
import com.example.base.extensions.toast
import com.example.base.utils.L
import com.example.base.viewmodel.BaseViewModel

class ZZDBViewModel: BaseViewModel() {
    val listLiveData = MutableLiveData<List<ZZDBInfoEntity>>()

    fun getAgencyList(page: Int, name: String) {
        launchOnUiTryCatch({
            val params = mutableMapOf<String, String>()
            params["page"] = "$page"
            params["size"] = "20"
            params["name"] = name
            val response = ApiFactory.apiService.getAgencyList(params)
            if (response.status) {
                listLiveData.postValue(response.data.items)
            } else toast(response.message, true)
        }, {
            setError(it)
            L.d(it)
        })
    }
}