package com.navinfo.outdoor.room;

import android.content.Context;

import androidx.room.Database;

/**
 * 数据库插入
 */
public class InsertAndUpdateUtils {
    private static InsertAndUpdateUtils instance;

    public static InsertAndUpdateUtils getInstance() {
        if (instance == null) {
            instance = new InsertAndUpdateUtils();
        }
        return instance;
    }

    public String[] insertOrUpdate(Context mContext,PoiEntity... entities) {
        String[] ids = new String[entities.length];
        if (entities!=null) {
            PoiDatabase.getInstance(mContext).getPoiDao().insertPoiEntity(entities);
            for (int i = 0; i < entities.length; i++) {
                ids[i] = entities[i].getId();
            }
        }
        return ids;
    }

    public long[] insertOrUpdateChargingPile(Context mContext,ChargingPileEntity... entities) {
        long[] ids = new long[entities.length];
        if (entities!=null) {
            ids = PoiDatabase.getInstance(mContext).getChargingPileDao().insertChargingPileEntity(entities);
        }
        return ids;
    }
}
