Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智布道
OneBlog
提交
2dbf7256
O
OneBlog
项目概览
智布道
/
OneBlog
10 个月 前同步成功
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2dbf7256
编写于
3月 28, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🐛
修复统计文章评论数错误的问题
上级
a3d0f2eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
4 deletion
+26
-4
blog-core/pom.xml
blog-core/pom.xml
+4
-0
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizArticleServiceImpl.java
...zyd/blog/business/service/impl/BizArticleServiceImpl.java
+6
-3
blog-core/src/main/java/com/zyd/blog/util/ResultUtil.java
blog-core/src/main/java/com/zyd/blog/util/ResultUtil.java
+4
-0
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
+12
-1
未找到文件。
blog-core/pom.xml
浏览文件 @
2dbf7256
...
...
@@ -158,6 +158,10 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
<dependency>
<groupId>
javax.validation
</groupId>
<artifactId>
validation-api
</artifactId>
...
...
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizArticleServiceImpl.java
浏览文件 @
2dbf7256
...
...
@@ -6,6 +6,7 @@ import com.zyd.blog.business.annotation.RedisCache;
import
com.zyd.blog.business.entity.Article
;
import
com.zyd.blog.business.entity.User
;
import
com.zyd.blog.business.enums.ArticleStatusEnum
;
import
com.zyd.blog.business.enums.CommentStatusEnum
;
import
com.zyd.blog.business.enums.FileUploadType
;
import
com.zyd.blog.business.enums.ResponseStatus
;
import
com.zyd.blog.business.service.BizArticleService
;
...
...
@@ -383,9 +384,11 @@ public class BizArticleServiceImpl implements BizArticleService {
entity
.
setLookCount
(
bizArticleLookMapper
.
selectCount
(
look
));
// 评论数
BizComment
comment
=
new
BizComment
();
comment
.
setSid
(
primaryKey
);
entity
.
setCommentCount
(
commentMapper
.
selectCount
(
comment
));
Example
example
=
new
Example
(
BizComment
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"sid"
,
primaryKey
);
criteria
.
andEqualTo
(
"status"
,
CommentStatusEnum
.
APPROVED
.
toString
());
entity
.
setCommentCount
(
commentMapper
.
selectCountByExample
(
example
));
// 喜欢的次数
BizArticleLove
love
=
new
BizArticleLove
();
...
...
blog-core/src/main/java/com/zyd/blog/util/ResultUtil.java
浏览文件 @
2dbf7256
...
...
@@ -50,6 +50,10 @@ public class ResultUtil {
return
vo
(
CommonConst
.
DEFAULT_SUCCESS_CODE
,
message
,
data
);
}
public
static
ResponseVO
success
(
Object
data
)
{
return
vo
(
ResponseStatus
.
SUCCESS
.
getCode
(),
ResponseStatus
.
SUCCESS
.
getMessage
(),
data
);
}
public
static
ResponseVO
success
(
String
message
)
{
return
success
(
message
,
null
);
}
...
...
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
浏览文件 @
2dbf7256
...
...
@@ -213,7 +213,8 @@
a.`comment`,
a.create_time,
a.update_time,
l.lookCount AS look_count
l.lookCount AS look_count,
c.commentCount AS comment_count
FROM
biz_article a
LEFT JOIN (
...
...
@@ -225,6 +226,16 @@
GROUP BY
l.article_id
) l ON a.id = l.article_id
LEFT JOIN (
SELECT
c.sid,
IFNULL(count(1), 0) AS commentCount
FROM
biz_comment c
WHERE c.`status` = 'APPROVED'
GROUP BY
c.sid
) c ON a.id = c.sid
WHERE a.status = 1
ORDER BY
l.lookCount DESC
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录