评论,回复,删评

This commit is contained in:
sjm
2023-12-22 10:03:33 +08:00
parent 1399bfd1e5
commit ae032c0d53
5 changed files with 114 additions and 15 deletions

View File

@@ -1,26 +1,53 @@
package com.lovenav.controller;
import com.alibaba.fastjson2.JSONObject;
import com.lovenav.entity.Comment;
import com.lovenav.service.CommentService;
import com.lovenav.service.serviceImpl.CommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.HashMap;
@RestController
@RequestMapping("/comment")
public class CommentController {
@Autowired
private CommentService commentService;
// @GetMapping(value= "/AddLikeCount")
// public String AddLikeCount_Controller(HttpSession session){
// int id = (int) session.getAttribute("id");
// return commentService.AddLikeCount(id);
// }
@GetMapping(value= "/AddLikeCount")
public String AddLikeCount(int id){
return commentService.AddLikeCount(id);
// 评论功能
@RequestMapping(method = RequestMethod.POST, value = "/reply_comment")
public String Reply1(@RequestBody Comment comment){
return commentService.Reply1(comment);
}
// 回复功能
@RequestMapping(method = RequestMethod.POST, value = "/comment")
public String Reply2(@RequestBody Comment comment){
return commentService.Reply2(comment);
}
// 删除功能
@RequestMapping(method = RequestMethod.POST, value = "/delete_comment")
public String Delete(Comment comment){
return commentService.Delete(comment);
}
@RequestMapping(method = RequestMethod.GET, value = "/addLikeCount")
public String addLikeCount(int id){
return commentService.AddLikeCount(id);
// HttpServletResponse resp = null;
// PrintWriter writer = null;
// try {
// writer = resp.getWriter();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// writer.println(commentService.AddLikeCount(id));
}
}