u
This commit is contained in:
1 parent
9bf7c40b70
commit
9eb5639d84
24 files changed
+915
-98
No files matched your search
@@ -0,0 +1,98 @@
|
||||
<?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="cn.link56.post.mapper.PostMapper">
|
||||
|
||||
<resultMap id="QueryPostVOMap"
|
||||
type="cn.link56.post.model.vo.QueryPostVO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="cover" column="cover"/>
|
||||
|
||||
<!-- tags 字符串 → List<String> -->
|
||||
<result
|
||||
property="tags"
|
||||
column="tagsString"
|
||||
typeHandler="cn.link56.common.mybatis.StringListTypeHandler"/>
|
||||
|
||||
<result property="publishTime" column="publishTime"/>
|
||||
<result property="updateTime" column="updateTime"/>
|
||||
<result property="status" column="status"/>
|
||||
|
||||
<result property="viewCount" column="viewCount"/>
|
||||
<result property="likeCount" column="likeCount"/>
|
||||
<result property="favoriteCount" column="favoriteCount"/>
|
||||
<result property="commentCount" column="commentCount"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryPostPage" resultMap="QueryPostVOMap">
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
p.b_id AS id,
|
||||
p.b_title AS title,
|
||||
p.b_cover AS cover,
|
||||
p.b_tag AS tagsString,
|
||||
p.b_update_time AS updateTime,
|
||||
p.b_publish_time AS publishTime,
|
||||
p.b_status AS status,
|
||||
|
||||
(SELECT COUNT(*) FROM b_post_view v WHERE v.b_post_id = p.b_id) AS viewCount,
|
||||
(SELECT COUNT(*) FROM b_post_like l WHERE l.b_post_id = p.b_id) AS likeCount,
|
||||
(SELECT COUNT(*) FROM b_post_favorite f WHERE f.b_post_id = p.b_id) AS favoriteCount,
|
||||
(SELECT COUNT(*) FROM b_post_comment c WHERE c.b_post_id = p.b_id) AS commentCount,
|
||||
|
||||
ROW_NUMBER() OVER (ORDER BY p.b_update_time DESC) AS rn
|
||||
FROM b_post p
|
||||
<where>
|
||||
<if test="userId != null">
|
||||
AND p.b_create_by = #{userId}
|
||||
</if>
|
||||
|
||||
<if test="status != null and status != -1">
|
||||
AND p.b_status = #{status}
|
||||
</if>
|
||||
|
||||
<if test="title != null and title != ''">
|
||||
AND p.b_title LIKE '%' + #{title} + '%'
|
||||
</if>
|
||||
|
||||
<if test="year != null and year != ''">
|
||||
AND YEAR(p.b_update_time) = #{year}
|
||||
</if>
|
||||
|
||||
<if test="month != null and month != ''">
|
||||
AND MONTH(p.b_update_time) = #{month}
|
||||
</if>
|
||||
</where>
|
||||
) t
|
||||
WHERE t.rn BETWEEN #{offset} AND #{limit}
|
||||
</select>
|
||||
|
||||
<select id="queryPostTotal" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM b_post p
|
||||
<where>
|
||||
<if test="userId != null">
|
||||
AND p.b_create_by = #{userId}
|
||||
</if>
|
||||
|
||||
<if test="status != null and status != -1">
|
||||
AND p.b_status = #{status}
|
||||
</if>
|
||||
|
||||
<if test="title != null and title != ''">
|
||||
AND p.b_title LIKE '%' + #{title} + '%'
|
||||
</if>
|
||||
|
||||
<if test="year != null and year != ''">
|
||||
AND YEAR(p.b_update_time) = #{year}
|
||||
</if>
|
||||
|
||||
<if test="month != null and month != ''">
|
||||
AND MONTH(p.b_update_time) = #{month}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user