@Override public List<Comment> listCommentAndPraise(Comment comment, PageBase pageBase) { List<?> commentList = commentDao.listComment(comment); commentList = CommonUtils.createListPage(commentList, pageBase); List<Comment> returnCommentList = new ArrayList<Comment>(); for (Object objTmp : commentList) { // 判断每个comment Comment commentTmp = ((Comment) objTmp); // 判断每个评论的点赞数 Praise praise = new Praise(); praise.setPraisetype(Constant.PRAISE_TYPE_COMMENT); praise.setOtherid(commentTmp.getCommentid()); commentTmp.setPraisecount(praiseDao.countPraise(praise)); praise.setUserid(comment.getUserid()); if (null == praiseDao.detailPraise(praise)) { // 如果点赞为空,则说明还未点赞 commentTmp.setIspraise(Constant.COMMENT_NOT_PRAISE); } else { // 如果点赞不为空,则说明已经点赞 commentTmp.setIspraise(Constant.COMMENT_HAS_PRAISE); } // 清理掉无关的 commentTmp.setUserid(null); returnCommentList.add(commentTmp); } return returnCommentList; }
@Override public int countComment(Comment comment) { return commentDao.countComment(comment); }
@Override public int addComment(Comment comment) { return commentDao.insert(comment); }
@Override public int deleteComment(int uid) { return commentDao.deleteByPrimaryKey(uid); }
@Override public int updateComment(Comment comment) { return commentDao.updateByPrimaryKeySelective(comment); }
@Override public Comment detailComment(Comment comment) { return commentDao.detailComment(comment); }
@Override public List<Comment> listComment(Comment comment) { return commentDao.listComment(comment); }