Search in sources :

Example 1 with BlogComment

use of com.duan.blogos.entity.blog.BlogComment in project BlogSystem by DuanJiaNing.

the class BlogBrowseServiceImpl method listBlogComment.

@Override
public ResultBean<List<BlogCommentDTO>> listBlogComment(int blogId, int offset, int rows) {
    List<BlogCommentDTO> result = new ArrayList<>();
    List<BlogComment> comments = commentDao.listCommentByBlogId(blogId, offset, rows, BlogCommentStatusEnum.RIGHTFUL.getCode());
    for (BlogComment comment : comments) {
        // 评论者数据
        int sid = comment.getSpokesmanId();
        BloggerAccount smAccount = accountDao.getAccountById(sid);
        BloggerProfile smProfile = getProfile(sid);
        BloggerDTO smDTO = dataFillingManager.bloggerAccountToDTO(smAccount, smProfile, getAvatar(smProfile.getAvatarId()));
        BlogCommentDTO dto = dataFillingManager.blogCommentToDTO(comment, smDTO);
        result.add(dto);
    }
    return CollectionUtils.isEmpty(result) ? null : new ResultBean<>(result);
}
Also used : BloggerDTO(com.duan.blogos.dto.blogger.BloggerDTO) BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) ArrayList(java.util.ArrayList) BlogComment(com.duan.blogos.entity.blog.BlogComment) BlogCommentDTO(com.duan.blogos.dto.blog.BlogCommentDTO) BloggerProfile(com.duan.blogos.entity.blogger.BloggerProfile)

Example 2 with BlogComment

use of com.duan.blogos.entity.blog.BlogComment in project BlogSystem by DuanJiaNing.

the class BloggerCommentServiceImpl method insertComment.

@Override
public int insertComment(int blogId, int spokesmanId, int listenerId, int state, String content) {
    BlogComment comment = new BlogComment();
    comment.setBlogId(blogId);
    comment.setContent(content);
    comment.setListenerId(listenerId);
    comment.setSpokesmanId(spokesmanId);
    comment.setState(state);
    commentDao.insert(comment);
    // 博文评论次数加一
    statisticsDao.updateCommentCountPlus(blogId);
    Integer id = comment.getId();
    return id == null ? -1 : id;
}
Also used : BlogComment(com.duan.blogos.entity.blog.BlogComment)

Aggregations

BlogComment (com.duan.blogos.entity.blog.BlogComment)2 BlogCommentDTO (com.duan.blogos.dto.blog.BlogCommentDTO)1 BloggerDTO (com.duan.blogos.dto.blogger.BloggerDTO)1 BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)1 BloggerProfile (com.duan.blogos.entity.blogger.BloggerProfile)1 ArrayList (java.util.ArrayList)1