Example #1
0
  /**
   * * 查询所有与当前用户发表的说说相关的动态列表
   *
   * @param userid
   */
  public List getUserSayList(String userid, Integer pageNo, Integer pageSize) {
    List<Map> rtnList = new ArrayList<Map>();
    if (pageNo == null) pageNo = 1;
    if (pageSize == null) pageSize = 10;
    List<Map<String, Object>> saylist = new ArrayList<Map<String, Object>>();
    Map sqlmap = new HashMap<String, Object>();
    sqlmap.put("userid", userid);
    sqlmap.put("pageNo", (pageNo - 1) * pageSize);
    sqlmap.put("pageSize", pageSize);
    saylist = sayMapper.queryUserSayList(sqlmap);
    for (int s = 0; s < saylist.size(); s++) {
      Map say = saylist.get(s);
      say.put(
          "sayuserimg",
          ContentUtil.IMAGE_ROOT + ContentUtil.IMAGEPATHS.get("user") + say.get("sayuserimg"));
      Long sayid = (Long) say.get("sayid");

      pageSize = 5;
      Long commentid = (Long) say.get("commentid");
      int replySize = commReplyService.queryReplyCount(commentid);
      if (replySize > pageSize) {
        pageNo = replySize - pageSize;
      } else {
        pageNo = 0;
      }
      Map map = new HashMap<String, Object>();
      Map sqlmap1 = new HashMap<String, Object>();
      sqlmap1.put("actiontype", 1);
      sqlmap1.put("actionid", sayid);
      List<String> sayimages = sayImageMapper.queryActionfileUrlList(sqlmap1);
      List<String> newsayimages = new ArrayList<String>();
      for (String simg : sayimages) {
        newsayimages.add(ContentUtil.IMAGE_ROOT + ContentUtil.IMAGEPATHS.get("say") + simg);
      }
      say.put("images", newsayimages);
      IpavcommentEntity comment =
          commReplyService.queryCommentByCommentid(commentid, pageNo, pageSize);
      List<IpavcommentEntity> comments = new ArrayList<IpavcommentEntity>();
      comments.add(comment);
      say.put("comments", comments);
      if (comment.getReplys() != null && comment.getReplys().size() > 0) {
        IpavcommentEntity comment1 =
            commReplyService.queryCommentByCommentid(commentid, null, null);
        // String date=comment1.getReplys().get(comment1.getReplys().size()-1).getReplydate();
        // say.put("saydate",(IpavcommReplyService.DateToString(date)));
        for (int i = comment1.getReplys().size() - 1; i >= 0; i--) {
          if (comment1.getReplys().get(i).getBereplyid().equals(userid)
              && !comment1.getReplys().get(i).getReplyuserid().equals(userid)) {
            map.put("uname", comment1.getReplys().get(i).getReplyusername());
            map.put("img", comment1.getReplys().get(i).getReplyuserimg());
            map.put("uid", comment1.getReplys().get(i).getReplyuserid());
            break;
          }
        }
        map.put("type", "回复了");

      } else if (comment.getCommtype() == 0) {
        // map.put("uname",comment.getCommusername());
        map.put("type", "赞了");
      } else {
        // map.put("uname",comment.getCommusername());
        map.put("type", "评论了");
      }

      if (!map.containsKey("img") || comment.getCommtype() == 0) {
        map.put("uname", comment.getCommusername());
        map.put("img", comment.getCommuserimg());
        map.put("uid", comment.getCommuserid());
      }
      say.put("saydate", (IpavcommReplyService.DateToString((String) say.get("saydate"))));
      if (say.get("sayuserid").equals(userid)) {
        map.put("isMyTopic", "Y");
      } else {
        map.put("isMyTopic", "N");
      }
      Map filemap = new HashMap<String, Object>();
      filemap.put("actionid", say.get("sayid"));
      filemap.put("actiontype", 5);
      IpavActionFileEntity file = sayImageMapper.queryActionfileByAction(filemap);
      if (file != null) {
        Map fmap = new HashMap<String, Object>();
        fmap.put("name", file.getFilename());
        fmap.put("path", file.getFilepath());
        map.put("fmap", fmap);
      }
      map.put("say", say);
      map.put("praisSize", commReplyService.queryPraiseOrCommentCount(1, sayid, 0));
      map.put("isPrais", commReplyService.queryIsPraiseOrComment(1, sayid, 0, userid, 0));
      map.put("CommentSize", commReplyService.queryPraiseOrCommentCount(1, sayid, 1));
      Integer surplusSize = null;
      if ((pageNo == null || pageNo != 0) && comment.getReplys() != null) {
        surplusSize = replySize - comment.getReplys().size();
      }
      map.put("surplusSize", surplusSize);
      List<Map> userPraises = searchPraiseUser(sayid, 1, null, null, 1);
      map.put("userPraises", userPraises);
      rtnList.add(map);
    }
    return rtnList;
  }