package com.gyee.frame.mapper.StandardPointTableMapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

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

@Repository
public interface StandardPointTableMapper {

    //所有表名
    @Select("select table_name from user_tables")
    List<String> getTableName();

    //指定表字段
    @Select( "SELECT column_name FROM user_tab_columns where table_name = upper('${tableName}') ")
    List<String> getAllColumns(@Param("tableName") String tableName);

    //根据指定列查询出数据
    @Select( "SELECT ${columnsName} FROM ${tableName}")
    List<Map<String, Object>> getDataByColumns(@Param("tableName") String tableName, @Param("columnsName") String columnsName);

    //存到数据库
//    @Select("insert into ${tableName}\n" +
//            "    <foreach item=\"value\" collection=\"unionData\" index=\"key\" open=\"(\"   separator=\",\" close=\")\">\n" +
//            "      ${key}\n" +
//            "    </foreach>\n" +
//            "    values\n" +
//            "    <foreach item=\"value\" collection=\"unionData\" index=\"key\"  open=\"(\"   separator=\",\" close=\")\">\n" +
//            "      #{value}\n" +
//            "    </foreach>")
    void saveData(@Param("unionData") Map<String, Object> unionData,@Param("tableName") String tableName);
}
