<?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.inkasso.factoring.code.dao.EntityGenerateDao">
     <!-- 获取数据源  -->
     <select id="getDataSources" resultType="java.lang.String">
     	show databases
     </select>
     
     <!-- 根据数据源获取所有的表  -->
     <select id="getTablesByDataSource" resultType="java.lang.String">
     	select
			table_name tableName
		from
			information_schema.TABLES
		where
			table_schema = #{dataSource}
     </select>
     
     <!-- 根据数据源获取所有的表  -->
     <select id="getColumnsByTableAndDataSource" resultType="com.inkasso.factoring.code.domain.TableColumn">
     	SELECT
			column_name columnName,
			data_type dataType,
			(CASE is_nullable WHEN 'NO' THEN TRUE ELSE FALSE END) required,
			CHARACTER_MAXIMUM_LENGTH length,
			column_comment label
		FROM
			information_schema.COLUMNS 
		WHERE
			table_name = #{tableName} 
			AND table_schema = #{dataSource}
		ORDER BY
			ordinal_position
     </select>
     
</mapper>