remove Article ABOUT type,classId and add canList attr
This commit is contained in:
@ -25,9 +25,6 @@ public class Article extends Entity implements CommentSupport, Destroyable {
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/** 关于 */
|
||||
ABOUT,
|
||||
|
||||
/** 公版 */
|
||||
PUBLIC,
|
||||
|
||||
@ -44,9 +41,6 @@ public class Article extends Entity implements CommentSupport, Destroyable {
|
||||
/** 类型 */
|
||||
protected Type type;
|
||||
|
||||
/** 分类 ID */
|
||||
protected long classId;
|
||||
|
||||
/** 摘要 */
|
||||
protected String digest;
|
||||
|
||||
@ -62,7 +56,7 @@ public class Article extends Entity implements CommentSupport, Destroyable {
|
||||
/** 喜欢数量 */
|
||||
protected int likes;
|
||||
|
||||
/** 是否显示评论 */
|
||||
/** true 为显示评论 */
|
||||
protected boolean showComment;
|
||||
|
||||
/** true 为可评论 */
|
||||
@ -71,6 +65,9 @@ public class Article extends Entity implements CommentSupport, Destroyable {
|
||||
/** true 为可排位 */
|
||||
protected boolean canRanking;
|
||||
|
||||
/** true 为可通过列表查询 */
|
||||
protected boolean canList;
|
||||
|
||||
/** @return true 为可评论 */
|
||||
@Override
|
||||
public boolean canComment() {
|
||||
|
||||
@ -2,27 +2,24 @@
|
||||
<!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">
|
||||
<sql id="table">article</sql>
|
||||
|
||||
<!-- 查询列表的文章字段 -->
|
||||
<sql id="listColumn">
|
||||
article.id,
|
||||
article.type,
|
||||
article.title,
|
||||
article.digest,
|
||||
article.likes,
|
||||
article.reads,
|
||||
article.created_at,
|
||||
article.updated_at
|
||||
`id`,
|
||||
`type`,
|
||||
`title`,
|
||||
`digest`,
|
||||
`likes`,
|
||||
`reads`,
|
||||
`created_at`,
|
||||
`updated_at`
|
||||
</sql>
|
||||
|
||||
|
||||
<!-- 主页列表 -->
|
||||
<!-- 列表 -->
|
||||
<sql id="normalCondition">
|
||||
FROM
|
||||
article
|
||||
WHERE
|
||||
1 < article.id
|
||||
AND article.deleted_at IS NULL
|
||||
can_list IS TRUE
|
||||
AND deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="count" resultType="long">
|
||||
SELECT COUNT(1) <include refid="normalCondition" />
|
||||
@ -32,23 +29,17 @@
|
||||
<include refid="listColumn" />
|
||||
<include refid="normalCondition" />
|
||||
ORDER BY
|
||||
COALESCE(article.updated_at, article.created_at) DESC
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据关键字获取列表 -->
|
||||
<sql id="byKeywordCondition">
|
||||
FROM
|
||||
article
|
||||
WHERE
|
||||
1 < article.id
|
||||
AND (
|
||||
article.title LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR article.digest LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
AND article.deleted_at IS NULL
|
||||
<include refid="normalCondition" />
|
||||
AND (
|
||||
`title` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `digest` LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
</sql>
|
||||
<select id="countByKeyword" resultType="long">
|
||||
SELECT COUNT(1) <include refid="byKeywordCondition" />
|
||||
@ -58,8 +49,8 @@
|
||||
<include refid="listColumn" />
|
||||
<include refid="byKeywordCondition" />
|
||||
ORDER BY
|
||||
COALESCE(article.updated_at, article.created_at) DESC
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user