package cn.muchinfo.rma.global.database

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import cn.muchinfo.rma.global.dao.BannerDao
import cn.muchinfo.rma.global.dao.EnumDao
import cn.muchinfo.rma.global.dao.ErrorCodeDao
import cn.muchinfo.rma.global.dao.GoodsInfoDao
import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
import cn.muchinfo.rma.global.data.database.BannerEntity
import cn.muchinfo.rma.global.data.database.EnumDicEntity
import cn.muchinfo.rma.global.data.database.ErrorCodeEntity
import com.blankj.utilcode.util.Utils

@Database(
    entities = [GoodsInfo::class, BannerEntity::class, ErrorCodeEntity::class, EnumDicEntity::class],
    version = 1,
    exportSchema = false
)
abstract class DataBase : RoomDatabase() {

    abstract fun bannerDao(): BannerDao

    abstract fun goodsInfoDao(): GoodsInfoDao

    abstract fun errorCodeDao(): ErrorCodeDao

    abstract fun enumsDicDao(): EnumDao

    companion object {
        fun getInstance() = SingletonHolder.INSTANCE
    }

    private object SingletonHolder {
        val INSTANCE = Room.databaseBuilder(
            Utils.getApp(),
            DataBase::class.java,
            "db_goods_info"
        )
            .allowMainThreadQueries()
            .build()
    }

}