linwei
2024-02-22 947c4e68b6ce3b64db967a689227315924dd181e
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
<?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="org.springblade.modules.article.mapper.ArticleMapper">
 
 
    <!-- 通用查询映射结果 -->
    <resultMap id="noticeResultMap" type="org.springblade.modules.article.vo.ArticleVO">
        <result column="id" property="id"/>
        <result column="title" property="title"/>
        <result column="type" property="type"/>
        <result column="content" property="content"/>
        <result column="url" property="url"/>
        <result column="video_url" property="videoUrl"/>
        <result column="source_id" property="sourceId"/>
        <result column="source_name" property="sourceName"/>
        <result column="article_type" property="articleType"/>
        <result column="recommend" property="recommend"/>
        <result column="publish" property="publish"/>
        <result column="iscomment" property="iscomment"/>
        <result column="view_number" property="viewNumber"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="create_user" property="createUser"/>
        <result column="is_deleted" property="isDeleted"/>
        <result property="articleRange" column="article_range"/>
        <collection property="countNumber" column="id" javaType="int" select="selectStlCount">
        </collection>
 
    </resultMap>
 
 
    <select id="selectStlCount" resultType="int">
        select count(1) countNumber
        FROM jczz_article jn
                 LEFT JOIN jczz_article_like jnl ON jn.id = jnl.article_id
        where jn.is_deleted = 0
          and jnl.delete_flag = 0
          and jn.id = #{id}
    </select>
 
 
    <sql id="selectArticle">
        select
            id,
            title,
            type,
            content,
            url,
            video_url,
            source_id,
            source_name,
            article_type,
            recommend,
            publish,
            iscomment,
            view_number,
            create_time,
            update_time,
            update_user,
            create_user,
            is_deleted,
            article_range,
            building,
            unit
        from
            jczz_article
    </sql>
 
 
    <select id="selectArticlePageByApp" resultMap="noticeResultMap">
        <!-- 查询报名和议事 -->
        <if test="article.eventType != null">
            select ja.id,
            ja.title,
            ja.type,
            ja.url,
            ja.video_url,
            ja.source_id,
            ja.source_name,
            ja.article_type,
            ja.recommend,
            ja.publish,
            ja.iscomment,
            ja.view_number,
            ja.create_time,
            ja.update_time,
            ja.update_user,
            ja.create_user,
            ja.is_deleted,
            (select bdb.dict_value from blade_dict_biz bdb where bdb.parent_id='1740566650527752194' and ja.article_type
            = bdb.dict_key) dictValue,
            jpd.id pdId
            from jczz_article ja
            LEFT JOIN jczz_public_discuss jpd on jpd.article_id=ja.id
            where ja.is_deleted = 0
            and ja.publish = 1
            <if test="article.articleType != null and article.articleType != ''">
                and ja.article_type = #{article.articleType}
            </if>
 
            <if test="article.eventType != null">
                and jpd.event_type = #{article.eventType}
            </if>
 
            <if test="article.type != null">
                and ja.type = #{article.type}
            </if>
 
            <if test="article.type == null">
                and ja.type = 0
            </if>
 
            <if test="article.districtId != null and article.districtId != ''">
                and (ja.article_range like concat('%',#{article.districtId},'%')
                or ja.article_range is null)
            </if>
            <if test="article.building != null and article.building != ''">
                and (ja.building = #{article.building}
                or ja.building is null)
            </if>
 
            <if test="article.unit != null and article.unit != ''">
                and (ja.unit = #{article.unit}
                or ja.unit is null)
            </if>
        </if>
        <!-- 查询文章 -->
        <if test="article.eventType == null">
            select ja.id,
            ja.title,
            ja.type,
            ja.url,
            ja.video_url,
            ja.source_id,
            ja.source_name,
            ja.article_type,
            ja.recommend,
            ja.publish,
            ja.iscomment,
            ja.view_number,
            ja.create_time,
            ja.update_time,
            ja.update_user,
            ja.create_user,
            (select bdb.dict_value from blade_dict_biz bdb where bdb.parent_id='1722966265111248897' and ja.article_type
            = bdb.dict_key) dictValue,
            ja.is_deleted
            from jczz_article ja
            where ja.is_deleted = 0
            and ja.publish = 1
            <if test="article.articleType != null and article.articleType != ''">
                and ja.article_type = #{article.articleType}
            </if>
 
            <if test="article.type != null">
                and ja.type = #{article.type}
            </if>
 
            <if test="article.type == null">
                and ja.type = 0
            </if>
 
            <if test="article.districtId != null and article.districtId != ''">
                and (ja.article_range like concat('%',#{article.districtId},'%')
                or ja.article_range is null)
            </if>
 
            <if test="article.building != null and article.building != ''">
                and (ja.building = #{article.building}
                or ja.building is null)
            </if>
 
            <if test="article.unit != null and article.unit != ''">
                and (ja.unit = #{article.unit}
                or ja.unit is null)
            </if>
        </if>
 
        order by ja.create_time desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="selectArticlePage" resultType="org.springblade.modules.article.vo.ArticleVO">
        SELECT
        ja.*,
        br.`village_name` communityName,
        br.town_name streetName
        FROM
        jczz_article ja
        LEFT JOIN jczz_district jd ON ja.district_id = jd.id
        LEFT JOIN blade_region br on br.`code` = jd.community_code
        where 1=1
        and ja.is_deleted = 0
        <if test="article.propertyFlag!=null ">
            and ja.district_id IS NOT NULL
            <if test="article.communityName!=null and article.communityName!=''">
                and br.`village_name` like concat('%',#{article.communityName},'%')
            </if>
 
            <if test="article.streetName!=null and article.streetName!=''">
                and br.town_name like concat('%',#{article.streetName},'%')
            </if>
        </if>
 
 
        <if test="article.title!=null and article.title!=''">
            and ja.title like concat('%',#{article.title},'%')
        </if>
        <if test="article.sourceName!=null and article.sourceName!=''">
            and ja.source_name like concat('%',#{article.sourceName},'%')
        </if>
        <if test="article.startTime!=null and article.startTime!=''">
            and ja.create_time&gt;=#{article.startTime}
        </if>
        <if test="article.endTime!=null and article.endTime!=''">
            and ja.create_time&lt;=#{article.endTime}
        </if>
        <if test="article.publish!=null and article.publish!=''">
            and ja.publish = #{article.publish}
        </if>
        <if test="article.articleType!=null and article.articleType!=''">
            and ja.article_type like concat('%',#{article.articleType},'%')
        </if>
        <if test="article.type != null ">and ja.type = #{article.type}</if>
 
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(ja.title,ja.source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="article.districtIdList != null and article.districtIdList.size() > 0 ">
            and (ja.article_range like
            <foreach collection="article.districtIdList" separator=" or article_range like" item="id">'%${id}%'
            </foreach>
            )
            and ja.district_id in
            <foreach collection="article.districtIdList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        order by ja.create_time desc
    </select>
 
    <!--查询资讯敏感词预警-->
    <select id="pageWords" resultType="org.springblade.modules.article.entity.Article">
        select * from jczz_article
        where 1=1
        <if test="article.title!=null and article.title!=''">
            and title like concat('%',#{article.title},'%')
        </if>
        <if test="article.sourceName!=null and article.sourceName!=''">
            and source_name like concat('%',#{article.sourceName},'%')
        </if>
        <if test="article.startTime!=null and article.startTime!=''">
            and create_time&gt;=#{article.startTime}
        </if>
        <if test="article.endTime!=null and article.endTime!=''">
            and create_time&lt;=#{article.endTime}
        </if>
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type = #{article.articleType}
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        and iswords = "1"
        order by id desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="pageDate" resultType="org.springblade.modules.article.entity.Article">
        select * from jczz_article
        where 1=1
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type LIKE CONCAT ('%', #{article.articleType},'%')
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        and iswords = "0"
        order by id desc
    </select>
 
    <!--查询收藏资讯分页列表信息-->
    <select id="pageCollectList" resultType="org.springblade.modules.article.entity.Article">
        SELECT
        art.*
        FROM
        sys_collect col
        LEFT JOIN jczz_article art on art.id = col.collect_article
        WHERE
        1 = 1 AND collect_user = #{article.userid}
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type LIKE CONCAT ('%', #{article.articleType},'%')
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        and iswords = "0"
        order by id desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="pageLikes" resultType="org.springblade.modules.article.vo.ArticleVO">
        SELECT
        *
        FROM
        jczz_article art
        LEFT JOIN (
        SELECT
        a.likes_article,
        COUNT( * ) AS count,
        b.islikes
        FROM
        sys_likes a
        LEFT JOIN ( SELECT likes_article, COUNT( * ) AS islikes FROM sys_likes WHERE 1 = 1
        <if test="article.userid!=null and article.userid!=''">
            and likes_user = #{article.userid}
        </if>
        GROUP BY likes_article ) b ON a.likes_article = b.likes_article
        GROUP BY
        likes_article,
        b.islikes
        ) likes ON art.id = likes.likes_article
 
        LEFT JOIN (
        SELECT
        a.collect_article,
        COUNT( * ) AS collectcount,
        b.iscollect
        FROM
        sys_collect a
        LEFT JOIN ( SELECT collect_article, COUNT( * ) AS iscollect FROM sys_collect WHERE 1 = 1
        <if test="article.userid!=null and article.userid!=''">
            and collect_user = #{article.userid}
        </if>
        GROUP BY collect_article ) b ON a.collect_article = b.collect_article
        GROUP BY
        collect_article,
        b.iscollect
        ) collect ON art.id = collect.collect_article
 
        LEFT JOIN (
        SELECT
        article,
        COUNT(*) as comments
        FROM
        sys_comment
        GROUP BY article
        ) com on com.article = art.id
        WHERE
        1 = 1
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type LIKE CONCAT ('%', #{article.articleType},'%')
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        and iswords = "0"
        order by id desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="pageCollect" resultType="org.springblade.modules.article.vo.ArticleVO">
        SELECT
        *
        FROM
        jczz_article art
        LEFT JOIN (
        SELECT
        a.likes_article,
        COUNT( * ) AS count,
        b.islikes
        FROM
        sys_likes a
        LEFT JOIN ( SELECT likes_article, COUNT( * ) AS islikes FROM sys_likes WHERE 1 = 1
        <if test="article.userid!=null and article.userid!=''">
            and likes_user = #{article.userid}
        </if>
        GROUP BY likes_article ) b ON a.likes_article = b.likes_article
        GROUP BY
        likes_article,
        b.islikes
        ) likes ON art.id = likes.likes_article
 
        LEFT JOIN (
        SELECT
        a.collect_article,
        COUNT( * ) AS collectcount,
        b.iscollect
        FROM
        sys_collect a
        LEFT JOIN ( SELECT collect_article, COUNT( * ) AS iscollect FROM sys_collect WHERE 1 = 1
        <if test="article.userid!=null and article.userid!=''">
            and collect_user = #{article.userid}
        </if>
        GROUP BY collect_article ) b ON a.collect_article = b.collect_article
        GROUP BY
        collect_article,
        b.iscollect
        ) collect ON art.id = collect.collect_article
 
        LEFT JOIN (
        SELECT
        article,
        COUNT(*) as comments
        FROM
        sys_comment
        GROUP BY article
        ) com on com.article = art.id
        WHERE
        1 = 1
        AND iscollect = 1
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type LIKE CONCAT ('%', #{article.articleType},'%')
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        and iswords = "0"
        order by id desc
    </select>
 
    <update id="upcomment">
        update jczz_article set iscomment = #{type}
        where id in(${ids})
    </update>
 
    <!--个人资讯-->
    <select id="selectArticleG" resultType="org.springblade.modules.article.entity.Article">
        select * from jczz_article
        where 1=1
        <if test="article.title!=null and article.title!=''">
            and title like concat('%',#{article.title},'%')
        </if>
        <if test="article.sourceName!=null and article.sourceName!=''">
            and source_name like concat('%',#{article.sourceName},'%')
        </if>
        <if test="article.startTime!=null and article.startTime!=''">
            and create_time&gt;=#{article.startTime}
        </if>
        <if test="article.endTime!=null and article.endTime!=''">
            and create_time&lt;=#{article.endTime}
        </if>
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type = #{article.articleType}
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        and iswords = "0" and type!=1
        order by id desc
    </select>
 
 
    <select id="getArticleOne" parameterType="org.springblade.modules.article.vo.ArticleVO" resultMap="noticeResultMap">
        select ja.id,
        ja.title,
        ja.type,
        ja.url,
        ja.video_url,
        ja.source_id,
        ja.content,
        ja.source_name,
        ja.article_type,
        ja.recommend,
        ja.publish,
        ja.iscomment,
        ja.view_number,
        ja.create_time,
        ja.update_time,
        ja.update_user,
        ja.create_user,
        ja.is_deleted,
        ja.article_range,
        ((select bdb.dict_value from blade_dict_biz bdb where bdb.parent_id=#{parentId} and ja.article_type
        = bdb.dict_key)) dictValue
        from jczz_article ja
        <where>
            <if test="id != null ">and ja.id = #{id}</if>
            <if test="title != null  and title != ''">and ja.title = #{title}</if>
            <if test="type != null ">and ja.type = #{type}</if>
            <if test="content != null  and content != ''">and ja.content = #{content}</if>
            <if test="url != null  and url != ''">and ja.url = #{url}</if>
            <if test="videoUrl != null  and videoUrl != ''">and ja.video_url = #{videoUrl}</if>
            <if test="sourceId != null  and sourceId != ''">and ja.source_id = #{sourceId}</if>
            <if test="sourceName != null  and sourceName != ''">and ja.source_name = #{sourceName}</if>
            <if test="articleType != null  and articleType != ''">and ja.article_type = #{articleType}</if>
            <if test="recommend != null ">and ja.recommend = #{recommend}</if>
            <if test="publish != null  and publish != ''">and ja.publish = #{publish}</if>
            <if test="iscomment != null  and iscomment != ''">and ja.iscomment = #{iscomment}</if>
            <if test="viewNumber != null ">and ja.view_number = #{viewNumber}</if>
            <if test="createTime != null ">and ja.create_time = #{createTime}</if>
            <if test="updateTime != null ">and ja.update_time = #{updateTime}</if>
            <if test="updateUser != null ">and ja.update_user = #{updateUser}</if>
            <if test="createUser != null ">and ja.create_user = #{createUser}</if>
            <if test="isDeleted != null ">and ja.is_deleted = #{isDeleted}</if>
            <if test="articleRange != null  and articleRange != ''">and article_range = #{articleRange}</if>
        </where>
        and ja.is_deleted = 0
        order by ja.create_time desc
    </select>
 
 
    <select id="getDistrictId" resultType="java.lang.String">
        SELECT jd.id
        FROM jczz_doorplate_address jda
                 LEFT JOIN jczz_district jd ON jda.aoi_code = jd.aoi_code
        WHERE jda.address_code = #{houseCode}
 
    </select>
</mapper>