inleft
2022-08-24 dc050f50a530ef7b0eaa378ca1790c26d4f0bfd5
commit | author | age
9bcb19 1 <?xml version="1.0" encoding="UTF-8"?>
I 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="vip.xiaonuo.modular.blogarticle.mapper.BlogArticleMapper">
4
0613f2 5
I 6     <!-- 通用查询结果列 -->
7     <sql id="Base_Column">
8         id,title,article_file_id,article_file_type,
9         article_type_id,introduce,cover_file_id,last_editor_date,publish_date,
10         is_top,top_value,auth_status,auth_password,editor_status,
11         separate_year,separate_month,separate_day,is_enable,update_date,create_date
12     </sql>
13
14     <sql id="Base_Column_List">
15        a.id,
16        a.title,
17        a.article_file_type,
18        a.article_type_id,
19        a.introduce,
20        a.cover_file_id,
21        a.auth_status,
22        a.last_editor_date,
23        a.publish_date,
24        a.is_top,
25        a.editor_status,
42b7d0 26        a.is_allowed_comment,
70097d 27        a.jump_url as jumpURL,
ba780f 28        a.update_date,
dc050f 29        a.create_date,
I 30        a.video_ids,
31        a.picture_ids
0613f2 32     </sql>
I 33
dc050f 34     <!--首页通用的条件查询-->
0613f2 35     <sql id="queryListCondition">
I 36         <trim prefix="WHERE" prefixOverrides="AND | OR">
37             a.is_enable=1
38             and a.editor_status=1
c49fa0 39             and a.publish_date &lt; now()
d80267 40             <choose>
1e152b 41                 <!-- 月台查询用 -->
d80267 42                 <when test="param.fileType != null">
I 43                     and a.article_file_type = #{param.fileType}
44                 </when>
1e152b 45                 <!-- 指定排除 视频类在首页显示,但需要在分类栏目列表显示 -->
d80267 46                 <when test="param.fileType == null and param.typeId == null">
I 47                     and a.article_file_type not in (3,4)
48                 </when>
49             </choose>
cb2e50 50             <choose>
I 51                 <when test="param.typeId != null">
52                     AND a.article_type_id = #{param.typeId}
20e5fc 53                     order by a.is_top desc,a.top_value asc , a.publish_date desc
cb2e50 54                 </when>
1e152b 55
I 56                 <!-- 指定排除 笔记类在首页显示 -->
cb2e50 57                 <otherwise>
I 58                     AND a.article_type_id != 4
ba780f 59                     order by a.is_top desc,a.top_value asc , a.update_date desc
cb2e50 60                 </otherwise>
I 61             </choose>
0613f2 62         </trim>
cb2e50 63
0613f2 64     </sql>
I 65
dc050f 66     <!-- 首页查询-->
88f419 67     <select id="searchList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
0613f2 68         select
I 69         <include refid="Base_Column_List"/>
70097d 70         ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
0613f2 71         ,t.type_name as articleTypeName
I 72         from
73         blog_article a
a9c4c9 74         inner join blog_article_type t
0613f2 75         on t.id =a.article_type_id
I 76
77         left join sys_file_info f2
78         on f2.id=a.cover_file_id
79
80         <include refid="queryListCondition"/>
81
82         limit #{param.pageNo},#{param.pageSize}
83     </select>
84
dc050f 85     <!-- 首页查询个数统计-->
a9c4c9 86     <select id="searchListCount" resultType="java.lang.Long">
0613f2 87         select
I 88         count(0)
89         from
90         blog_article a
91         <include refid="queryListCondition"/>
92
93     </select>
94
dc050f 95     <!-- 月份归档统计-->
a9c4c9 96     <select id="searchMonthCount" resultType="vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo">
I 97        SELECT
98         separate_month AS `month`,
d80267 99         count(1) AS `count`
a9c4c9 100         FROM
I 101             blog_article
102         WHERE
103             (
104                 is_enable = 1
105                 AND editor_status = 1
106                 AND separate_year = #{separateYear}
20e5fc 107                 AND publish_date &lt; now()
a9c4c9 108             )
I 109         GROUP BY
110             separate_month
111         ORDER BY  separate_month desc
112
113     </select>
114
dc050f 115     <!-- 上下篇查询-->
I 116     <select id="getAdjoiningRecord" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
1e152b 117         select
I 118         a.id,
119         a.title
120         from
121         blog_article a
122         <include refid="queryListCondition"/>
123         limit #{param.pageNo},#{param.pageSize}
124     </select>
dc050f 125
I 126     <sql id="queryPlatformCondition">
127         <trim prefix="WHERE" prefixOverrides="AND | OR">
128             a.is_enable=1
129             and a.editor_status=1
130             and a.publish_date &lt; now()
131
132             <if test="param.fileType != null">
133                 and a.article_file_type = #{param.fileType}
134             </if>
135
136             AND a.article_type_id in
137             <foreach collection="param.typeIds" item="obj" separator="," open="(" close=")">
138                 #{obj}
139             </foreach>
140
141             order by a.is_top desc,a.top_value asc , a.publish_date desc
142         </trim>
143
144     </sql>
145
146     <!--月台列表查询-->
147     <select id="searchPlatformList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
148         select
149         <include refid="Base_Column_List"/>
150         ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
151         ,t.type_name as articleTypeName
152         from
153         blog_article a
154         inner join blog_article_type t
155         on t.id =a.article_type_id
156
157         left join sys_file_info f2
158         on f2.id=a.cover_file_id
159
160         <include refid="queryPlatformCondition"/>
161
162         limit #{param.pageNo},#{param.pageSize}
163     </select>
164
165     <select id="searchPlatformListCount" resultType="java.lang.Long">
166         select
167         count(0)
168         from
169         blog_article a
170         <include refid="queryPlatformCondition"/>
171     </select>
172
173
9bcb19 174 </mapper>