GenMapper.xml
1.84 KB
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
<?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.huaheng.pc.tool.gen.mapper.GenMapper">
<sql id="selectGenVo">
select TABLE_NAME AS tableName, TABLE_COMMENT AS tableComment, CREATE_TIME AS createTime, UPDATE_TIME AS updateTime
from information_schema.tables
</sql>
<select id="selectTableList" parameterType="TableInfo" resultType="TableInfo">
<include refid="selectGenVo"/>
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
<if test="tableName != null and tableName != ''">
AND table_name like concat('%', #{tableName}, '%')
</if>
<if test="tableComment != null and tableComment != ''">
AND table_comment like concat('%', #{tableComment}, '%')
</if>
<if test="params != null and params.beginTime != null"><!-- 开始时间检索 -->
and date_format(createTime,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params != null and params.endTime != null"><!-- 结束时间检索 -->
and date_format(createTime,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
</if>
</select>
<select id="selectTableByName" parameterType="String" resultType="TableInfo">
<include refid="selectGenVo"/>
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
and table_name = #{tableName}
</select>
<select id="selectTableColumnsByName" parameterType="String" resultType="ColumnInfo">
select TABLE_NAME AS tableName, COLUMN_NAME AS columnName, DATA_TYPE AS dataType, IS_NULLABLE AS isNullable,
COLUMN_DEFAULT AS columnDefault, COLUMN_COMMENT AS columnComment
from information_schema.columns
where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position
</select>
</mapper>