64 lines
2.6 KiB
XML
64 lines
2.6 KiB
XML
<?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="com.cxx.admin.dao.BlogDao">
|
|
<select id="queryBlogByPage" resultType="com.cxx.common.dto.blog.BlogDto">
|
|
SELECT a.id AS id,
|
|
a.title AS title,
|
|
a.top_value AS topValue,
|
|
a.is_great AS isGreat,
|
|
b.NAME AS category,
|
|
a.summary AS summary,
|
|
a.word_count AS wordCount,
|
|
a.read_duration AS readDuration,
|
|
COUNT(c.id) AS visitCount,
|
|
a.create_time AS createTime,
|
|
a.update_time AS updateTime
|
|
FROM blog a
|
|
LEFT JOIN blog_category b ON b.id = a.category_id
|
|
LEFT JOIN blog_visit c ON c.blog_id = a.id
|
|
GROUP BY a.id
|
|
ORDER BY a.top_value DESC,
|
|
a.update_time DESC
|
|
</select>
|
|
|
|
<select id="queryBlogById" resultType="com.cxx.common.dto.blog.BlogDto">
|
|
SELECT a.id AS id,
|
|
a.title AS title,
|
|
a.top_value AS topValue,
|
|
a.is_great AS isGreat,
|
|
b.NAME AS category,
|
|
a.summary AS summary,
|
|
c.content AS content,
|
|
a.word_count AS wordCount,
|
|
a.read_duration AS readDuration,
|
|
COUNT(d.id) AS visitCount,
|
|
a.create_time AS createTime,
|
|
a.update_time AS updateTime
|
|
FROM blog a
|
|
LEFT JOIN blog_category b ON b.id = a.category_id
|
|
LEFT JOIN blog_content c ON c.id = a.content_id
|
|
LEFT JOIN blog_visit d ON d.blog_id = a.id
|
|
WHERE a.id = #{id} LIMIT 1
|
|
</select>
|
|
|
|
<select id="queryBlogCategory" resultType="com.cxx.common.dto.blog.BlogCategoryDto">
|
|
SELECT b.name AS name,
|
|
count(b.name) AS count
|
|
FROM blog a
|
|
LEFT JOIN blog_category b
|
|
ON a.category_id = b.id
|
|
GROUP BY b.name
|
|
</select>
|
|
|
|
<select id="queryBlogVisit" resultType="com.cxx.common.dto.blog.BlogVisitDto">
|
|
SELECT a.ip AS ip,
|
|
a.os AS os,
|
|
a.browser AS browser,
|
|
a.uri AS uri,
|
|
b.title AS title,
|
|
a.create_time AS visitTime
|
|
FROM blog_visit AS a
|
|
LEFT JOIN blog AS b on a.blog_id = b.id
|
|
ORDER BY a.create_time DESC
|
|
</select>
|
|
</mapper> |