Search in sources :

Example 1 with Comment

use of com.zyd.blog.business.entity.Comment in project OneBlog by zhangyd-c.

the class BizCommentServiceImpl method findPageBreakByCondition.

/**
 * 分页查询
 *
 * @param vo
 * @return
 */
@Override
public PageInfo<Comment> findPageBreakByCondition(CommentConditionVO vo) {
    PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
    List<BizComment> list = bizCommentMapper.findPageBreakByCondition(vo);
    List<Comment> boList = this.getComments(list);
    if (boList == null) {
        return null;
    }
    PageInfo bean = new PageInfo<BizComment>(list);
    bean.setList(boList);
    return bean;
}
Also used : Comment(com.zyd.blog.business.entity.Comment) BizComment(com.zyd.blog.persistence.beans.BizComment) BizComment(com.zyd.blog.persistence.beans.BizComment) PageInfo(com.github.pagehelper.PageInfo)

Example 2 with Comment

use of com.zyd.blog.business.entity.Comment in project OneBlog by zhangyd-c.

the class BizCommentServiceImpl method sendEmail.

private void sendEmail(Comment comment) {
    // 可以进行日志记录等操作
    try {
        if (null != comment.getPid() && 0 != comment.getPid()) {
            // 给被评论的用户发送通知
            Comment commentDB = this.getByPrimaryKey(comment.getPid());
            mailService.send(commentDB, TemplateKeyEnum.TM_COMMENT_REPLY, false);
        } else {
            mailService.sendToAdmin(comment);
        }
    } catch (Exception e) {
        log.error("发送评论通知邮件时发生异常", e);
    }
}
Also used : Comment(com.zyd.blog.business.entity.Comment) BizComment(com.zyd.blog.persistence.beans.BizComment) ZhydCommentException(com.zyd.blog.framework.exception.ZhydCommentException)

Example 3 with Comment

use of com.zyd.blog.business.entity.Comment in project OneBlog by zhangyd-c.

the class BizCommentServiceImplTest method comment.

@Test
public void comment() throws InterruptedException {
    Comment comment = new Comment();
    comment.setPid(1L);
    comment.setNickname("测试");
    comment.setEmail("843977358@qq.com");
    comment.setQq("843977358");
    commentService.comment(comment);
    TimeUnit.SECONDS.sleep(60);
}
Also used : Comment(com.zyd.blog.business.entity.Comment) BaseJunitTest(com.zyd.blog.BaseJunitTest) Test(org.junit.Test)

Example 4 with Comment

use of com.zyd.blog.business.entity.Comment in project OneBlog by zhangyd-c.

the class BizCommentServiceImpl method convert2DTO.

private List<BizCommentDTO> convert2DTO(List<Comment> list) {
    if (CollectionUtils.isEmpty(list)) {
        return null;
    }
    List<BizCommentDTO> dtoList = new LinkedList<>();
    for (Comment comment : list) {
        BizCommentDTO dto = BeanConvertUtil.doConvert(comment, BizCommentDTO.class);
        dto.setParentDTO(BeanConvertUtil.doConvert(comment.getParent(), BizCommentDTO.class));
        if (null != comment.getUser()) {
            dto.setUserType(comment.getUser().getUserTypeEnum());
        }
        dtoList.add(dto);
    }
    return dtoList;
}
Also used : Comment(com.zyd.blog.business.entity.Comment) BizComment(com.zyd.blog.persistence.beans.BizComment) BizCommentDTO(com.zyd.blog.business.dto.BizCommentDTO)

Example 5 with Comment

use of com.zyd.blog.business.entity.Comment in project OneBlog by zhangyd-c.

the class BizCommentServiceImpl method getByPrimaryKey.

@Override
public Comment getByPrimaryKey(Long primaryKey) {
    Assert.notNull(primaryKey, "PrimaryKey不可为空!");
    BizComment entity = bizCommentMapper.getById(primaryKey);
    return null == entity ? null : new Comment(entity);
}
Also used : Comment(com.zyd.blog.business.entity.Comment) BizComment(com.zyd.blog.persistence.beans.BizComment) BizComment(com.zyd.blog.persistence.beans.BizComment)

Aggregations

Comment (com.zyd.blog.business.entity.Comment)6 BizComment (com.zyd.blog.persistence.beans.BizComment)4 ZhydCommentException (com.zyd.blog.framework.exception.ZhydCommentException)2 PageInfo (com.github.pagehelper.PageInfo)1 BaseJunitTest (com.zyd.blog.BaseJunitTest)1 BussinessLog (com.zyd.blog.business.annotation.BussinessLog)1 BizCommentDTO (com.zyd.blog.business.dto.BizCommentDTO)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 Test (org.junit.Test)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1