package xn.hxp.room;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.blankj.utilcode.util.Utils;

import xn.hxp.room.bean.BaseConfig;
import xn.hxp.room.bean.cabinet.Cabinet;
import xn.hxp.room.bean.DeviceInfo;
import xn.hxp.room.bean.LabInfo;
import xn.hxp.room.bean.UserInfo;
import xn.hxp.room.bean.cabinet.CabinetDoor;
import xn.hxp.room.bean.cabinet.CabinetDoorAdmin;
import xn.hxp.room.bean.cabinet.CabinetDoorLock;
import xn.hxp.room.dao.BaseConfigDao;
import xn.hxp.room.dao.cabinet.CabinetDao;
import xn.hxp.room.dao.DeviceInfoDao;
import xn.hxp.room.dao.LabInfoDao;
import xn.hxp.room.dao.UserInfoDao;
import xn.hxp.room.dao.cabinet.CabinetDoorAdminDao;
import xn.hxp.room.dao.cabinet.CabinetDoorDao;
import xn.hxp.room.dao.cabinet.CabinetDoorLockDao;

@Database(entities = {
        DeviceInfo.class,
        LabInfo.class,
        UserInfo.class,
        BaseConfig.class,
        Cabinet.class,
        CabinetDoor.class,
        CabinetDoorAdmin.class,
        CabinetDoorLock.class
}, version = 1, exportSchema = false)
public abstract class RoomTool extends RoomDatabase {
    private static RoomTool INSTANCE;

    public static synchronized RoomTool getInstance() {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder(Utils.getApp(), RoomTool.class, "hxp2_db").allowMainThreadQueries().build();
        }
        return INSTANCE;
    }

    public abstract DeviceInfoDao deviceInfoDao();

    public abstract LabInfoDao labInfoDao();

    public abstract UserInfoDao userInfoDao();

    public abstract BaseConfigDao baseConfigDao();

    public abstract CabinetDao cabinetDao();

    public abstract CabinetDoorDao cabinetDoorDao();

    public abstract CabinetDoorAdminDao cabinetDoorAdminDao();

    public abstract CabinetDoorLockDao cabinetDoorLockDao();
}
