<?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.iotechn.unimall.data.mapper.tools.gen.GenTableMapper">

<!--	<resultMap type="GenTable" id="GenTableResult">-->
<!--		<id     property="tableId"        column="table_id"        />-->
<!--		<result property="tableName"      column="table_name"      />-->
<!--		<result property="tableComment"   column="table_comment"   />-->
<!--		<result property="className"      column="class_name"      />-->
<!--		<result property="tplCategory"    column="tpl_category"    />-->
<!--		<result property="packageName"    column="package_name"    />-->
<!--		<result property="moduleName"     column="module_name"     />-->
<!--		<result property="businessName"   column="business_name"   />-->
<!--		<result property="functionName"   column="function_name"   />-->
<!--		<result property="functionAuthor" column="function_author" />-->
<!--		<result property="options"        column="options"         />-->
<!--		<result property="createBy"       column="create_by"       />-->
<!--		<result property="createTime"     column="create_time"     />-->
<!--		<result property="updateBy"       column="update_by"       />-->
<!--		<result property="updateTime"     column="update_time"     />-->
<!--		<result property="remark"         column="remark"          />-->
<!--		<collection  property="columns"  javaType="java.util.List"  resultMap="GenTableColumnResult" />-->
<!--	</resultMap>-->

<!--	<resultMap type="GenTableColumn" id="GenTableColumnResult">-->
<!--		<id     property="columnId"       column="column_id"      />-->
<!--		<result property="tableId"        column="table_id"       />-->
<!--		<result property="columnName"     column="column_name"    />-->
<!--		<result property="columnComment"  column="column_comment" />-->
<!--		<result property="columnType"     column="column_type"    />-->
<!--		<result property="javaType"       column="java_type"      />-->
<!--		<result property="javaField"      column="java_field"     />-->
<!--		<result property="isPk"           column="is_pk"          />-->
<!--		<result property="isIncrement"    column="is_increment"   />-->
<!--		<result property="isRequired"     column="is_required"    />-->
<!--		<result property="isInsert"       column="is_insert"      />-->
<!--		<result property="isEdit"         column="is_edit"        />-->
<!--		<result property="isList"         column="is_list"        />-->
<!--		<result property="isQuery"        column="is_query"       />-->
<!--		<result property="queryType"      column="query_type"     />-->
<!--		<result property="htmlType"       column="html_type"      />-->
<!--		<result property="dictType"       column="dict_type"      />-->
<!--		<result property="sort"           column="sort"           />-->
<!--		<result property="createBy"       column="create_by"      />-->
<!--		<result property="createTime"     column="create_time"    />-->
<!--		<result property="updateBy"       column="update_by"      />-->
<!--		<result property="updateTime"     column="update_time"    />-->
<!--	</resultMap>-->
	<sql id="selectDictTypeVo">
		SELECT
			table_id AS tableId,
			`table_name` AS tableName,
			table_comment AS tableComment,
			class_name AS className,
			tpl_category AS tplCategory,
			package_name AS packageName,
			module_name AS moduleName,
			business_name AS businessName,
			function_name AS functionName,
			function_author AS functionAuthor,
			create_by AS createBy,
			create_time AS createTime,
			update_by AS updateBy,
			update_time AS updateTime,
			`options`
		FROM
			sys_gen_table
	</sql>
	<select id="selectDbTableListByNames"  resultType="com.iotechn.unimall.data.domain.tools.gen.GenTable">
		SELECT
		table_name as tableName,
		table_comment as tableComment,
		create_time as createTime,
		update_time as updateTime
		FROM
		information_schema.TABLES
		WHERE
		table_schema = ( SELECT DATABASE ( ) )
		AND table_name NOT LIKE 'qrtz_%'
		AND table_name NOT LIKE 'gen_%'
		AND table_name NOT IN ( SELECT table_name FROM sys_gen_table )
		AND table_name in
		<foreach  item="item" collection="array" index="index"  open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>
	<select id="selectDbTableList"  resultType="com.iotechn.unimall.data.domain.tools.gen.GenTable">
		SELECT
		table_name as tableName,
		table_comment as tableComment,
		create_time as createTime,
		update_time as updateTime
		FROM
		information_schema.TABLES
		WHERE
		table_schema = ( SELECT DATABASE ( ) )
		AND table_name NOT LIKE 'qrtz_%'
		AND table_name NOT LIKE 'gen_%'
		AND table_name NOT IN ( SELECT table_name FROM sys_gen_table )
		<if test="tableName != null and tableName != ''">
			AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
		</if>
		<if test="tableComment != null and tableComment != ''">
			AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
		</if>
	</select>
	<select id="selectDbTableCount"  resultType="java.lang.Integer">
		SELECT
		COUNT(*)
		FROM
		information_schema.TABLES
		WHERE
		table_schema = ( SELECT DATABASE ( ) )
		AND table_name NOT LIKE 'qrtz_%'
		AND table_name NOT LIKE 'gen_%'
		AND table_name NOT IN ( SELECT table_name FROM sys_gen_table )
		<if test="tableName != null and tableName != ''">
			AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
		</if>
		<if test="tableComment != null and tableComment != ''">
			AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
		</if>
	</select>

</mapper>