package com.zj365.mime.vm

import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.network.model.LnvitationMessageListBean
import com.xty.network.model.PaingBean
import com.xty.network.model.RespBody
import org.json.JSONObject

class LnvitationMessageVm : BaseVm() {

    val inviteRecordData by lazy { MutableLiveData<RespBody<PaingBean<LnvitationMessageListBean>>>() }

    fun getInviteRecordRequest(
        pageNum: Int,
        id: String,
        orderByType: Int,
        year: String,
        month: String
    ) {
        startHttp {
            val json = JSONObject()
            json.put("pageNum", pageNum)
            json.put("pageSize", 20)
            json.put("id", id)
            json.put("orderSort", orderByType)
            if (!TextUtils.isEmpty(year)) {
                json.put("year", year)
            }
            if (!TextUtils.isEmpty(month)) {
                json.put("month", month)
            }
            val inviteRecord = apiInterface().getInviteRecord(
                retrofits.getRequestBody(
                    json.toString()
                )
            )
            inviteRecord.getCodeStatus(inviteRecordData, nowData)
        }
    }
}