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

📄 dbforum.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            }
          }
        }
        ui = null;
        au = null;
      }
      if (de == 1) {
        Boards aBoards = BoardsFactory.getInstance();
        aBoards.setBoardsInfo(this.myUserSessionCheck.getTheBoards());
        if (this.myForumInfo.getID() != this.myForumInfo.getID2()) {
          System.out.println(this.myForumInfo.getID());
          System.out.println(this.myForumInfo.getID2());
          ForumInfo afi = new ForumInfo();
          afi.setBoardID(this.myForumInfo.getBoardID());
          afi.setID(this.myForumInfo.getID2());
          Forum af = ForumFactory.getInstance();
          af.setForumInfo(afi);
          af.updatePost(myDBTrans, "decReNum");
          aBoards.updateBoards(myDBTrans, "DecPostNums");
          afi = null;
          af = null;
        }
        else {
          aBoards.updateBoards(myDBTrans, "DecPostMainNum");
        }
        aBoards = null;
      }
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public int delPosts(TranContext aTranContext, String[] parm2, String parm3) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    int len = 0;
    String sPostIDs = "";
    StringBuffer sb = new StringBuffer();
    len = parm2.length;
    for (int i = 0; i < len; i++) {
      sb.append(parm2[i] + ",");
    }
    sPostIDs = sb.toString();
    if (sPostIDs.endsWith(",")) {
      sPostIDs = sPostIDs.substring(0, sPostIDs.length() - 1);
      this.sDelPostIDs = sPostIDs;
    }
    List myList = null;
    try {
      myList = loadDBs(myDBTrans, "delPosts");
      int flen = myList.size();
      ForumInfo afi = null;
      Forum af = ForumFactory.getInstance();
      for (int i = 0; i < flen; i++) {
        afi = (ForumInfo) myList.get(i);
        afi.setDelUserID(this.myForumInfo.getDelUserID());
        afi.setDelUserName(this.myForumInfo.getDelUserName());
        afi.setDelTime(this.myForumInfo.getDelTime());
        afi.setDelIP(this.myForumInfo.getDelIP());
        af.setUserSessionCheck(this.myUserSessionCheck);
        af.setForumInfo(afi);
        if (parm3.equals("del")) {
          af.delaPost(myDBTrans, "delaPost", 0);
        }
        else {
          af.delaPost(myDBTrans, "delaPost", 1);
        }
      }
      int postMainNum = this.getPostNum(myDBTrans, "PostMainList");
      int postNum = this.getPostNum(myDBTrans, "PostManagerList");
      Boards aBoards = BoardsFactory.getInstance();
      BoardsInfo abs = this.myUserSessionCheck.getTheBoards();
      abs.setMainPostNum(postMainNum);
      abs.setPostNum(postNum);
      aBoards.setBoardsInfo(abs);
      aBoards.updateBoards(myDBTrans, "PostNumAll");
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public int updatePost(TranContext aTranContext, String[] postIDs,
                        String key) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    int len = 0;
    String sPostIDs = "";
    StringBuffer sb = new StringBuffer();
    len = postIDs.length;
    for (int i = 0; i < len; i++) {
      sb.append(postIDs[i] + ",");
    }
    sPostIDs = sb.toString();
    if (sPostIDs.endsWith(",")) {
      sPostIDs = sPostIDs.substring(0, sPostIDs.length() - 1);
      this.sDelPostIDs = sPostIDs;
    }
    try {
      this.updateDB(myDBTrans, key);
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public void loadDB(TranContext myDB, String key, boolean isLoad) throws
      ObjectException, ObjectNoExistException {
    try {
      if (key.equals("ID")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("haveElite")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where EliteID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getEliteID());
      }
      rs = myDB.executeQuery();
      if (rs.next()) {
        if (isLoad) {
          myForumInfo.setID(rs.getLong("ID"));
          myForumInfo.setID1(rs.getLong("ID1"));
          myForumInfo.setID2(rs.getLong("ID2"));
          myForumInfo.setBoardID(rs.getLong("BoardID"));
          myForumInfo.setBoardName(rs.getString("BoardName"));
          myForumInfo.setReNum(rs.getInt("ReNum"));
          myForumInfo.setFace(rs.getInt("Face"));
          myForumInfo.setUserID(rs.getLong("UserID"));
          myForumInfo.setUserName(rs.getString("UserName"));
          myForumInfo.setTitle(rs.getString("Title"));
          myForumInfo.setDetail(rs.getString("Detail"));
          myForumInfo.setSign(rs.getString("Sign"));
          myForumInfo.setArtSize(rs.getInt("ArtSize"));
          myForumInfo.setEmail_Inform(rs.getInt("Email_Inform"));
          myForumInfo.setMsg_Inform(rs.getInt("Msg_Inform"));
          myForumInfo.setClick(rs.getInt("Click"));
          myForumInfo.setPostTime(rs.getLong("PostTime"));
          myForumInfo.setLastTime(rs.getLong("LastTime"));
          myForumInfo.setIPAddress(rs.getString("IPAddress"));
          myForumInfo.setVtime(rs.getString("vtime"));
          myForumInfo.setIsNew(rs.getInt("IsNew"));
          myForumInfo.setNickName(rs.getString("NickName"));
          myForumInfo.setElite(rs.getLong("Elite"));
          myForumInfo.setEliteID(rs.getLong("EliteID"));
          myForumInfo.setAgree(rs.getInt("Agree"));
          myForumInfo.setBeAgainst(rs.getInt("BeAgainst"));
          myForumInfo.setCanNotDel(rs.getInt("CanNotDel"));
          myForumInfo.setDelSign(rs.getInt("DelSign"));
          myForumInfo.setDelUserID(rs.getLong("DelUserID"));
          myForumInfo.setDelUserName(rs.getString("DelUserName"));
          myForumInfo.setDelTime(rs.getLong("DelTime"));
          myForumInfo.setDelIP(rs.getString("DelIP"));
          myForumInfo.setCanNotRe(rs.getInt("CanNotRe"));
          myForumInfo.setAmend(rs.getString("Amend"));
          myForumInfo.setDoEliteName(rs.getString("DoEliteName"));
          myForumInfo.setDoEliteTime(rs.getLong("DoEliteTime"));
          myForumInfo.setHavePic(rs.getInt("HavePic"));
          myForumInfo.setPicName(rs.getString("PicName"));
          myForumInfo.setLastPostUserName(rs.getString("LastPostUserName"));
          myForumInfo.setLastPostTitle(rs.getString("LastPostTitle"));
          myForumInfo.setIsTop(rs.getInt("IsTop"));
          myForumInfo.setIsB(rs.getInt("IsB"));
          FileLoadCache flc = new FileLoadCache(String.valueOf(myForumInfo.
              getID()), myForumInfo);
          FileLoad fl = flc.get();
          myForumInfo.setDetailText(fl.getContent());
        }
      }
      else {
        throw new ObjectNoExistException();
      }

    }
    catch (SQLException e) {
      throw new ObjectException(e.toString());
    }
    finally {
      try {
        if (rs != null) {
          rs.close();
          rs = null;
        }
      }
      catch (SQLException e) {
      }
      try {
        if (myDB != null) {
          myDB.close();
        }
      }
      catch (SQLException e) {
      }
    }
  }

  public List loadDBs(TranContext myDB, String key) throws ObjectException {
    List alist = ListFactory.getInstance(2);
    ForumInfo aForumInfo = null;
    boolean load = false;
    try {
      if (key.equals("PostMainList")) {
        String strSQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + this.myForumInfo.getBoardID() +
            " and IsNew = 1 and DelSign = 0 order by IsTop desc,LastTime desc";
        this.pages.setTotals(this.getPostNum(myDB, key));
        this.pages.doPageBreak();
        this.sListPageBreak = this.pages.getListPageBreak();
        this.pages.setSQL(strSQL);
        myDB.prepareStatement(this.pages.getSQLString("ID"));
        rs = myDB.executeQuery();
        //rs = this.pages.getRs(myDB, "ID");
      }
      if (key.equals("PostTopicList")) {
        load = true;
        String strSQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + this.myForumInfo.getBoardID() +
            " and  ID2 = " + this.myForumInfo.getID2() +
            " and DelSign = 0 order by ID";
        this.pages.setTotals(this.getPostNum(myDB, key));
        this.pages.doPageBreak();
        this.sListPageBreak = this.pages.getListPageBreak();
        this.pages.setSQL(strSQL);
        myDB.prepareStatement(this.pages.getSQLString("ID"));
        rs = myDB.executeQuery();
      }
      if (key.equals("PostManagerList")) {
        String strSQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + myForumInfo.getBoardID() +
            " and DelSign = 0 order by LastTime desc";
        this.pages.setTotals(this.getPostNum(myDB, key));
        this.pages.doPageBreak();
        this.sListPageBreak = this.pages.getListPageBreak();
        this.pages.setSQL(strSQL);
        myDB.prepareStatement(this.pages.getSQLString("ID"));
        rs = myDB.executeQuery();
      }
      if (key.equals("delPosts")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + myForumInfo.getBoardID() + " and ID in (" +
            this.sDelPostIDs + ")";
        myDB.prepareStatement(SQL);
        rs = myDB.executeQuery();
      }
      if (key.equals("wastebox")) {
        String strSQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + myForumInfo.getBoardID() +
            " and DelSign = 1 order by LastTime desc";
        this.pages.setTotals(this.getPostNum(myDB, key));
        this.pages.doPageBreak();
        this.sListPageBreak = this.pages.getListPageBreak();
        this.pages.setSQL(strSQL);
        myDB.prepareStatement(this.pages.getSQLString("ID"));
        rs = myDB.executeQuery();
      }
      if (key.equals("readwaste")) {
        load = true;
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + myForumInfo.getBoardID() + " and  ID2 = " +
            myForumInfo.getID2() + " and DelSign = 1 order by ID";
        myDB.prepareStatement(SQL);
        rs = myDB.executeQuery();
      }
      if (key.equals("delwaste")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + myForumInfo.getBoardID() +
            " and ID in (" + this.sDelPostIDs +
            ") and PostTime < ? and DelSign = 1";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, (Util.getaLongTime() - 604800000));
        rs = myDB.executeQuery();
      }
      if (key.equals("delall")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = ? and PostTime < ? and DelSign = 1";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getBoardID());
        myDB.setLong(2, (Util.getaLongTime() - 604800000));
        rs = myDB.executeQuery();
      }
      if (key.equals("search")) {
        String strSQL = "select * from " + this.myForumInfo.getTablename() +
            " where BoardID = " + this.myForumInfo.getBoardID() +

⌨️ 快捷键说明

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