xiangpei
2025-04-18 ccadf9480d4e6a9dcc227a2a0b1f9ae0612e36fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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>