forked from opentiny/tiny-engine-backend-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppMapper.xml
More file actions
653 lines (637 loc) · 22.7 KB
/
AppMapper.xml
File metadata and controls
653 lines (637 loc) · 22.7 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
<?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.tinyengine.it.mapper.AppMapper">
<!-- 通用设置 -->
<!-- 通用查询列 -->
<sql id="Base_Column_List">
id
, name, app_website, platform_id, platform_history_id, industry_id, scene_id, publish_url, editor_url, visit_url, image_url,
assets_url, state, published, home_page_id, css, config, constants, data_handler, description, latest,
git_group, project_name, branch, is_demo, is_default, template_type, is_template, set_template_time, set_template_by,
set_default_by, framework, global_state, default_lang, extend_config, data_hash, can_associate,
data_source_global, created_by, last_updated_by, created_time, last_updated_time, tenant_id, renter_id, site_id
</sql>
<!-- 通用条件列 -->
<sql id="AppByCondition">
<if test="name!=null and name!=''">
AND A.name = #{name}
</if>
<if test="appWebsite!=null and appWebsite!=''">
AND A.app_website = #{appWebsite}
</if>
<if test="platformId!=null">
AND A.platform_id = #{platformId}
</if>
<if test="platformHistoryId!=null">
AND A.platform_history_id = #{platformHistoryId}
</if>
<if test="industryId!=null">
AND A.industry_id = #{industryId}
</if>
<if test="sceneId!=null">
AND A.scene_id = #{sceneId}
</if>
<if test="publishUrl!=null and publishUrl!=''">
AND A.publish_url = #{publishUrl}
</if>
<if test="editorUrl!=null and editorUrl!=''">
AND A.editor_url = #{editorUrl}
</if>
<if test="visitUrl!=null and visitUrl!=''">
AND A.visit_url = #{visitUrl}
</if>
<if test="imageUrl!=null and imageUrl!=''">
AND A.image_url = #{imageUrl}
</if>
<if test="assetsUrl!=null and assetsUrl!=''">
AND A.assets_url = #{assetsUrl}
</if>
<if test="state!=null and state!=''">
AND A.state = #{state}
</if>
<if test="isPublish!=null">
AND A.published = #{isPublish}
</if>
<if test="homePage!=null">
AND A.home_page_id = #{homePage}
</if>
<if test="css!=null and css!=''">
AND A.css = #{css}
</if>
<if test="config!=null and config!=''">
AND A.config = #{config}
</if>
<if test="constants!=null and constants!=''">
AND A.constants = #{constants}
</if>
<if test="dataHandler!=null and dataHandler!=''">
AND A.data_handler = #{dataHandler}
</if>
<if test="description!=null and description!=''">
AND A.description = #{description}
</if>
<if test="latest!=null and latest!=''">
AND A.latest = #{latest}
</if>
<if test="gitGroup!=null and gitGroup!=''">
AND A.git_group = #{gitGroup}
</if>
<if test="projectName!=null and projectName!=''">
AND A.project_name = #{projectName}
</if>
<if test="branch!=null and branch!=''">
AND A.branch = #{branch}
</if>
<if test="isDemo!=null">
AND A.is_demo = #{isDemo}
</if>
<if test="isDefault!=null">
AND A.is_default = #{isDefault}
</if>
<if test="templateType!=null and templateType!=''">
AND A.template_type = #{templateType}
</if>
<if test="isTemplate!=null">
AND A.is_template = #{isTemplate}
</if>
<if test="setTemplateTime!=null">
AND A.set_template_time = #{setTemplateTime}
</if>
<if test="setTemplateBy!=null and setTemplateBy!=''">
AND A.set_template_by = #{setTemplateBy}
</if>
<if test="setDefaultBy!=null and setDefaultBy!=''">
AND A.set_default_by = #{setDefaultBy}
</if>
<if test="framework!=null and framework!=''">
AND A.framework = #{framework}
</if>
<if test="globalState!=null and globalState!=''">
AND A.global_state = #{globalState}
</if>
<if test="defaultLang!=null and defaultLang!=''">
AND A.default_lang = #{defaultLang}
</if>
<if test="extendConfig!=null and extendConfig!=''">
AND A.extend_config = #{extendConfig}
</if>
<if test="dataHash!=null and dataHash!=''">
AND A.data_hash = #{dataHash}
</if>
<if test="canAssociate!=null">
AND A.can_associate = #{canAssociate}
</if>
<if test="dataSourceGlobal!=null and dataSourceGlobal!=''">
AND A.data_source_global = #{dataSourceGlobal}
</if>
<if test="createdBy!=null and createdBy!=''">
AND A.created_by = #{createdBy}
</if>
<if test="lastUpdatedBy!=null and lastUpdatedBy!=''">
AND A.last_updated_by = #{lastUpdatedBy}
</if>
<if test="createdTime!=null">
AND A.created_time = #{createdTime}
</if>
<if test="lastUpdatedTime!=null">
AND A.last_updated_time = #{lastUpdatedTime}
</if>
<if test="tenantId!=null and tenantId!=''">
AND A.tenant_id = #{tenantId}
</if>
<if test="renterId!=null and renterId!=''">
AND A.renter_id = #{renterId}
</if>
<if test="siteId!=null and siteId!=''">
AND A.site_id = #{siteId}
</if>
</sql>
<!-- 通用设置列 -->
<sql id="AppSetColumns">
<if test="name!=null and name!=''">
name = #{name},
</if>
<if test="appWebsite!=null and appWebsite!=''">
app_website = #{appWebsite},
</if>
<if test="platformId!=null">
platform_id = #{platformId},
</if>
<if test="platformHistoryId!=null">
platform_history_id = #{platformHistoryId},
</if>
<if test="industryId!=null">
industry_id = #{industryId},
</if>
<if test="sceneId!=null">
scene_id = #{sceneId},
</if>
<if test="publishUrl!=null and publishUrl!=''">
publish_url = #{publishUrl},
</if>
<if test="editorUrl!=null and editorUrl!=''">
editor_url = #{editorUrl},
</if>
<if test="visitUrl!=null and visitUrl!=''">
visit_url = #{visitUrl},
</if>
<if test="imageUrl!=null and imageUrl!=''">
image_url = #{imageUrl},
</if>
<if test="assetsUrl!=null and assetsUrl!=''">
assets_url = #{assetsUrl},
</if>
<if test="state!=null and state!=''">
state = #{state},
</if>
<if test="isPublish!=null">
published = #{isPublish},
</if>
<if test="homePage!=null">
home_page_id = #{homePage},
</if>
<if test="css!=null and css!=''">
css = #{css},
</if>
<if test="config!=null and config!=''">
config = #{config},
</if>
<if test="constants!=null and constants!=''">
constants = #{constants},
</if>
<if test="dataHandler!=null and dataHandler!=''">
data_handler = #{dataHandler},
</if>
<if test="description!=null and description!=''">
description = #{description},
</if>
<if test="latest!=null and latest!=''">
latest = #{latest},
</if>
<if test="gitGroup!=null and gitGroup!=''">
git_group = #{gitGroup},
</if>
<if test="projectName!=null and projectName!=''">
project_name = #{projectName},
</if>
<if test="branch!=null and branch!=''">
branch = #{branch},
</if>
<if test="isDemo!=null">
is_demo = #{isDemo},
</if>
<if test="isDefault!=null">
is_default = #{isDefault},
</if>
<if test="templateType!=null and templateType!=''">
template_type = #{templateType},
</if>
<if test="isTemplate!=null">
is_template = #{isTemplate},
</if>
<if test="setTemplateTime!=null">
set_template_time = #{setTemplateTime},
</if>
<if test="setTemplateBy!=null and setTemplateBy!=''">
set_template_by = #{setTemplateBy},
</if>
<if test="setDefaultBy!=null and setDefaultBy!=''">
set_default_by = #{setDefaultBy},
</if>
<if test="framework!=null and framework!=''">
framework = #{framework},
</if>
<if test="globalState!=null and globalState!=''">
global_state = #{globalState},
</if>
<if test="defaultLang!=null and defaultLang!=''">
default_lang = #{defaultLang},
</if>
<if test="extendConfig!=null and extendConfig!=''">
extend_config = #{extendConfig},
</if>
<if test="dataHash!=null and dataHash!=''">
data_hash = #{dataHash},
</if>
<if test="canAssociate!=null">
can_associate = #{canAssociate},
</if>
<if test="dataSourceGlobal!=null and dataSourceGlobal!=''">
data_source_global = #{dataSourceGlobal},
</if>
<if test="createdBy!=null and createdBy!=''">
created_by = #{createdBy},
</if>
<if test="lastUpdatedBy!=null and lastUpdatedBy!=''">
last_updated_by = #{lastUpdatedBy},
</if>
<if test="createdTime!=null">
created_time = #{createdTime},
</if>
<if test="lastUpdatedTime!=null">
last_updated_time = #{lastUpdatedTime},
</if>
<if test="tenantId!=null and tenantId!=''">
tenant_id = #{tenantId},
</if>
<if test="renterId!=null and renterId!=''">
renter_id = #{renterId},
</if>
<if test="siteId!=null and siteId!=''">
site_id = #{siteId},
</if>
</sql>
<!-- 通用查询映射结果 -->
<resultMap id="AppMap" type="com.tinyengine.it.model.entity.App">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="app_website" property="appWebsite"/>
<result column="platform_id" property="platformId"/>
<result column="platform_history_id" property="platformHistoryId"/>
<result column="publish_url" property="publishUrl"/>
<result column="editor_url" property="editorUrl"/>
<result column="visit_url" property="visitUrl"/>
<result column="image_url" property="imageUrl"/>
<result column="assets_url" property="assetsUrl"/>
<result column="state" property="state"/>
<result column="published" property="isPublish"/>
<result column="home_page_id" property="homePage"/>
<result column="css" property="css"/>
<result column="config" property="config"/>
<result column="constants" property="constants"/>
<result column="data_handler" property="dataHandler"/>
<result column="description" property="description"/>
<result column="latest" property="latest"/>
<result column="git_group" property="gitGroup"/>
<result column="project_name" property="projectName"/>
<result column="branch" property="branch"/>
<result column="is_demo" property="isDemo"/>
<result column="is_default" property="isDefault"/>
<result column="template_type" property="templateType"/>
<result column="is_template" property="isTemplate"/>
<result column="industry_id" property="industryId"/>
<result column="scene_id" property="sceneId"/>
<result column="set_template_time" property="setTemplateTime"/>
<result column="set_template_by" property="setTemplateBy"/>
<result column="set_default_by" property="setDefaultBy"/>
<result column="framework" property="framework"/>
<result column="global_state" property="globalState"/>
<result column="default_lang" property="defaultLang"/>
<result column="extend_config" property="extendConfig"/>
<result column="data_hash" property="dataHash"/>
<result column="can_associate" property="canAssociate"/>
<result column="data_source_global" property="dataSourceGlobal"/>
<result column="created_by" property="createdBy"/>
<result column="last_updated_by" property="lastUpdatedBy"/>
<result column="created_time" property="createdTime"/>
<result column="last_updated_time" property="lastUpdatedTime"/>
<result column="tenant_id" property="tenantId"/>
<result column="renter_id" property="renterId"/>
<result column="site_id" property="siteId"/>
<!-- 行业分类映射 -->
<association property="industry" javaType="com.tinyengine.it.model.entity.BusinessCategory">
<id column="industry_id" property="id"/>
<result column="industry_code" property="code"/>
<result column="industry_name" property="name"/>
<result column="industry_business_group" property="businessGroup"/>
<result column="industry_created_by" property="createdBy"/>
<result column="industry_last_updated_by" property="lastUpdatedBy"/>
<result column="industry_created_time" property="createdTime"/>
<result column="industry_last_updated_time" property="lastUpdatedTime"/>
<result column="industry_tenant_id" property="tenantId"/>
<result column="industry_renter_id" property="renterId"/>
<result column="industry_site_id" property="siteId"/>
</association>
<!-- 场景分类映射 -->
<association property="scene" javaType="com.tinyengine.it.model.entity.BusinessCategory">
<id column="scene_id" property="id"/>
<result column="scene_code" property="code"/>
<result column="scene_name" property="name"/>
<result column="scene_business_group" property="businessGroup"/>
<result column="scene_created_by" property="createdBy"/>
<result column="scene_last_updated_by" property="lastUpdatedBy"/>
<result column="scene_created_time" property="createdTime"/>
<result column="scene_last_updated_time" property="lastUpdatedTime"/>
<result column="scene_tenant_id" property="tenantId"/>
<result column="scene_renter_id" property="renterId"/>
<result column="scene_site_id" property="siteId"/>
</association>
</resultMap>
<!-- 公共列定义 -->
<sql id="App_Base_Column_List">
A.id,
A.name,
A.app_website,
A.platform_id,
A.industry_id,
A.scene_id,
A.platform_history_id,
A.publish_url,
A.editor_url,
A.visit_url,
A.image_url,
A.assets_url,
A.state,
A.published,
A.home_page_id,
A.css,
A.config,
A.constants,
A.data_handler,
A.description,
A.latest,
A.git_group,
A.project_name,
A.branch,
A.is_demo,
A.is_default,
A.template_type,
A.is_template,
A.set_template_time,
A.set_template_by,
A.set_default_by,
A.framework,
A.global_state,
A.default_lang,
A.extend_config,
A.data_hash,
A.can_associate,
A.data_source_global,
A.created_by,
A.last_updated_by,
A.created_time,
A.last_updated_time,
A.tenant_id,
A.renter_id,
A.site_id
</sql>
<!-- 公共 JOIN 逻辑 -->
<sql id="Common_Join">
FROM t_app A
LEFT JOIN t_business_category industry ON A.industry_id = industry.id AND A.industry_id IS NOT NULL
LEFT JOIN t_business_category scene ON A.scene_id = scene.id AND A.scene_id IS NOT NULL
</sql>
<sql id="Common_Column_List">
<include refid="App_Base_Column_List"/>,
industry.id as industry_id, industry.code as industry_code, industry.name as industry_name,
industry.business_group as industry_business_group,
scene.id as scene_id, scene.code as scene_code, scene.name as scene_name,
scene.business_group as scene_business_group
</sql>
<select id="queryAllApp" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
WHERE A.is_template IS NOT TRUE AND A.tenant_id = #{tenantId}
ORDER BY A.created_time DESC
</select>
<select id="queryAllAppByPage" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
<where>
A.is_template IS NOT TRUE
<if test="name != null and name != ''">
AND A.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="industryId != null">
AND A.industry_id = #{industryId}
</if>
<if test="sceneId != null">
AND A.scene_id = #{sceneId}
</if>
<if test="framework != null">
AND A.framework = #{framework}
</if>
<if test="createdBy != null">
AND A.created_by = #{createdBy}
</if>
<if test="tenantId != null">
AND A.tenant_id = #{tenantId}
</if>
</where>
ORDER BY
<choose>
<when test="orderBy == 'create_time'">A.created_time</when>
<when test="orderBy == 'last_updated_time'">A.last_updated_time</when>
<otherwise>A.id</otherwise>
</choose>
DESC
LIMIT #{pageSize} OFFSET #{offset}
</select>
<!-- 查询应用模版所有数据 -->
<select id="queryAllAppTemplate" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
<where>
A.is_template = true
<if test="name != null and name != ''">
AND A.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="industryId != null">
AND A.industry_id = #{industryId}
</if>
<if test="sceneId != null">
AND A.scene_id = #{sceneId}
</if>
<if test="framework != null">
AND A.framework = #{framework}
</if>
<if test="createdBy != null">
AND A.created_by = #{createdBy}
</if>
<if test="tenantId != null">
AND A.tenant_id = #{tenantId}
</if>
</where>
ORDER BY
<choose>
<when test="orderBy == 'created_time'">A.created_time</when>
<when test="orderBy == 'last_updated_time'">A.last_updated_time</when>
<otherwise>A.id</otherwise>
</choose>
DESC
LIMIT #{pageSize} OFFSET #{offset}
</select>
<!-- 根据主键id查询表t_app信息 -->
<select id="queryAppById" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
<where>
<if test="tenantId != null">
AND A.tenant_id = #{tenantId}
</if>
A.id = #{id}
</where>
</select>
<!-- 根据主键id查询应用模版信息 -->
<select id="queryAppTemplateById" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
<where>
<if test="tenantId != null">
AND A.tenant_id = #{tenantId}
</if>
A.id = #{id} AND A.is_template = true
</where>
</select>
<!-- 根据条件查询表t_app数据 -->
<select id="queryAppByCondition" resultMap="AppMap">
SELECT
<include refid="Common_Column_List"/>
<include refid="Common_Join"/>
WHERE 1=1
<include refid="AppByCondition"/>
</select>
<!-- 根据主键id删除表t_app数据 -->
<delete id="deleteAppById">
DELETE
FROM t_app
WHERE id = #{id} AND tenant_id = #{tenantId}
</delete>
<!-- 根据主键id更新表t_app数据 -->
<update id="updateAppById" parameterType="com.tinyengine.it.model.entity.App">
UPDATE t_app
<set>
<include refid="AppSetColumns"/>
</set>
WHERE
id = #{id} AND tenant_id = #{tenantId}
</update>
<!-- 新增表t_app数据 -->
<insert id="createApp" useGeneratedKeys="true" keyProperty="id" parameterType="com.tinyengine.it.model.entity.App">
INSERT INTO t_app ( id
, name
, app_website
, platform_id
, platform_history_id
, industry_id
, scene_id
, publish_url
, editor_url
, visit_url
, image_url
, assets_url
, state
, published
, home_page_id
, css
, config
, constants
, data_handler
, description
, latest
, git_group
, project_name
, branch
, is_demo
, is_default
, template_type
, is_template
, set_template_time
, set_template_by
, set_default_by
, framework
, global_state
, default_lang
, extend_config
, data_hash
, can_associate
, data_source_global
, created_by
, last_updated_by
, created_time
, last_updated_time
, tenant_id
, renter_id
, site_id)
VALUES ( #{id}
, #{name}
, #{appWebsite}
, #{platformId}
, #{platformHistoryId}
, #{industryId}
, #{sceneId}
, #{publishUrl}
, #{editorUrl}
, #{visitUrl}
, #{imageUrl}
, #{assetsUrl}
, #{state}
, #{isPublish}
, #{homePage}
, #{css}
, #{config}
, #{constants}
, #{dataHandler}
, #{description}
, #{latest}
, #{gitGroup}
, #{projectName}
, #{branch}
, #{isDemo}
, #{isDefault}
, #{templateType}
, #{isTemplate}
, #{setTemplateTime}
, #{setTemplateBy}
, #{setDefaultBy}
, #{framework}
, #{globalState}
, #{defaultLang}
, #{extendConfig}
, #{dataHash}
, #{canAssociate}
, #{dataSourceGlobal}
, #{createdBy}
, #{lastUpdatedBy}
, #{createdTime}
, #{lastUpdatedTime}
, #{tenantId}
, #{renterId}
, #{siteId})
</insert>
</mapper>