<?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.hchyun.generator.dao.AssociatedDao">
    <select id="tableInfos" resultType="java.util.HashMap">
        select table_name, table_comment
        from information_schema.tables
        where table_schema = (select database())
          AND table_name NOT LIKE 'qrtz_%'
          AND table_name NOT LIKE 'gen_%'
    </select>
    <select id="selectTableColumnByTableId" resultType="com.hchyun.generator.entity.AssColumn" parameterType="Long">
        select * from gen_acc_column where table_id = #{tableId} order by sort
    </select>

    <select id="selectTableColumn" resultType="com.hchyun.generator.entity.AssColumn" parameterType="String">
        select column_name, ordinal_position as sort, column_comment, column_type
        from information_schema.columns
        where table_schema = (select database())
          and table_name = (#{tableNAme})
        order by sort
    </select>

    <delete id="deleteTableColumn" parameterType="Long">
        delete
        from gen_acc_column
        where table_id = #{tableId}
    </delete>



    <insert id="insertColumns" parameterType="java.util.List">
        insert into gen_acc_column(table_id, column_name, column_comment, column_type, java_type, java_field, is_list,
        is_query, query_type, html_type, dict_type, sort, create_by, update_by)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.tableId},#{item.columnName},#{item.columnComment},#{item.columnType},
            #{item.javaType},#{item.javaField},#{item.isList},#{item.isQuery},
            #{item.queryType},#{item.htmlType},#{item.dictType},#{item.sort},
             #{item.createBy},#{item.updateBy})
        </foreach>
    </insert>


</mapper>