/**
   * 显示详细内容
   *
   * @param session
   * @param model
   * @param docid
   * @return
   */
  @RequestMapping(params = "method=show", method = RequestMethod.GET)
  public String show(HttpSession session, Model model, int docid, Pager<Comment> paraPage) {
    User user = (User) session.getAttribute("user");
    if (user != null) {
      Document document = documentService.getById(docid);
      if (document != null) {
        if (paraPage == null) paraPage = new Pager<Comment>();
        int totleCount = commentService.getAllCount(docid);

        Pager<Comment> page =
            new Pager<Comment>(totleCount, paraPage.getCurPage(), paraPage.getCountPerPage());
        List<Comment> commentList =
            commentService.getByPage(page.getStartCount(), page.getCountPerPage(), docid);
        if (commentList.isEmpty()) model.addAttribute("msg", "当前还没人翻译,译一下");
        else {
          // 为comment设置User字段
          for (Comment comment : commentList) {
            comment.setUser(userService.getByKey(comment.getUserid()));
            comment.setLikeTime(loveService.CountByComment(comment.getComid()));
            // 如果当前session与该评论的user相同,则可以删除
            if (comment.getUserid().equals(user.getUserid())) comment.setCanDel("1");
          }

          Comment comment = commentService.getByDocAndAc(document.getDocid());
          // 还没接受则可以接受
          if (comment == null) {
            // 如果当前session与此篇文档的用户相同,则可以进行接受操作
            if (document.getUserid().equals(user.getUserid())) model.addAttribute("canAcc", "1");
          } else {
            comment.setUser(userService.getByKey(comment.getUserid()));
            comment.setLikeTime(loveService.CountByComment(comment.getComid()));
            if (comment.getUserid().equals(user.getUserid())) comment.setCanDel("1");
            model.addAttribute("accComment", comment);
          }

          page.settList(commentList);
          model.addAttribute("msg", "已有翻译");
        }
        model.addAttribute("page", page);
        User author = userService.getByKey(document.getUserid());
        model.addAttribute("user", user);
        model.addAttribute("document", document);
        model.addAttribute("author", author);
        model.addAttribute("wantCount", wantService.countByDoc(docid));
        return "document/show";
      }
    }
    return "error";
  }
 /**
  * 修改主流程
  *
  * @param session
  * @param model
  * @param document
  * @return
  */
 @RequestMapping(params = "method=modify", method = RequestMethod.POST)
 public String modify(HttpSession session, Model model, Document document) {
   User user = (User) session.getAttribute("user");
   if (user != null) {
     document.setUserid(user.getUserid());
     documentService.update(document);
     model.addAttribute("user", user);
     model.addAttribute("msg", "更新成功!");
     return "redirect:document?method=list";
   } else return "error";
 }
  /**
   * 添加业务
   *
   * @param session
   * @param model
   * @param document
   * @return
   */
  @RequestMapping(params = "method=add", method = RequestMethod.POST)
  public String add(HttpSession session, Model model, Document document, String guestIdStr) {
    try {
      User user = (User) session.getAttribute("user");
      document.setUserid(user.getUserid());

      Integer docid = documentService.addRet(document);

      // 为文档分配积分
      distribPoint(user, document);

      // 添加邀请信息
      if (guestIdStr != "") invite(guestIdStr, docid);

      return "redirect:/document?method=list";
    } catch (Exception e) {
      System.out.println(e);
      return "error";
    }
  }
 /**
  * 回滚积分
  *
  * @param user
  * @param document
  */
 private void retPoint(User user, Document document) {
   user.setPoint(user.getPoint() + document.getPoint());
   userService.update(user);
 }