⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumserviceimp.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        sb.append(forum.getBoardID());
        sb.append("'>\n");

        sb.append(detail);
        sb.append(
            "<br><input type=\"submit\" name=\"Submit\" class='BUTTN-FIX1' value=\"Submit\"></form>");
        sb.append("</body></html>");
        FileIO.writeFile(sb.toString(),
                         SysUtil.getForumPath(forum.getBoardID(),
                                              forum.getPostTime()) + filename,
                         Constant.CHARSET);
        forum.setDetail(filename);
        forum.setId2(forum.getId().longValue());
        forum = this.saveForum(forum);
        NewPost.intoNewPost(forum);
        if (forum == null) {
          return new Result(false, "error.posterror", null);
        }
        else {
          return new Result(true, "", forum);
        }
      }
      else {
        return new Result(false, "error.posterror", null);
      }

    }
  }

  public Result changeForum(Forum forum) {
    String detail = forum.getDetail();
    String filename = "post_" + forum.getId().longValue() + "_" +
        forum.getBoardID() +
        "_" + forum.getId().longValue() + "_" + forum.getPostTime() +
        ".html";
    SysUtil.delFile(SysUtil.getForumPath(forum.getBoardID(),
                                         forum.getPostTime()) +
                    filename);
    StringBuffer sb = new StringBuffer();
    sb.append("<html><head><title>");
    sb.append(forum.getTitle());
    sb.append("</title><body>");
    sb.append(detail);
    sb.append("</body></html>");
    FileIO.writeFile(sb.toString(),
                     SysUtil.getForumPath(forum.getBoardID(),
                                          forum.getPostTime()) + filename,
                     Constant.CHARSET);
    forum.setDetail(filename);
    forum = this.saveForum(forum);
    NewPost.delNewPost(forum.getId().longValue());
    if (forum == null) {
      return new Result(false, "error.changepost", null);
    }
    else {
      return new Result(true, "", forum);
    }
  }

  public void delaPost(Forum forum, int de) {
    this.saveForum(forum);
    NewPost.delNewPost(forum.getId().longValue());
    if (forum.getIsNew() != 1) {
      Forum mainForum = this.getForum(forum.getId2(), forum.getBoardID());
      if (mainForum != null) {
        mainForum.setReNum(mainForum.getReNum() - 1);
        this.saveForum(mainForum);
      }
    }
    if (de == 0) {
      CacheManager.getCache(0).remove(String.valueOf(forum.getUserID()));
      UserInfo ui = this.getUserInfoService().findUserInfoById(new Long(forum.
          getUserID()));
      if (ui != null) {
        if (forum.getArtSize() > 30 && ui.getArticleNum() > 1) {
          ui.setArticleNum(ui.getArticleNum() - 1);
          if (forum.getElite() != 0 && ui.getExpression() > 5) {
            ui.setExpression(ui.getExpression() - 5);
          }
          this.getUserInfoService().saveUserInfo(ui);
        }
      }
    }
  }

  public void delPosts(long bid, long[] ids, int de, UserCheck uc) {
    if (ids != null && ids.length > 0) {
      int len = ids.length;
      List values = new ArrayList();
      for (int i = 0; i < len; i++) {
        values.add(new Long(ids[i]));
      }
      List fs = this.findForumInList(bid, values);
      Forum forum;
      len = fs.size();
      for (int i = 0; i < len; i++) {
        forum = (Forum) fs.get(i);
        forum.setDelIP(uc.getRequest().getRemoteAddr());
        forum.setDelSign( (short) 1);
        forum.setDelTime(SysUtil.getLongTime());
        forum.setDelUserID(uc.getId());
        forum.setDelUserName(uc.getUsername());
        if (forum.getAuditing() == 1) {
          forum.setAuditing( (short) 0);
        }
        this.delaPost(forum, de);
      }
    }
  }

  public void auditingPosts(long bid, long[] ids) {
    if (ids != null && ids.length > 0) {
      int len = ids.length;
      List values = new ArrayList();
      for (int i = 0; i < len; i++) {
        values.add(new Long(ids[i]));
      }
      List fs = this.findForumInList(bid, values);
      Forum forum;
      Forum mainForum;
      len = fs.size();
      for (int i = 0; i < len; i++) {
        forum = (Forum) fs.get(i);
        forum.setAuditing( (short) 0);
        if (forum.getIsNew() != 1) {
          mainForum = this.getForum(forum.getId2(), forum.getBoardID());
          if (mainForum != null) {
            mainForum.setLastPostNickName(forum.getNickName());
            mainForum.setLastPostTitle(forum.getTitle());
            mainForum.setLastPostUserName(forum.getUserName());
            mainForum.setLastTime(forum.getPostTime());
            mainForum.setReNum(mainForum.getReNum() + 1);
            this.saveForum(mainForum);
          }
          mainForum = null;
        }
        this.saveForum(forum);
        forum = null;
      }
    }
  }

  public void delAuditingPosts(long bid, long[] ids, UserCheck uc) {
    if (ids != null && ids.length > 0) {
      int len = ids.length;
      List values = new ArrayList();
      for (int i = 0; i < len; i++) {
        values.add(new Long(ids[i]));
      }
      List fs = this.findForumInList(bid, values);
      Forum forum;
      len = fs.size();
      for (int i = 0; i < len; i++) {
        forum = (Forum) fs.get(i);
        forum.setDelIP(uc.getRequest().getRemoteAddr());
        forum.setDelSign( (short) 1);
        forum.setDelTime(SysUtil.getLongTime());
        forum.setDelUserID(uc.getId());
        forum.setDelUserName(uc.getUsername());
        /*
                 if (forum.getAuditing() == 1) {
          forum.setAuditing( (short) 0);
                 }*/
        this.saveForum(forum);
      }
    }
  }

  public void realDelPosts(long bid, long[] ids) {
    if (ids != null && ids.length > 0) {
      int len = ids.length;
      List values = new ArrayList();
      for (int i = 0; i < len; i++) {
        values.add(new Long(ids[i]));
      }
      List fs = this.findForumInList(bid, values);
      Forum forum;
      len = fs.size();
      for (int i = 0; i < len; i++) {
        forum = (Forum) fs.get(i);
        if ( (SysUtil.getLongTime() - forum.getPostTime()) >
            7 * 24 * 3600 * 1000) {
          this.realDelPost(forum);
        }
      }
    }
  }

  public void realDelPost(Forum forum) {
    if (forum.getHavePic() != 0 && forum.getPicName() != null) {
      SysUtil.delFile(SysUtil.getUpFilePath(forum.getBoardID(),
                                            forum.getPostTime()) +
                      forum.getPicName());
    }
    SysUtil.delFile(SysUtil.getForumPath(forum.getBoardID(), forum.getPostTime()) +
                    forum.getDetail());
    this.getForumDAO().removeForum(forum);
  }

  public void delWastePost(long bid) {
    List l = this.getForumDAO().findForumDelAll(bid);
    Forum forum;
    int len = l.size();
    for (int i = 0; i < len; i++) {
      forum = (Forum) l.get(i);
      this.realDelPost(forum);
    }
  }

  public void resumePosts(long bid, long[] ids) {
    if (ids != null && ids.length > 0) {
      int len = ids.length;
      List values = new ArrayList();
      for (int i = 0; i < len; i++) {
        values.add(new Long(ids[i]));
      }
      List fs = this.findForumInList(bid, values);
      Forum forum;
      len = fs.size();
      for (int i = 0; i < len; i++) {
        forum = (Forum) fs.get(i);
        forum.setDelSign( (short) 0);
        this.saveForum(forum);
        if (forum.getId().longValue() != forum.getId2()) {
          forum = this.getForum(forum.getId2(), forum.getBoardID());
          if (forum != null) {
            forum.setReNum(forum.getReNum() + 1);
            this.saveForum(forum);
          }
        }
      }
    }
  }

  public int getForumMainNum(long bid) {
    return this.getForumDAO().getForumMainNum(bid);
  }

  public int getForumAllNum(long bid, short delSign, short auditing) {
    return this.getForumDAO().getForumAllNum(bid, delSign, auditing);
  }

  public List findForumElite(long bid, long elite, long eliteId) {
    return this.getForumDAO().findForumElite(bid, elite, eliteId);
  }

  public int getSearchNum(long bid, String con, String text) {
    return this.getForumDAO().getSearchNum(bid, con, text);
  }

  public PageList getSearchList(long bid, String con, String text, Pages pages) {
    //return this.getForumDAO().getSearchList(bid, con, text, pages);
    PageList pl = new PageList();

    if (pages.getTotals() == -1) {
      pages.setTotals(this.getSearchNum(bid, con, text));
    }
    pages.doPageBreak();

    List l = this.getForumDAO().getSearchList(bid, con, text, pages.getSpage(),
                                              pages.getPerPageNum());
    pl.setObjectList(l);
    pl.setPageShowString(pages.getListPageBreak());
    pl.setPages(pages);
    return pl;
  }

  public List getForumDelTopicList(long bid, long ID2) {
    return this.getForumDAO().getForumDelTopicList(bid, ID2);
  }

  public PageList findForumDelAllList(long bid, Pages pages) {
    //return this.getForumDAO().findForumDelAllList(bid, pages);
    PageList pl = new PageList();

    if (pages.getTotals() == -1) {
      pages.setTotals(this.getForumDAO().getForumDelAllNum(bid));
    }
    pages.doPageBreak();

    List l = this.getForumDAO().findForumDelAllList(bid, pages.getSpage(),
        pages.getPerPageNum());

    pl.setObjectList(l);
    pl.setPageShowString(pages.getListPageBreak());
    pl.setPages(pages);
    return pl;

  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -