新增[评论点赞]
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.lxyer.service;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.model.ActLog;
|
||||
import com.lxyer.model.Comment;
|
||||
import com.lxyer.model.Content;
|
||||
|
||||
@@ -22,4 +24,34 @@ public class CommentService {
|
||||
//更新评论数
|
||||
Content.upReplyNum(comment.getContentId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 评论点赞
|
||||
* @param commentId
|
||||
* @param ok
|
||||
* @param userId
|
||||
* @throws Exception
|
||||
*/
|
||||
public void support(Integer commentId, Integer ok, Integer userId) throws Exception {
|
||||
Comment comment = Comment.dao.findById(commentId);
|
||||
if (comment == null)
|
||||
throw new Exception("操作失败,未查询到相关信息");
|
||||
|
||||
ActLog actLog = ActLog.dao.findFirst(Kv.by("userId", userId).set("tid", commentId).set("cate", 1));
|
||||
if (actLog == null){
|
||||
actLog = new ActLog();
|
||||
actLog.setTid(commentId);
|
||||
actLog.setUserId(userId);
|
||||
actLog.setCate(1);
|
||||
actLog.setStatus(1);
|
||||
actLog.setCreateTime(System.currentTimeMillis());
|
||||
actLog.save();
|
||||
}else if (actLog.getStatus() != ok){
|
||||
actLog.setStatus(ok == 1 ? 1 : -1);
|
||||
actLog.setCreateTime(System.currentTimeMillis());
|
||||
actLog.update();
|
||||
}
|
||||
|
||||
Comment.upSupportNum(commentId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user