package com.zj365.health.vm

import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONObject
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.common.util.CommonUtils
import com.xty.network.model.BloodHistoryNewBean
import com.xty.network.model.BloodLipidAdjustBean
import com.xty.network.model.PaingBean
import com.xty.network.model.RespBody

class BloodLipidAdjustRecordsVm : BaseVm() {

    val  bloodLipidAdjustRecord  by lazy{ MutableLiveData<RespBody<PaingBean<BloodLipidAdjustBean>>>() }

    val deleteBloodFatData by lazy { MutableLiveData<RespBody<Any>>() }

    fun getBloodLipidRecord(pageNum: Int){
        startHttp {
            var json = JSONObject()
            json.put("pageNum",pageNum)
            json.put("pageSize", Const.PAGE_SIZE)
            json.put("userId",CommonUtils.getMyUserId())
            var response = apiInterface().getBloodLipidAdjustRecord(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(bloodLipidAdjustRecord,nowData)


        }
    }

    fun deleteBloodFatDataRequest(list: MutableList<BloodLipidAdjustBean>) {
        startHttp {
            var ids = ""
            list.forEachIndexed { _, bloodSugarNewbean ->
                ids += "${bloodSugarNewbean.id},"
            }
            val deleteDbpCalibration = apiInterface().deleteBloodFatRecord(ids)
            deleteDbpCalibration.getCodeStatus(deleteBloodFatData, nowData)
        }
    }

}