Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
Followers
Project_Team4
提交
05c98639
P
Project_Team4
项目概览
软件工程实践2022年春W班
/
Followers
/
Project_Team4
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Project_Team4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
05c98639
编写于
4月 29, 2022
作者:
LKJKJOIUIU
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
查询评论接口完善
上级
0f8843bb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
9 deletion
+46
-9
backend/src/main/java/com/nav/controller/PostController.java
backend/src/main/java/com/nav/controller/PostController.java
+9
-2
backend/src/main/java/com/nav/service/PostService.java
backend/src/main/java/com/nav/service/PostService.java
+1
-1
backend/src/main/java/com/nav/service/PostServiceImpl.java
backend/src/main/java/com/nav/service/PostServiceImpl.java
+2
-2
backend/src/main/java/com/nav/vo/result/CommentResult.java
backend/src/main/java/com/nav/vo/result/CommentResult.java
+28
-0
backend/src/main/resources/mapper/CommentMapper.xml
backend/src/main/resources/mapper/CommentMapper.xml
+6
-4
未找到文件。
backend/src/main/java/com/nav/controller/PostController.java
浏览文件 @
05c98639
...
...
@@ -3,6 +3,7 @@ package com.nav.controller;
import
com.nav.common.api.CommonResult
;
import
com.nav.pojo.Comment
;
import
com.nav.service.PostService
;
import
com.nav.vo.result.CommentResult
;
import
com.nav.vo.result.LifePostResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
...
...
@@ -10,7 +11,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 类说明
...
...
@@ -50,8 +53,12 @@ public class PostController {
}
@GetMapping
(
"comment/{id}"
)
public
List
<
Comment
>
getCommentByPostId
(
@PathVariable
long
id
)
{
return
postService
.
getCommentByPostId
(
id
);
public
Map
<
Integer
,
CommonResult
>
getCommentByPostId
(
@PathVariable
long
id
)
{
Map
<
Integer
,
CommonResult
>
map
=
new
HashMap
<>();
CommonResult
commonResult
=
postService
.
getCommentByPostId
(
id
);
List
<
CommentResult
>
commentResult
=
(
List
<
CommentResult
>)
commonResult
.
getData
();
map
.
put
(
commentResult
.
size
(),
commonResult
);
return
map
;
}
}
backend/src/main/java/com/nav/service/PostService.java
浏览文件 @
05c98639
...
...
@@ -67,5 +67,5 @@ public interface PostService {
* @param id:文章id
* @return:java.util.List<com.nav.pojo.Comment>
**/
public
List
<
Comment
>
getCommentByPostId
(
long
id
);
public
CommonResult
getCommentByPostId
(
long
id
);
}
backend/src/main/java/com/nav/service/PostServiceImpl.java
浏览文件 @
05c98639
...
...
@@ -49,7 +49,7 @@ public class PostServiceImpl implements PostService{
}
@Override
public
List
<
Comment
>
getCommentByPostId
(
long
id
)
{
return
commentDao
.
selectCommentByPostId
(
id
);
public
CommonResult
getCommentByPostId
(
long
id
)
{
return
CommonResult
.
success
(
commentDao
.
selectCommentByPostId
(
id
),
"请求成功"
);
}
}
backend/src/main/java/com/nav/vo/result/CommentResult.java
0 → 100644
浏览文件 @
05c98639
package
com.nav.vo.result
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
/**
* 类说明
* 根据文章id返回的评论内容以及评论者数据集
* @author zyx
* @date 2022/4/29 20:33
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
CommentResult
{
private
long
id
;
private
long
fromUserId
;
private
long
toPostId
;
private
long
parentId
;
private
String
commentContent
;
private
String
nickname
;
private
String
profilePicture
;
private
Date
gmtCreate
;
}
backend/src/main/resources/mapper/CommentMapper.xml
浏览文件 @
05c98639
...
...
@@ -3,10 +3,12 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.nav.dao.CommentDao"
>
<select
id=
"selectCommentByPostId"
parameterType=
"long"
resultType=
"com.nav.pojo.Comment"
>
select *
from comment
where to_post_id = #{id};
<select
id=
"selectCommentByPostId"
parameterType=
"long"
resultType=
"com.nav.vo.result.CommentResult"
>
select u.nickname,u.profile_picture,c.gmt_create,c.id,c.from_user_id,c.to_post_id,c.parent_id,c.comment_content
from comment c
left join user u
on c.from_user_id = u.id
where c.to_post_id = #{id};
</select>
</mapper>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录