修正comment,banner接口

This commit is contained in:
sjm
2023-12-22 14:03:59 +08:00
parent 39048bbcfc
commit 7d3f10a7dc
11 changed files with 224 additions and 23 deletions

View File

@@ -3,6 +3,7 @@ package com.lovenav.service.serviceImpl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.lovenav.dao.CommentDao;
import com.lovenav.dao.UserDao;
import com.lovenav.entity.Comment;
import com.lovenav.service.CommentService;
import org.apache.ibatis.jdbc.Null;
@@ -13,10 +14,12 @@ import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
@Service("commentService")
@Service
public class CommentServiceImpl implements CommentService {
@Autowired
private CommentDao commentDao;
@Autowired
private UserDao userDao;
// 评论功能
@Override
public String Reply1(Comment comment){
@@ -32,18 +35,11 @@ public class CommentServiceImpl implements CommentService {
}
// 回复功能
@Override
public String Reply2(Comment comment){
List<Integer> list = commentDao.selectByRootId(comment.getRootCommentId());
if(list.size()<5){
commentDao.insert(comment);
return JSON.toJSONString(comment);
}else{
HashMap<String, Object> result = new HashMap<>();
result.put("code", 500);
result.put("msg", "回复超过上限");
String jsonString = JSONObject.toJSONString(result);
return JSON.toJSONString(result);
}
public String Reply2(Comment comment,int id){
String name = (userDao.selectByPrimaryKey(id)).getNickname();
HashMap<Comment,String> hashMap = new HashMap<>();
hashMap.put(comment, name);
return JSON.toJSONString(hashMap);
}
// 删除
@Override
@@ -67,7 +63,13 @@ public class CommentServiceImpl implements CommentService {
comment.setLikeCount(comment.getLikeCount()+1);
commentDao.updateByPrimaryKeySelective(comment);
HashMap<String, Long> hashMap = new HashMap<>();
hashMap.put("点赞成功:",comment.getLikeCount());
hashMap.put("点赞成功",comment.getLikeCount());
return JSON.toJSONString(hashMap);
}
// 显示评论
public String View_comment(){
List<Comment> list = commentDao.selectByAllComment();
return JSON.toJSONString(list);
}
}