点赞++2
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.lovenav.service;
|
||||
|
||||
import com.lovenav.entity.Comment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
public interface CommentService {
|
||||
// 点赞
|
||||
public String AddLikeCount(Comment comment);
|
||||
public String AddLikeCount(int id);
|
||||
}
|
||||
|
@@ -4,18 +4,21 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.lovenav.dao.CommentDao;
|
||||
import com.lovenav.entity.Comment;
|
||||
import com.lovenav.service.CommentService;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Service("commentService")
|
||||
public class CommentServiceImpl implements CommentService {
|
||||
|
||||
@Autowired
|
||||
private CommentDao commentDao;
|
||||
|
||||
// 点赞++
|
||||
public String AddLikeCount(Comment comment){
|
||||
@Override
|
||||
public String AddLikeCount(int id){
|
||||
Comment comment = commentDao.selectByPrimaryKey(id);
|
||||
comment.setLikeCount(comment.getLikeCount()+1);
|
||||
commentDao.updateByPrimaryKeySelective(comment);
|
||||
return JSONObject.toJSONString(comment);
|
||||
commentDao.updateByPrimaryKey(comment);
|
||||
return JSONObject.toJSONString(comment.getLikeCount());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user