洪城义警-正式版后台
zengh
2021-10-09 86b6fcd12634fbb08a2bd8a2cf44205f7e1d2067
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
<?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">
 
    <!--查询资讯分页列表信息-->
    <select id="selectArticlePage" resultType="org.springblade.modules.article.entity.Article">
        select * from sys_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>
        order by create_time desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="pageDate" resultType="org.springblade.modules.article.entity.Article">
        select * from sys_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>
        order by create_time desc
    </select>
 
    <!--查询资讯分页列表信息-->
    <select id="pageLikes" resultType="org.springblade.modules.article.vo.ArticleVo">
        SELECT
        *
        FROM
        sys_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
        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>
        order by create_time desc
    </select>
 
    <update id="upcomment">
        update sys_article set iscomment = #{type}
        where id in(${ids})
    </update>
</mapper>