remove Article ABOUT type,classId and add canList attr

This commit is contained in:
Timi
2025-07-22 14:16:24 +08:00
parent 2de29cb3a8
commit 53230943e8
2 changed files with 23 additions and 35 deletions

View File

@ -25,9 +25,6 @@ public class Article extends Entity implements CommentSupport, Destroyable {
*/ */
public enum Type { public enum Type {
/** 关于 */
ABOUT,
/** 公版 */ /** 公版 */
PUBLIC, PUBLIC,
@ -44,9 +41,6 @@ public class Article extends Entity implements CommentSupport, Destroyable {
/** 类型 */ /** 类型 */
protected Type type; protected Type type;
/** 分类 ID */
protected long classId;
/** 摘要 */ /** 摘要 */
protected String digest; protected String digest;
@ -62,7 +56,7 @@ public class Article extends Entity implements CommentSupport, Destroyable {
/** 喜欢数量 */ /** 喜欢数量 */
protected int likes; protected int likes;
/** 是否显示评论 */ /** true 为显示评论 */
protected boolean showComment; protected boolean showComment;
/** true 为可评论 */ /** true 为可评论 */
@ -71,6 +65,9 @@ public class Article extends Entity implements CommentSupport, Destroyable {
/** true 为可排位 */ /** true 为可排位 */
protected boolean canRanking; protected boolean canRanking;
/** true 为可通过列表查询 */
protected boolean canList;
/** @return true 为可评论 */ /** @return true 为可评论 */
@Override @Override
public boolean canComment() { public boolean canComment() {

View File

@ -2,27 +2,24 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.imyeyu.server.modules.blog.mapper.ArticleMapper"> <mapper namespace="com.imyeyu.server.modules.blog.mapper.ArticleMapper">
<sql id="table">article</sql> <sql id="table">article</sql>
<!-- 查询列表的文章字段 --> <!-- 查询列表的文章字段 -->
<sql id="listColumn"> <sql id="listColumn">
article.id, `id`,
article.type, `type`,
article.title, `title`,
article.digest, `digest`,
article.likes, `likes`,
article.reads, `reads`,
article.created_at, `created_at`,
article.updated_at `updated_at`
</sql> </sql>
<!-- 列表 -->
<!-- 主页列表 -->
<sql id="normalCondition"> <sql id="normalCondition">
FROM FROM
article article
WHERE WHERE
1 &lt; article.id can_list IS TRUE
AND article.deleted_at IS NULL AND deleted_at IS NULL
</sql> </sql>
<select id="count" resultType="long"> <select id="count" resultType="long">
SELECT COUNT(1) <include refid="normalCondition" /> SELECT COUNT(1) <include refid="normalCondition" />
@ -32,23 +29,17 @@
<include refid="listColumn" /> <include refid="listColumn" />
<include refid="normalCondition" /> <include refid="normalCondition" />
ORDER BY ORDER BY
COALESCE(article.updated_at, article.created_at) DESC COALESCE(updated_at, created_at) DESC
LIMIT LIMIT
#{offset}, #{limit} #{offset}, #{limit}
</select> </select>
<!-- 根据关键字获取列表 --> <!-- 根据关键字获取列表 -->
<sql id="byKeywordCondition"> <sql id="byKeywordCondition">
FROM <include refid="normalCondition" />
article AND (
WHERE `title` LIKE CONCAT('%', #{keyword}, '%')
1 &lt; article.id OR `digest` LIKE CONCAT('%', #{keyword}, '%')
AND ( )
article.title LIKE CONCAT('%', #{keyword}, '%')
OR article.digest LIKE CONCAT('%', #{keyword}, '%')
)
AND article.deleted_at IS NULL
</sql> </sql>
<select id="countByKeyword" resultType="long"> <select id="countByKeyword" resultType="long">
SELECT COUNT(1) <include refid="byKeywordCondition" /> SELECT COUNT(1) <include refid="byKeywordCondition" />
@ -58,8 +49,8 @@
<include refid="listColumn" /> <include refid="listColumn" />
<include refid="byKeywordCondition" /> <include refid="byKeywordCondition" />
ORDER BY ORDER BY
COALESCE(article.updated_at, article.created_at) DESC COALESCE(updated_at, created_at) DESC
LIMIT LIMIT
#{offset}, #{limit} #{offset}, #{limit}
</select> </select>
</mapper> </mapper>