Beispiel #1
0
  @SuppressWarnings("unchecked")
  public String show() {
    // test user
    User user = getCurrentUser();
    ActionContext.getContext().put("luser", user);
    // 该问题
    Userpost userpost = userPostService.findById(questionId);
    Integer cnum = userpost.getClickNumber();
    if (cnum == null) cnum = 0;
    userpost.setClickNumber(cnum + 1);
    userPostService.update(userpost);
    ActionContext.getContext().getValueStack().push(userpost);

    // 标签云
    List<Postlabel> postlabels = labelService.findAll();
    ActionContext.getContext().put("postlabels", postlabels);
    // 相关问题
    List<Userpost> userposts = userPostService.findByType(userpost.getPostlabel(), 5);
    userposts.remove(userpost);
    ActionContext.getContext().put("userposts", userposts);
    // 雷锋榜
    List<User> users = (List<User>) userService.topByReplys(1, 6).getRecordList();
    ActionContext.getContext().put("users", users);
    // 等级称号
    List<Title> titles = titleService.findAll();
    ActionContext.getContext().put("titles", titles);

    // 采纳
    Reply adoptReply = null;
    Set<Reply> replies = (Set<Reply>) userpost.getReplies();
    for (Reply r : replies) {
      if (r.getStatus() == 2) {
        adoptReply = r;
        continue;
      }
      if (r.getStatus() == 0) {
        r.setStatus(1);
        replyService.update(r);
      }
    }
    // 新提问
    int questionNum = userPostService.getQuestionNum(user.getUserId());
    ActionContext.getContext().put("questionNum", questionNum);
    // 新回复
    int replyNum = userPostService.getReplyNum(user.getUserId());
    ActionContext.getContext().put("replyNum", replyNum);

    ActionContext.getContext().put("adoptReply", adoptReply);
    return "show";
  }