添加点赞++功能
This commit is contained in:
parent
a001f2f05f
commit
09165ec608
22
src/main/java/com/lovenav/controller/CommentComtroller.java
Normal file
22
src/main/java/com/lovenav/controller/CommentComtroller.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -9,6 +9,86 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class Comment implements Serializable {
|
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
|
* id
|
||||||
*/
|
*/
|
||||||
|
8
src/main/java/com/lovenav/service/CommentService.java
Normal file
8
src/main/java/com/lovenav/service/CommentService.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.lovenav.service;
|
||||||
|
|
||||||
|
import com.lovenav.entity.Comment;
|
||||||
|
|
||||||
|
public interface CommentService {
|
||||||
|
// 点赞
|
||||||
|
public int AddLikeCount(Comment comment);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user