From 09165ec608202ac4ef539565bdd0a3c726d360a7 Mon Sep 17 00:00:00 2001 From: sjm <2431685932@qq.com> Date: Wed, 20 Dec 2023 17:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=82=B9=E8=B5=9E++=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lovenav/controller/CommentComtroller.java | 22 +++++ src/main/java/com/lovenav/entity/Comment.java | 80 +++++++++++++++++++ .../com/lovenav/service/CommentService.java | 8 ++ .../serviceImpl/CommentServiceImpl.java | 17 ++++ 4 files changed, 127 insertions(+) create mode 100644 src/main/java/com/lovenav/controller/CommentComtroller.java create mode 100644 src/main/java/com/lovenav/service/CommentService.java create mode 100644 src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java diff --git a/src/main/java/com/lovenav/controller/CommentComtroller.java b/src/main/java/com/lovenav/controller/CommentComtroller.java new file mode 100644 index 0000000..5adf5d3 --- /dev/null +++ b/src/main/java/com/lovenav/controller/CommentComtroller.java @@ -0,0 +1,22 @@ +package com.lovenav.controller; + +import com.lovenav.entity.Comment; +import com.lovenav.service.CommentService; +import com.lovenav.service.serviceImpl.CommentServiceImpl; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class CommentComtroller { + private CommentServiceImpl commentServiceImpl; + @PostMapping(value= "/AddLikeCount",produces="application/json;charset=UTF-8") + public int AddLikeCount(@RequestBody Comment comment) { + return commentServiceImpl.AddLikeCount(comment); + } + + +} diff --git a/src/main/java/com/lovenav/entity/Comment.java b/src/main/java/com/lovenav/entity/Comment.java index 8a33e5c..145ccd9 100644 --- a/src/main/java/com/lovenav/entity/Comment.java +++ b/src/main/java/com/lovenav/entity/Comment.java @@ -9,6 +9,86 @@ import lombok.Data; */ @Data public class Comment implements Serializable { + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUrlId() { + return urlId; + } + + public void setUrlId(Integer urlId) { + this.urlId = urlId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getRootCommentId() { + return rootCommentId; + } + + public void setRootCommentId(Integer rootCommentId) { + this.rootCommentId = rootCommentId; + } + + public Long getLikeCount() { + return likeCount; + } + + public void setLikeCount(Long likeCount) { + this.likeCount = likeCount; + } + + public Date getCommentTime() { + return commentTime; + } + + public void setCommentTime(Date commentTime) { + this.commentTime = commentTime; + } + + public Byte getCommentStatus() { + return commentStatus; + } + + public void setCommentStatus(Byte commentStatus) { + this.commentStatus = commentStatus; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Integer getRating() { + return rating; + } + + public void setRating(Integer rating) { + this.rating = rating; + } + /** * id */ diff --git a/src/main/java/com/lovenav/service/CommentService.java b/src/main/java/com/lovenav/service/CommentService.java new file mode 100644 index 0000000..c1838ac --- /dev/null +++ b/src/main/java/com/lovenav/service/CommentService.java @@ -0,0 +1,8 @@ +package com.lovenav.service; + +import com.lovenav.entity.Comment; + +public interface CommentService { +// 点赞 + public int AddLikeCount(Comment comment); +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java new file mode 100644 index 0000000..00292e2 --- /dev/null +++ b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java @@ -0,0 +1,17 @@ +package com.lovenav.service.serviceImpl; + +import com.lovenav.dao.CommentDao; +import com.lovenav.entity.Comment; +import com.lovenav.service.CommentService; +import org.springframework.beans.factory.annotation.Autowired; + +public class CommentServiceImpl implements CommentService { + + private CommentDao commentDao; + + // 点赞++ + public int AddLikeCount(Comment comment){ + comment.setLikeCount(comment.getLikeCount()+1); + return commentDao.updateByPrimaryKeySelective(comment); + } +}