package tech.easyflow.common.analyticaldb.core;

import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import tech.easyflow.common.analyticaldb.page.AnalyticalDBPageRequest;
import tech.easyflow.common.analyticaldb.page.AnalyticalDBPageResult;

import java.util.List;

public interface AnalyticalDBOperations {

    boolean available();

    void assertAvailable();

    <T> List<T> query(String sql, RowMapper<T> rowMapper, Object... args);

    <T> T queryOne(String sql, Class<T> requiredType, Object... args);

    <T> T queryOne(String sql, RowMapper<T> rowMapper, Object... args);

    <T> List<T> queryForList(String sql, Class<T> elementType, Object... args);

    int update(String sql, Object... args);

    <T> int[][] batchUpdate(String sql, List<T> items, int batchSize, ParameterizedPreparedStatementSetter<T> setter);

    <T> AnalyticalDBPageResult<T> page(String countSql,
                                       Object[] countArgs,
                                       String dataSql,
                                       Object[] dataArgs,
                                       AnalyticalDBPageRequest pageRequest,
                                       RowMapper<T> rowMapper);
}
