Exemple #1
0
  /**
   * @Title: selectOrderCommentByGoodsId @Description: TODO(根据商品id查询评论列表)
   *
   * @author <a href="*****@*****.**">赖彩妙</a>
   * @date 2015-5-13 下午2:19:50
   * @version 1.0.0
   * @param @param data
   * @param @return
   * @return Object 返回类型
   * @throws
   */
  public Object selectOrderCommentByGoodsId(Object data) {
    log.info("start[OrderCommentService.selectOrderCommentByGoodsId]");
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(data);
    Integer pageIndex = jsonObject.getInt("pageIndex");
    Integer pageSize = jsonObject.getInt("pageSize");
    Integer goodsId = jsonObject.getInt("goodsId");
    PageHelper.startPage(pageIndex, pageSize);
    ResultPage<OrderCommentDetailDTO> commentPage =
        new ResultPage(orderCommentMapper.selectOrderCommentByGoodsId(goodsId));
    if (commentPage.getRows() != null && commentPage.getRows().size() >= 1) {
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      CommentPraiseExample example = null;
      for (int i = 0; i < commentPage.getRows().size(); i++) {
        if (commentPage.getRows().get(i).getOrderCreateTime() != null) {
          commentPage
              .getRows()
              .get(i)
              .setOrderCreateDate(format.format(commentPage.getRows().get(i).getOrderCreateTime()));
        }
        // 查询点赞数量
        //					example = new CommentPraiseExample();
        //
        //	example.createCriteria().andCommentIdEqualTo(commentPage.getRows().get(i).getCommentId().intValue());
        //					commentPage.getRows().get(i).setPraise(commentPraiseMapper.countByExample(example));
        commentPage
            .getRows()
            .get(i)
            .setPraise(
                commentPraiseMapper.selectCountByCommentId(
                    commentPage.getRows().get(i).getCommentId().intValue()));

        // 查询回复数量
        commentPage
            .getRows()
            .get(i)
            .setReplyCount(
                orderCommentMapper.selectReplyCountByCommentId(
                    commentPage.getRows().get(i).getCommentId().intValue()));
      }
    }
    return new ResultObject(
        new HeadObject(ErrorCode.SUCCESS), com.alibaba.fastjson.JSONObject.toJSON(commentPage));
  }
Exemple #2
0
  /**
   * @Title: selectCommentById @Description: TODO(根据主键查询评论对象)
   *
   * @author <a href="*****@*****.**">赖彩妙</a>
   * @date 2015-5-18 下午7:24:23
   * @version 1.0.0
   * @param @param data
   * @param @return
   * @return Object 返回类型
   * @throws
   */
  public Object selectCommentById(Object data) {
    log.info("start[MemberCommentService.selectCommentById]");
    OrderCommentDetailDTO comment = orderCommentMapper.selectCommentById((Integer) data);
    if (comment != null) {
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      if (comment.getOrderCreateTime() != null) {
        comment.setOrderCreateDate(format.format(comment.getOrderCreateTime()));
      }
      if (comment.getCreateTime() != null) {
        comment.setCommentDate(format.format(comment.getCreateTime()));
      }
      // 查询点赞数量
      comment.setPraise(
          commentPraiseMapper.selectCountByCommentId(comment.getCommentId().intValue()));

      // 查询回复数量
      comment.setReplyCount(
          orderCommentMapper.selectReplyCountByCommentId(comment.getCommentId().intValue()));
    }
    log.info("end[MemberCommentService.selectCommentById]");
    return new ResultObject(new HeadObject(ErrorCode.SUCCESS), comment);
  }