package xn.xxp.room;

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

import com.blankj.utilcode.util.Utils;

import xn.xxp.room.bean.DeviceConfig;
import xn.xxp.room.bean.Face;
import xn.xxp.room.bean.LabConfig;
import xn.xxp.room.bean.NoticeSummary;
import xn.xxp.room.dao.DeviceConfigDao;
import xn.xxp.room.dao.FaceDao;
import xn.xxp.room.dao.LabConfigDao;
import xn.xxp.room.dao.NoticeSummaryDao;

@Database(version = 1, entities = {Face.class, DeviceConfig.class, LabConfig.class, NoticeSummary.class})
public abstract class RoomTool extends RoomDatabase {
    private static RoomTool INSTANCE;

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

    public abstract FaceDao faceDao();

    public abstract DeviceConfigDao deviceConfigDao();

    public abstract LabConfigDao labConfigDao();

    public abstract NoticeSummaryDao noticeSummaryDao();
}
