提交 25266997 编写于 作者: LKJKJOIUIU's avatar LKJKJOIUIU

娱乐天地发布帖子接口

上级 f28689d2
......@@ -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);
}
}
......@@ -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);
}
......@@ -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);
}
......@@ -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.
先完成此消息的编辑!
想要评论请 注册