inleft
2022-08-25 d807fd2490a86bc99bb5abbe9566a63af63a6131
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
<?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="vip.xiaonuo.modular.blogarticle.mapper.BlogArticleMapper">
 
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column">
        id,title,article_file_id,article_file_type,
        article_type_id,introduce,cover_file_id,last_editor_date,publish_date,
        is_top,top_value,auth_status,auth_password,editor_status,
        separate_year,separate_month,separate_day,is_enable,update_date,create_date
    </sql>
 
    <sql id="Base_Column_List">
       a.id,
       a.title,
       a.article_file_type,
       a.article_type_id,
       a.introduce,
       a.cover_file_id,
       a.auth_status,
       a.last_editor_date,
       a.publish_date,
       a.is_top,
       a.editor_status,
       a.is_allowed_comment,
       a.jump_url as jumpURL,
       a.update_date,
       a.create_date,
       a.video_ids,
       a.picture_ids
    </sql>
 
    <!--首页通用的条件查询-->
    <sql id="queryListCondition">
        <trim prefix="WHERE" prefixOverrides="AND | OR">
            a.is_enable=1
            and a.editor_status=1
            and a.publish_date &lt; now()
            <choose>
                <when test="param.typeId != null">
                    AND a.article_type_id = #{param.typeId}
                    order by a.is_top desc,a.top_value asc , a.publish_date desc
                </when>
 
                <otherwise>
                    <!-- 首页不出现视频等文件类型-->
                    <if test="param.faceExcludeFile != null">
                        and a.article_file_type not in
                        <foreach collection="param.faceExcludeFile" item="obj" separator="," open="(" close=")">
                            #{obj}
                        </foreach>
                    </if>
                    order by a.is_top desc,a.top_value asc , a.update_date desc
                </otherwise>
            </choose>
        </trim>
 
    </sql>
 
    <!-- 首页查询-->
    <select id="searchList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
        select
        <include refid="Base_Column_List"/>
        ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
        ,t.type_name as articleTypeName
        from
        blog_article a
        inner join blog_article_type t
        on t.id =a.article_type_id
 
        <!-- 排除首页不查询的分类-->
        <if test="param.typeId == null">
            and t.is_show_face = 1
        </if>
 
        left join sys_file_info f2
        on f2.id=a.cover_file_id
 
        <include refid="queryListCondition"/>
 
        limit #{param.pageNo},#{param.pageSize}
    </select>
 
    <!-- 首页查询个数统计-->
    <select id="searchListCount" resultType="java.lang.Long">
        select
        count(0)
        from
        blog_article a
        <include refid="queryListCondition"/>
 
    </select>
 
    <!-- 月份归档统计-->
    <select id="searchMonthCount" resultType="vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo">
       SELECT
        separate_month AS `month`,
        count(1) AS `count`
        FROM
            blog_article
        WHERE
            (
                is_enable = 1
                AND editor_status = 1
                AND separate_year = #{separateYear}
                AND publish_date &lt; now()
            )
        GROUP BY
            separate_month
        ORDER BY  separate_month desc
 
    </select>
 
    <!-- 上下篇查询-->
    <select id="getAdjoiningRecord" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
        select
        a.id,
        a.title
        from
        blog_article a
        <include refid="queryListCondition"/>
        limit #{param.pageNo},#{param.pageSize}
    </select>
 
    <sql id="queryPlatformCondition">
        <trim prefix="WHERE" prefixOverrides="AND | OR">
            a.is_enable=1
            and a.editor_status=1
            and a.publish_date &lt; now()
 
            <if test="param.id != null">
                and a.id = #{param.id}
            </if>
 
            <if test="param.fileType != null">
                and a.article_file_type = #{param.fileType}
            </if>
 
            AND a.article_type_id in
            <foreach collection="param.typeIds" item="obj" separator="," open="(" close=")">
                #{obj}
            </foreach>
 
            order by a.is_top desc,a.top_value asc , a.publish_date desc
        </trim>
 
    </sql>
 
    <!--月台列表查询-->
    <select id="searchPlatformList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
        select
        <include refid="Base_Column_List"/>
        ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
        ,t.type_name as articleTypeName
        from
        blog_article a
        inner join blog_article_type t
        on t.id =a.article_type_id
 
        left join sys_file_info f2
        on f2.id=a.cover_file_id
 
        <include refid="queryPlatformCondition"/>
 
        limit #{param.pageNo},#{param.pageSize}
    </select>
 
    <select id="searchPlatformListCount" resultType="java.lang.Long">
        select
        count(0)
        from
        blog_article a
        <include refid="queryPlatformCondition"/>
    </select>
 
 
</mapper>