xm
2024-06-14 722af26bc6fec32bb289b1df51a9016a4935610f
提交 | 用户 | 时间
722af2 1 <?xml version="1.0" encoding="UTF-8" ?>
X 2 <!DOCTYPE mapper
3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 <mapper namespace="com.dl.generator.mapper.GenTableMapper">
6
7     <resultMap type="GenTable" id="GenTableResult">
8         <id     property="tableId"        column="table_id"          />
9         <result property="tableName"      column="table_name"        />
10         <result property="tableComment"   column="table_comment"     />
11         <result property="subTableName"   column="sub_table_name"    />
12         <result property="subTableFkName" column="sub_table_fk_name" />
13         <result property="className"      column="class_name"        />
14         <result property="tplCategory"    column="tpl_category"      />
15         <result property="packageName"    column="package_name"      />
16         <result property="moduleName"     column="module_name"       />
17         <result property="businessName"   column="business_name"     />
18         <result property="functionName"   column="function_name"     />
19         <result property="functionAuthor" column="function_author"   />
20         <result property="genType"        column="gen_type"          />
21         <result property="genPath"        column="gen_path"          />
22         <result property="options"        column="options"           />
23         <result property="createBy"       column="create_by"         />
24         <result property="createTime"     column="create_time"       />
25         <result property="updateBy"       column="update_by"         />
26         <result property="updateTime"     column="update_time"       />
27         <result property="remark"         column="remark"            />
28         <collection  property="columns"  javaType="java.util.List"  resultMap="GenTableColumnResult" />
29     </resultMap>
30
31     <resultMap type="GenTableColumn" id="GenTableColumnResult">
32         <id     property="columnId"       column="column_id"      />
33         <result property="tableId"        column="table_id"       />
34         <result property="columnName"     column="column_name"    />
35         <result property="columnComment"  column="column_comment" />
36         <result property="columnType"     column="column_type"    />
37         <result property="javaType"       column="java_type"      />
38         <result property="javaField"      column="java_field"     />
39         <result property="isPk"           column="is_pk"          />
40         <result property="isIncrement"    column="is_increment"   />
41         <result property="isRequired"     column="is_required"    />
42         <result property="isInsert"       column="is_insert"      />
43         <result property="isEdit"         column="is_edit"        />
44         <result property="isList"         column="is_list"        />
45         <result property="isQuery"        column="is_query"       />
46         <result property="queryType"      column="query_type"     />
47         <result property="htmlType"       column="html_type"      />
48         <result property="dictType"       column="dict_type"      />
49         <result property="sort"           column="sort"           />
50         <result property="createBy"       column="create_by"      />
51         <result property="createTime"     column="create_time"    />
52         <result property="updateBy"       column="update_by"      />
53         <result property="updateTime"     column="update_time"    />
54     </resultMap>
55
56     <select id="selectPageDbTableList" resultMap="GenTableResult">
57         <if test="@com.dl.common.helper.DataBaseHelper@isMySql()">
58             select table_name, table_comment, create_time, update_time
59             from information_schema.tables
60             where table_schema = (select database())
61             AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
62             AND table_name NOT IN (select table_name from gen_table)
63             <if test="genTable.tableName != null and genTable.tableName != ''">
64                 AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
65             </if>
66             <if test="genTable.tableComment != null and genTable.tableComment != ''">
67                 AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
68             </if>
69             order by create_time desc
70         </if>
71         <if test="@com.dl.common.helper.DataBaseHelper@isOracle()">
72             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
73             from user_tables dt, user_tab_comments dtc, user_objects uo
74             where dt.table_name = dtc.table_name
75             and dt.table_name = uo.object_name
76             and uo.object_type = 'TABLE'
77             AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
78             AND lower(dt.table_name) NOT IN (select table_name from gen_table)
79             <if test="genTable.tableName != null and genTable.tableName != ''">
80                 AND lower(dt.table_name) like lower(concat(concat('%', #{genTable.tableName}), '%'))
81             </if>
82             <if test="genTable.tableComment != null and genTable.tableComment != ''">
83                 AND lower(dtc.comments) like lower(concat(concat('%', #{genTable.tableComment}), '%'))
84             </if>
85             order by create_time desc
86         </if>
87         <if test="@com.dl.common.helper.DataBaseHelper@isPostgerSql()">
88             select table_name, table_comment, create_time, update_time
89             from (
90                 SELECT c.relname AS table_name,
91                         obj_description(c.oid) AS table_comment,
92                         CURRENT_TIMESTAMP AS create_time,
93                         CURRENT_TIMESTAMP AS update_time
94                 FROM pg_class c
95                     LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
96                 WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
97                     AND c.relname != 'spatial_%'::text
98                     AND n.nspname = 'public'::name
99                     AND n.nspname <![CDATA[ <> ]]> ''::name
100             ) list_table
101             where table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
102             AND table_name NOT IN (select table_name from gen_table)
103             <if test="genTable.tableName != null and genTable.tableName != ''">
104                 AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
105             </if>
106             <if test="genTable.tableComment != null and genTable.tableComment != ''">
107                 AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
108             </if>
109             order by create_time desc
110         </if>
111         <if test="@com.dl.common.helper.DataBaseHelper@isSqlServer()">
112             SELECT cast(D.NAME as nvarchar) as table_name,
113                    cast(F.VALUE as nvarchar) as table_comment,
114                    crdate as create_time,
115                    refdate as update_time
116             FROM SYSOBJECTS D
117                 INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
118                     AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
119                     AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
120                     AND D.NAME NOT IN (select table_name from gen_table)
121             <if test="genTable.tableName != null and genTable.tableName != ''">
122                 AND lower(D.NAME) like lower(concat(N'%', N'${genTable.tableName}', N'%'))
123             </if>
124             <if test="genTable.tableComment != null and genTable.tableComment != ''">
125                 AND lower(CAST(F.VALUE AS nvarchar)) like lower(concat(N'%', N'${genTable.tableComment}', N'%'))
126             </if>
127             order by crdate desc
128         </if>
129     </select>
130
131     <select id="selectDbTableListByNames" resultMap="GenTableResult">
132         <if test="@com.dl.common.helper.DataBaseHelper@isMySql()">
133             select table_name, table_comment, create_time, update_time from information_schema.tables
134             where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
135             and table_name in
136             <foreach collection="array" item="name" open="(" separator="," close=")">
137                  #{name}
138             </foreach>
139         </if>
140         <if test="@com.dl.common.helper.DataBaseHelper@isOracle()">
141             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
142             from user_tables dt, user_tab_comments dtc, user_objects uo
143             where dt.table_name = dtc.table_name
144             and dt.table_name = uo.object_name
145             and uo.object_type = 'TABLE'
146             AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
147             AND dt.table_name NOT IN (select table_name from gen_table)
148             and lower(dt.table_name) in
149             <foreach collection="array" item="name" open="(" separator="," close=")">
150                 #{name}
151             </foreach>
152         </if>
153         <if test="@com.dl.common.helper.DataBaseHelper@isPostgerSql()">
154             select table_name, table_comment, create_time, update_time
155             from (
156                 SELECT c.relname AS table_name,
157                         obj_description(c.oid) AS table_comment,
158                         CURRENT_TIMESTAMP AS create_time,
159                         CURRENT_TIMESTAMP AS update_time
160                 FROM pg_class c
161                     LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
162                 WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
163                     AND c.relname != 'spatial_%'::text
164                     AND n.nspname = 'public'::name
165                     AND n.nspname <![CDATA[ <> ]]> ''::name
166             ) list_table
167             where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%'
168             and table_name in
169             <foreach collection="array" item="name" open="(" separator="," close=")">
170                 #{name}
171             </foreach>
172         </if>
173         <if test="@com.dl.common.helper.DataBaseHelper@isSqlServer()">
174             SELECT cast(D.NAME as nvarchar) as table_name,
175                    cast(F.VALUE as nvarchar) as table_comment,
176                    crdate as create_time,
177                    refdate as update_time
178             FROM SYSOBJECTS D
179                 INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
180                     AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
181                     AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
182                     AND D.NAME in
183             <foreach collection="array" item="name" open="(" separator="," close=")">
184                 #{name}
185             </foreach>
186         </if>
187     </select>
188
189     <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
190         <if test="@com.dl.common.helper.DataBaseHelper@isMySql()">
191             select table_name, table_comment, create_time, update_time from information_schema.tables
192             where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
193             and table_name = #{tableName}
194         </if>
195         <if test="@com.dl.common.helper.DataBaseHelper@isOracle()">
196             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
197             from user_tables dt, user_tab_comments dtc, user_objects uo
198             where dt.table_name = dtc.table_name
199             and dt.table_name = uo.object_name
200             and uo.object_type = 'TABLE'
201             AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
202             AND dt.table_name NOT IN (select table_name from gen_table)
203             and lower(dt.table_name) = #{tableName}
204         </if>
205         <if test="@com.dl.common.helper.DataBaseHelper@isPostgerSql()">
206             select table_name, table_comment, create_time, update_time
207             from (
208                 SELECT c.relname AS table_name,
209                         obj_description(c.oid) AS table_comment,
210                         CURRENT_TIMESTAMP AS create_time,
211                         CURRENT_TIMESTAMP AS update_time
212                 FROM pg_class c
213                     LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
214                 WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
215                     AND c.relname != 'spatial_%'::text
216                     AND n.nspname = 'public'::name
217                     AND n.nspname <![CDATA[ <> ]]> ''::name
218             ) list_table
219             where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%'
220             and table_name = #{tableName}
221         </if>
222         <if test="@com.dl.common.helper.DataBaseHelper@isSqlServer()">
223             SELECT cast(D.NAME as nvarchar) as table_name,
224                    cast(F.VALUE as nvarchar) as table_comment,
225                    crdate as create_time,
226                    refdate as update_time
227             FROM SYSOBJECTS D
228                 INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
229                     AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
230                     AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
231                     AND D.NAME = #{tableName}
232         </if>
233     </select>
234
235     <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
236         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
237                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
238         FROM gen_table t
239              LEFT JOIN gen_table_column c ON t.table_id = c.table_id
240         where t.table_id = #{tableId} order by c.sort
241     </select>
242
243     <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
244         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
245                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
246         FROM gen_table t
247              LEFT JOIN gen_table_column c ON t.table_id = c.table_id
248         where t.table_name = #{tableName} order by c.sort
249     </select>
250
251     <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
252         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
253                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
254         FROM gen_table t
255              LEFT JOIN gen_table_column c ON t.table_id = c.table_id
256         order by c.sort
257     </select>
258
259 </mapper>