Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
Followers
Project_Team4
提交
25266997
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 搜索 >>
提交
25266997
编写于
6月 06, 2022
作者:
LKJKJOIUIU
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
娱乐天地发布帖子接口
上级
f28689d2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
53 deletion
+52
-53
backend/src/main/java/com/nav/controller/PostController.java
backend/src/main/java/com/nav/controller/PostController.java
+23
-23
backend/src/main/java/com/nav/dao/PostDao.java
backend/src/main/java/com/nav/dao/PostDao.java
+9
-10
backend/src/main/java/com/nav/service/PostService.java
backend/src/main/java/com/nav/service/PostService.java
+9
-9
backend/src/main/java/com/nav/service/imp/PostServiceImpl.java
...nd/src/main/java/com/nav/service/imp/PostServiceImpl.java
+11
-11
未找到文件。
backend/src/main/java/com/nav/controller/PostController.java
浏览文件 @
25266997
...
...
@@ -73,29 +73,6 @@ public class PostController {
return
postService
.
updateCollectionCountById
(
userId
,
postId
);
}
//发布帖子
@PostMapping
(
"/addPost"
)
public
CommonResult
addPost
(
@RequestBody
Map
map
)
{
long
userId
=
Long
.
parseLong
(
String
.
valueOf
(
map
.
get
(
"userId"
)));
String
postTitle
=
String
.
valueOf
(
map
.
get
(
"postTitle"
));
String
postContent
=
String
.
valueOf
(
map
.
get
(
"postContent"
));
String
postCover
=
""
;
List
<
String
>
postCoverList
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
map
.
get
(
"postCoverList"
)),
String
.
class
);
for
(
int
i
=
0
;
i
<
postCoverList
.
size
();
i
++){
postCover
+=
postCoverList
.
get
(
i
)+
" "
;
}
int
topicType
=(
int
)
map
.
get
(
"topicType"
);
int
likeCount
=(
int
)
map
.
get
(
"likeCount"
);
int
viewCount
=(
int
)
map
.
get
(
"viewCount"
);
int
collectionCount
=(
int
)
map
.
get
(
"collectionCount"
);
int
postStatus
=(
int
)
map
.
get
(
"postStatus"
);
Date
gmtCreate
=
new
Date
();
Date
gmtModified
=
new
Date
();
String
tag
=
String
.
valueOf
(
map
.
get
(
"tag"
));
Post
post
=
new
Post
(
1
,
userId
,
postTitle
,
postContent
,
postCover
,
topicType
,
likeCount
,
viewCount
,
collectionCount
,
postStatus
,
gmtCreate
,
gmtModified
);
return
postService
.
addPost
(
post
,
tag
);
}
//根据用户id和文章id查找该用户是否点过赞
@GetMapping
(
"/post/isLike/{userId}/{postId}"
)
public
CommonResult
getLikeById
(
@PathVariable
long
userId
,
@PathVariable
long
postId
){
...
...
@@ -152,4 +129,27 @@ public class PostController {
public
CommonResult
getEntertainmentPostByTag
(
@PathVariable
String
tag
,
@PathVariable
long
userId
)
{
return
postService
.
getEntertainmentPostByTag
(
tag
,
userId
);
}
//发布帖子
@PostMapping
(
"/addPost"
)
public
CommonResult
addPost
(
@RequestBody
Map
map
)
{
long
userId
=
Long
.
parseLong
(
String
.
valueOf
(
map
.
get
(
"userId"
)));
String
postTitle
=
String
.
valueOf
(
map
.
get
(
"postTitle"
));
String
postContent
=
String
.
valueOf
(
map
.
get
(
"postContent"
));
String
postCover
=
""
;
List
<
String
>
postCoverList
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
map
.
get
(
"postCoverList"
)),
String
.
class
);
for
(
int
i
=
0
;
i
<
postCoverList
.
size
();
i
++){
postCover
+=
postCoverList
.
get
(
i
)+
" "
;
}
int
topicType
=(
int
)
map
.
get
(
"topicType"
);
int
likeCount
=
0
;
int
viewCount
=
0
;
int
collectionCount
=
0
;
int
postStatus
=
0
;
Date
gmtCreate
=
new
Date
();
Date
gmtModified
=
new
Date
();
String
tag
=
String
.
valueOf
(
map
.
get
(
"tag"
));
Post
post
=
new
Post
(
1
,
userId
,
postTitle
,
postContent
,
postCover
,
topicType
,
likeCount
,
viewCount
,
collectionCount
,
postStatus
,
gmtCreate
,
gmtModified
);
return
postService
.
addPost
(
post
,
tag
);
}
}
backend/src/main/java/com/nav/dao/PostDao.java
浏览文件 @
25266997
...
...
@@ -123,16 +123,6 @@ public interface PostDao {
**/
public
int
updateDownCollectionCountById
(
@Param
(
"userId"
)
long
userId
,
@Param
(
"postId"
)
long
postId
);
/**
* 方法说明:发布帖子
* @author zyx
* @date 2022/5/1 16:12
* @param post
* @return:long
**/
public
long
insertPost
(
@Param
(
"post"
)
Post
post
);
/**
* 方法说明:根据标签内容获取标签id
* @author zyx
...
...
@@ -199,4 +189,13 @@ public interface PostDao {
* @return:java.util.List<com.nav.vo.result.LifePostResult>
**/
public
List
<
LifePostResult
>
selectEntertainmentPostByTag
(
String
tag
);
/**
* 方法说明:发布帖子
* @author zyx
* @date 2022/6/6 21:09
* @param post
* @return:long
**/
public
long
insertPost
(
@Param
(
"post"
)
Post
post
);
}
backend/src/main/java/com/nav/service/PostService.java
浏览文件 @
25266997
...
...
@@ -144,15 +144,6 @@ public interface PostService {
**/
public
CommonResult
updateCollectionCountById
(
long
userId
,
long
postId
);
/**
* 方法说明:发布帖子
* @author zyx
* @date 2022/5/1 16:24
* @param post:帖子封装类,tag:帖子对应标签
* @return:com.nav.common.api.CommonResult
**/
public
CommonResult
addPost
(
Post
post
,
String
tag
);
/**
* 方法说明:用户对某篇文章发表评论
* @author zyx
...
...
@@ -209,4 +200,13 @@ public interface PostService {
* @return:com.nav.common.api.CommonResult
**/
public
CommonResult
getEntertainmentPostByTag
(
String
tag
,
long
userId
);
/**
* 方法说明:发布帖子
* @author zyx
* @date 2022/6/6 21:08
* @param post:帖子封装类,tag:帖子对应标签
* @return:com.nav.common.api.CommonResult
**/
public
CommonResult
addPost
(
Post
post
,
String
tag
);
}
backend/src/main/java/com/nav/service/imp/PostServiceImpl.java
浏览文件 @
25266997
...
...
@@ -182,17 +182,6 @@ public class PostServiceImpl implements PostService {
}
}
@Override
public
CommonResult
addPost
(
Post
post
,
String
tag
)
{
//添加文章
postDao
.
insertPost
(
post
);
long
postId
=
post
.
getId
();
//关联文章标签
long
tagId
=
postDao
.
selectTagIdByTagContent
(
tag
);
postDao
.
insertPostTag
(
postId
,
tagId
,
new
Date
(),
new
Date
());
return
CommonResult
.
success
(
postId
,
"请求成功"
);
}
@Override
public
void
addCommentByPostId
(
Comment
comment
)
{
postDao
.
insertCommentByPostId
(
comment
);
...
...
@@ -273,4 +262,15 @@ public class PostServiceImpl implements PostService {
}
return
CommonResult
.
success
(
list
,
"请求成功"
);
}
@Override
public
CommonResult
addPost
(
Post
post
,
String
tag
)
{
//添加文章
postDao
.
insertPost
(
post
);
long
postId
=
post
.
getId
();
//关联文章标签
long
tagId
=
postDao
.
selectTagIdByTagContent
(
tag
);
postDao
.
insertPostTag
(
postId
,
tagId
,
new
Date
(),
new
Date
());
return
CommonResult
.
success
(
postId
,
"请求成功"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录