/* * Copyright (C), 2018-2020 * Project: starter * FileName: ProcessDBAccess * Author: xx * Date: 2020/6/4 11:48 */ package com.fr.plugin.isgd.provider; import com.fanruan.api.log.LogKit; import com.fr.plugin.db.AbstractDBAccessProvider; import com.fr.plugin.isgd.dao.ReportIndexInfoDao; import com.fr.plugin.isgd.entity.ReportIndexInfoEntity; import com.fr.stable.db.accessor.DBAccessor; import com.fr.stable.db.action.DBAction; import com.fr.stable.db.dao.DAOContext; import com.fr.stable.db.dao.DAOProvider; import java.util.List; /** * 〈Function Description〉
* 〈ProcessDBAccess〉 * * @author xx * @since 1.0.0 */ public class ProcessDBAccess extends AbstractDBAccessProvider { private static DBAccessor accessor; public ProcessDBAccess() { } public static DBAccessor getAccessor() { return accessor; } public static void saveAll(List entities) { try { ProcessDBAccess.getAccessor().runDMLAction(new DBAction() { @Override public Boolean run(DAOContext daoContext) throws Exception { for (ReportIndexInfoEntity entity : entities) { (daoContext.getDAO(ReportIndexInfoDao.class)).addOrUpdate(entity); } return true; } }); } catch (Exception e) { LogKit.error(e.getMessage(), e); } } /** * @param entity */ public static void save(final ReportIndexInfoEntity entity) { try { getAccessor().runDMLAction(new DBAction() { @Override public Boolean run(DAOContext context) throws Exception { (context.getDAO(ReportIndexInfoDao.class)).addOrUpdate(entity); return true; } }); } catch (Exception e) { LogKit.error(e.getMessage(), e); } } @Override public DAOProvider[] registerDAO() { return new DAOProvider[]{ ReportIndexInfoDao.DAO }; } @Override public void onDBAvailable(DBAccessor dbAccessor) { accessor = dbAccessor; } }