<?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.monkeylessey.sys.mapper.SysTableMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.monkeylessey.sys.domain.entity.SysTable">
|
<result column="table_name" property="tableName" />
|
</resultMap>
|
|
<select id="getTableNames" resultMap="BaseResultMap">
|
select table_name from information_schema.tables where TABLE_SCHEMA = #{database}
|
</select>
|
|
<select id="getTableColumns" resultType="com.monkeylessey.sys.domain.vo.TableColumnVO">
|
SELECT
|
COLUMN_NAME as columnName,
|
DATA_TYPE as columnType,
|
ORDINAL_POSITION as orderNum,
|
IS_NULLABLE as required,
|
CHARACTER_MAXIMUM_LENGTH as stringLength,
|
COLUMN_COMMENT as comment
|
FROM
|
information_schema.columns
|
WHERE
|
table_schema = #{dataBaseName} AND table_name = #{tableName}
|
ORDER BY
|
ordinal_position asc
|
</select>
|
|
<select id="getTableColumnsSelect" resultType="string">
|
SELECT
|
COLUMN_NAME
|
FROM
|
information_schema.columns
|
WHERE
|
table_schema = #{dataBaseName} AND table_name = #{tableName}
|
<if test=" keyword != null and keyword !='' ">
|
AND COLUMN_NAME like concat('%', #{keyword}, '%')
|
</if>
|
ORDER BY
|
ordinal_position asc
|
</select>
|
|
</mapper>
|