inleft
2022-08-25 d807fd2490a86bc99bb5abbe9566a63af63a6131
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>
cb2e50 41                 <when test="param.typeId != null">
I 42                     AND a.article_type_id = #{param.typeId}
20e5fc 43                     order by a.is_top desc,a.top_value asc , a.publish_date desc
cb2e50 44                 </when>
1e152b 45
cb2e50 46                 <otherwise>
fae101 47                     <!-- 首页不出现视频等文件类型-->
I 48                     <if test="param.faceExcludeFile != null">
49                         and a.article_file_type not in
50                         <foreach collection="param.faceExcludeFile" item="obj" separator="," open="(" close=")">
51                             #{obj}
52                         </foreach>
53                     </if>
ba780f 54                     order by a.is_top desc,a.top_value asc , a.update_date desc
cb2e50 55                 </otherwise>
I 56             </choose>
0613f2 57         </trim>
cb2e50 58
0613f2 59     </sql>
I 60
dc050f 61     <!-- 首页查询-->
88f419 62     <select id="searchList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
0613f2 63         select
I 64         <include refid="Base_Column_List"/>
70097d 65         ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
0613f2 66         ,t.type_name as articleTypeName
I 67         from
68         blog_article a
a9c4c9 69         inner join blog_article_type t
0613f2 70         on t.id =a.article_type_id
fae101 71
I 72         <!-- 排除首页不查询的分类-->
73         <if test="param.typeId == null">
74             and t.is_show_face = 1
75         </if>
0613f2 76
I 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
fae101 132             <if test="param.id != null">
I 133                 and a.id = #{param.id}
134             </if>
135
dc050f 136             <if test="param.fileType != null">
I 137                 and a.article_file_type = #{param.fileType}
138             </if>
139
140             AND a.article_type_id in
141             <foreach collection="param.typeIds" item="obj" separator="," open="(" close=")">
142                 #{obj}
143             </foreach>
144
145             order by a.is_top desc,a.top_value asc , a.publish_date desc
146         </trim>
147
148     </sql>
149
150     <!--月台列表查询-->
151     <select id="searchPlatformList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
152         select
153         <include refid="Base_Column_List"/>
154         ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL
155         ,t.type_name as articleTypeName
156         from
157         blog_article a
158         inner join blog_article_type t
159         on t.id =a.article_type_id
160
161         left join sys_file_info f2
162         on f2.id=a.cover_file_id
163
164         <include refid="queryPlatformCondition"/>
165
166         limit #{param.pageNo},#{param.pageSize}
167     </select>
168
169     <select id="searchPlatformListCount" resultType="java.lang.Long">
170         select
171         count(0)
172         from
173         blog_article a
174         <include refid="queryPlatformCondition"/>
175     </select>
176
177
9bcb19 178 </mapper>