package cn.edu.whu.boot.collection.mapper;

import cn.edu.whu.boot.collection.dto.SqlEnity;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

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

/**
 * 插入数据字段不固定，所以定义一个基础 Mapper 接口
 */
@Repository
public interface BaseMapper {

    Integer insertSql(@Param("insertSql") String insertSql);

    Integer insertSqlEnity(@Param("sqlEnity") SqlEnity sqlEnity);

    Integer getVersionByPolygonId(@Param("tableName") String tableName , @Param("primaryKeyName") String primaryKeyName ,
                                  @Param("primaryKeyValue") Long primaryKeyValue);

    List<Map<String,Object>> selectData(@Param("selectSql") String selectSql);

    Integer getUserWorkRole(@Param("taskId") Integer taskId , @Param("userId") Integer userId);

    List<Map<String,Object>> getNotPassDataId(@Param("tableNameInDb") String tableNameInDb ,
                                              @Param("primaryKey") String primaryKey , @Param("userId") Integer userId);
    Long getStatisticDataNum(@Param("tableNameInDb") String tableNameInDb, @Param("geometryName")String geometryName,
                             @Param("geoJson")String geoJson);

    Long getDataCount(@Param("tableNameInDb") String tableNameInDb);

    Long getHasCollectAndPatrolDataCount(@Param("tableNameInDb") String tableNameInDb);

    List<Map<String,Object>> getDataCountAndTimeByUser(@Param("tableNameInDb") String tableNameInDb,
                                                       @Param("userId") Integer userId);
    List<Map<String,Object>> getAllFuzzySearchData(@Param("tableNameInDb") String tableNameInDb,
                                                   @Param("fieldNameInDB") String fieldNameInDB,
                                                   @Param("searchKey") String searchKey);
    Page<Map<String,Object>> getAllFuzzySearchDataCenterPoint(@Param("tableNameInDb") String tableNameInDb,
                                                              @Param("fieldNameInDB") String fieldNameInDB,
                                                              @Param("geometryFieldNameInDB") String geometryFieldNameInDB,
                                                              @Param("searchKey") String searchKey);

    List<Map<String,Object>> randomSelectDataIdNotInList(@Param("tableNameInDb") String tableNameInDb,
                                                         @Param("primaryKey") String primaryKey,
                                                         @Param("selectIdList") List selectIdList,
                                                         @Param("selectDataNum") Integer selectDataNum,
                                                         @Param("whereClause") String whereClause);

    List<Integer> getIdsByReviewer(@Param("tableNameInDb")String tableNameInDb, @Param("reviewerId")int reviewerId,
                                   @Param("primaryKey") String primaryKey);

    Integer getReviewerByDataId(@Param("tableNameInDb")String tableNameInDb, @Param("primaryKey") String primaryKey,
                                @Param("dataId")int dataId);
        /**
         * 查询指定表的所有字段名
         * @param tableName 表名
         * @return 字段名列表
         */
        List<String> selectSingleColumn(@Param("databaseName") String databaseName,
                                        @Param("tableName") String tableName);
}
