package com.module.backstage.repo

import android.util.Log
import com.module.database.room.SZDatabase
import com.module.database.room.entity.WarringBean
import com.quyunshuo.androidbaseframemvvm.base.BaseApplication
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import java.lang.Error
import javax.inject.Inject

/**
 * HomeFragment的数据仓库层
 *
 * @author Qu Yunshuo
 * @since 2021/8/5 10:59 下午
 */
class ErrorStatFragmentRepo @Inject constructor() : BaseRepository() {
    private val warringDao = SZDatabase.getDatabase(BaseApplication.context).getWarringDao()
    private val TAG = "ErrorStatFragmentRepo"
    @Inject
    lateinit var mApi: com.module.pay.service.HomeApiService

    suspend fun getAllWarringData(): MutableList<WarringBean> {
      //  addWarringBean("")
        val all = warringDao.getAll()
        Log.d(TAG, "getAllWarringData: "+all)
        return all
    }

    suspend fun addWarringBean(thingError: String){
        warringDao.insert(WarringBean(
            time = System.currentTimeMillis(),
            thingError = thingError,
            remark = ""
        ))
    }

    suspend fun removeAllWarringData():Int {
        val result = warringDao.deleteAll()
        return result

    }

}