package com.module.backstage.repo

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import com.module.pay.service.HomeApiService
import com.quyunshuo.androidbaseframemvvm.base.utils.SpUtils
import com.quyunshuo.androidbaseframemvvm.common.bean.ProductDataBean
import com.quyunshuo.androidbaseframemvvm.common.constant.MMKVName
import javax.inject.Inject

/**
 * HomeFragment的数据仓库层
 *
 * @author Qu Yunshuo
 * @since 2021/8/5 10:59 下午
 */
class ShowProductFragmentRepo @Inject constructor() : BaseRepository() {

    @Inject
    lateinit var mApi: com.module.pay.service.HomeApiService
    fun getPriceData(): ArrayList<ProductDataBean> {
        //设置adapter
        val productStr = SpUtils.getString(MMKVName.PRODUCT_DATA, "")
        val list: ArrayList<ProductDataBean> = Gson().fromJson(
            productStr,
            object : TypeToken<ArrayList<ProductDataBean?>?>() {}.type
        )
        return list
    }

}