package com.keyware.shandan.datasource.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.keyware.shandan.bianmu.entity.DirectoryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.session.ResultHandler;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 动态数据源mapper
 * </p>
 *
 * @author Administrator
 * @since 2021/5/31
 */
@Mapper
public interface DynamicDatasourceMapper {

    @Select("${sql}")
    @ResultType(HashMap.class)
    List<Map<String, Object>> list(String sqlStr);

    @Select("${sql}")
    Page<HashMap<String, Object>> page(Page page, String sql);

    @Select("${sql}")
    @ResultType(HashMap.class)
    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = Integer.MIN_VALUE)
    void listByHandler(String sql, ResultHandler<HashMap<String, Object>> handler);

    @Select("${sql}")
    int count(String sql);
}
