package com.tofly.ghrq_route.module.emergencyHandle;

import com.tofly.data.sql.dao.DaoSession;
import com.tofly.data.sql.dao.EmergencyOverDataDao;
import com.tofly.ghrq_route.module.emergencyHandle.domain.EmergencyOverData;
import com.tofly.ghrq_route.module.sqlite.DBDaoHelper;

public class EmergencyDaoHelper {

    private static EmergencyDaoHelper ourInstance = new EmergencyDaoHelper();

    public static EmergencyDaoHelper getInstance() {
        return ourInstance;
    }

    private DBDaoHelper dbDaoHelper;
    private DaoSession daoSession;

    private EmergencyDaoHelper() {
        dbDaoHelper = DBDaoHelper.getInstance();
        daoSession = dbDaoHelper.getDaoSession();
    }

    /**
     * EmergencyOverDataDao
     */

    /**
     * 根据id查询应急处理到位情况
     * @param emergencyId 应急调度id
     * @return 查询到的应急调度
     */
    public EmergencyOverData getEmergencyOverData(String emergencyId) {
        EmergencyOverDataDao emergencyOverDataDao = daoSession.getEmergencyOverDataDao();
        return emergencyOverDataDao.load(emergencyId);
    }

    /**
     * 插入一个新的或者更新已存在的应急处理到位情况
     * @param overData 新的或者需要更新的应急处理到位情况
     * @return 数据表中的rowid
     */
    public void insertOrUpdateEmergencyOverData(EmergencyOverData overData) {
        daoSession.insertOrReplace(overData);
    }

    /**
     * 删除已存在的应急处理到位情况
     * @param overData 要删除的应急处理到位情况
     * @return 数据表中的rowid
     */
    public void deleteSavedEmergencyOverData(EmergencyOverData overData) {
        daoSession.delete(overData);
    }

}
