评论,回复,删评

This commit is contained in:
sjm 2023-12-22 10:35:12 +08:00
parent 1201edf7d5
commit 2d15b6b773
2 changed files with 8 additions and 11 deletions

View File

@ -9,6 +9,10 @@ import lombok.Data;
*/ */
@Data @Data
public class Comment implements Serializable { public class Comment implements Serializable {
public Comment(){
this.likeCount = Long.valueOf(0);
this.commentStatus = 1;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }

View File

@ -23,8 +23,7 @@ public class CommentServiceImpl implements CommentService {
int result = commentDao.insert(comment); int result = commentDao.insert(comment);
HashMap<String, Object> hashMap = new HashMap<>(); HashMap<String, Object> hashMap = new HashMap<>();
if(result > 0){ if(result > 0){
hashMap.put("msg", "评论成功"); return JSON.toJSONString(comment);
return JSON.toJSONString(hashMap);
} }
else{ else{
hashMap.put("msg", "评论失败"); hashMap.put("msg", "评论失败");
@ -64,15 +63,9 @@ public class CommentServiceImpl implements CommentService {
@Override @Override
public String AddLikeCount(int id){ public String AddLikeCount(int id){
Comment comment = commentDao.selectByPrimaryKey(id); Comment comment = commentDao.selectByPrimaryKey(id);
if(comment.getLikeCount() == 0){
}
comment.setLikeCount(comment.getLikeCount()+1); comment.setLikeCount(comment.getLikeCount()+1);
int result = commentDao.updateByPrimaryKey(comment); HashMap<String, Long> hashMap = new HashMap<>();
if(result>0){ hashMap.put("点赞成功:",comment.getLikeCount());
return JSONObject.toJSONString(comment.getLikeCount()); return JSON.toJSONString(hashMap);
}else{
return JSONObject.toJSONString("点赞失败");
}
} }
} }