package com.zj365.health.vm

import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONArray
import com.alibaba.fastjson.JSONObject
import com.xty.base.vm.BaseVm
import com.xty.common.util.CommonUtils
import com.zj365.health.model.BloodLipidAdjustBean
import com.xty.network.model.CalibrationBean
import com.xty.network.model.RespBody

class BloodLipidAdjustVm : BaseVm() {

    val calibrationLive by lazy { MutableLiveData<RespBody<CalibrationBean>>() }

    fun submitBloodLipidAdjustData(list: MutableList<BloodLipidAdjustBean>) {
        // var jsonArray = JsonParser.parseString(Gson().toJson(list)).asJsonArray
        val jsonObject = JSONObject()
        jsonObject["userId"] = CommonUtils.getMyUserId()
        jsonObject["list"] = JSONArray(list as List<Any>)
        startHttp {
            val body = apiInterface().addBloodLipidAdjust(
                retrofits.getRequestBody(
                    jsonObject.toString()
                )
            )
            body.getCodeStatus(calibrationLive, nowData)
        }
    }
}