1.0
xin
2025-04-15 e718afd02965c6a4018506acb1ae99baca0c5645
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
45
46
47
48
49
<?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.oying.mapper.ColumnInfoMapper">
    <resultMap id="BaseResultMap" type="com.oying.domain.ColumnInfo">
        <id column="column_id" property="id"/>
        <result column="table_name" property="tableName"/>
        <result column="column_name" property="columnName"/>
        <result column="column_type" property="columnType"/>
        <result column="key_type" property="keyType"/>
        <result column="extra" property="extra"/>
        <result column="remark" property="remark"/>
        <result column="not_null" property="notNull"/>
        <result column="list_show" property="listShow"/>
        <result column="form_show" property="formShow"/>
        <result column="form_type" property="formType"/>
        <result column="query_type" property="queryType"/>
        <result column="dict_name" property="dictName"/>
    </resultMap>
 
    <sql id="Base_Column_List">
        column_id, table_name, column_name, column_type, key_type, extra, remark, not_null, list_show, form_show, form_type, query_type, dict_name
    </sql>
 
    <select id="getTables" resultType="com.oying.domain.dto.TableInfo">
        select table_name, create_time, engine, table_collation as coding, table_comment as remark
        from information_schema.tables
        where table_schema = (select database())
        and table_name like concat('%',#{tableName},'%')
        order by create_time desc
    </select>
 
    <select id="findByTableNameOrderByIdAsc" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from code_column
        where table_name = #{tableName}
        order by column_id
    </select>
 
    <select id="getColumns" resultMap="BaseResultMap">
        select column_name, if(is_nullable = 'NO', 1, 0) not_null,
               data_type as column_type, column_comment as remark,
               column_key key_type, extra
        from information_schema.columns
        where table_name = #{tableName}
        and table_schema = (select database())
        order by ordinal_position
    </select>
</mapper>