<?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.lantone.daqe.mapper.ColumnInfoMapper">

    <select id="getNoVerifyColumnName" resultType="com.lantone.daqe.dto.GetColumnInfoDTO">
        SELECT
            *
        FROM
            (
                SELECT
                    a.*, b.column_id
                FROM
                    (
                        SELECT
                            a.id,
                            a.table_cname,
                            a.table_ename,
                            a.column_cname,
                            a.column_ename
                        FROM
                            dc_column_info a
                        WHERE
                            a.is_deleted = 'N'
                        <if test="getTableColumnNameVO.tableCname != null and getTableColumnNameVO.tableCname != ''">
                            AND a.table_cname LIKE CONCAT('%',#{getTableColumnNameVO.tableCname},'%')
                        </if>
                        <if test="getTableColumnNameVO.tableEname != null and getTableColumnNameVO.tableEname != ''">
                            AND a.table_ename LIKE CONCAT('%',#{getTableColumnNameVO.tableEname},'%')
                        </if>
                        <if test="getTableColumnNameVO.columnCname != null and getTableColumnNameVO.columnCname != ''">
                            AND a.column_cname LIKE CONCAT('%',#{getTableColumnNameVO.columnCname},'%')
                        </if>
                        <if test="getTableColumnNameVO.columnEname != null and getTableColumnNameVO.columnEname != ''">
                            AND a.column_ename LIKE CONCAT('%',#{getTableColumnNameVO.columnEname},'%')
                        </if>
                    ) a
                LEFT JOIN dc_column_verify b ON a.id = b.column_id
                GROUP BY
                    a.id
            ) a
        WHERE
            a.column_id IS NULL
    </select>


    <select id="getVerifyTableName" resultType="com.lantone.daqe.dto.GetTableNameDTO">
        SELECT
            a.table_ename,
            a.table_cname
        FROM
            dc_column_info a,
            dc_column_verify b
        WHERE
            b.column_id=a.id
            and a.is_deleted='N'
            and b.is_deleted='N'
            <if test="getTableNameVO.tableCname != null and getTableNameVO.tableCname != ''">
                AND a.table_cname LIKE CONCAT('%',#{getTableNameVO.tableCname},'%')
            </if>
            <if test="getTableNameVO.tableEname != null and getTableNameVO.tableEname != ''">
                AND a.table_ename LIKE CONCAT('%',#{getTableNameVO.tableEname},'%')
            </if>
            GROUP BY
            table_cname,
            table_ename
    </select>
</mapper>