<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nantian.cloud.query.mapper.record.RecordMultiDimensionDataSourceMapper">
    <resultMap id="BaseResultMap" type="com.nantian.cloud.query.entity.jljc.MultiDimensionDataSource">
        <id column="id" property="id"/>
        <result column="source_name" property="sourceName"/>
        <result column="source_code" property="sourceCode"/>
        <result column="source_desc" property="sourceDesc"/>
        <result column="source_type" property="sourceType"/>
        <result column="source_config" property="sourceConfig"/>
        <result column="create_time" property="createTime"/>
        <result column="enable_flag" property="enableFlag"/>
        <result column="delete_flag" property="deleteFlag"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="source_host" property="sourceHost"/>
        <result column="source_user" property="sourceUser"/>
        <result column="source_password" property="sourcePassword"/>
        <result column="source_port" property="sourcePort"/>
        <result column="version" property="version"/>
    </resultMap>

    <sql id="tableName">
        multi_dimension_data_source
    </sql>

    <sql id="baseColumn">
        id
        ,source_code,source_name,source_desc,source_type,source_config,enable_flag,delete_flag,create_by,create_time,update_by,
        update_time,version,source_host,source_user,source_password,source_port
    </sql>

    <select id="queryAllTables" resultType="String">
        SELECT
        TABLE_NAME
        FROM information_schema.tables
        <where>
            table_schema= #{dataBaseName}
        </where>
    </select>

    <select id="queryAllColumns" resultType="String">
        SELECT
        COLUMN_NAME
        FROM information_schema.COLUMNS
        WHERE 1 = 1
        <if test="dataBaseName != null and dataBaseName !='' ">
            AND table_schema= #{dataBaseName}
        </if>
        <if test="tableName != null and tableName !='' ">
            AND table_name= #{tableName}
        </if>
    </select>

</mapper>
