📄 boards.java
字号:
package com.laoer.bbscs.board;import java.sql.*;import java.io.*;import java.util.*;import com.laoer.bbscs.db.*;import com.laoer.bbscs.txthtml.*;import com.laoer.bbscs.user.User;/** * <p>Title: BBS-CS</p> * <p>Description: BBS-CS(BBS式虚拟社区系统)</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: loveroom.com.cn</p> * @author 龚天乙(laoer) * @version 3.0 */public class Boards { String SQL = ""; DbTrans DBSQL; ResultSet rs = null; DoText myDoText; private String strBoardID = ""; private String strBoardsName = ""; private String strEBoardsName = ""; private String strBsMaster = ""; private String strBsMaster1 = ""; private String strBsMaster2 = ""; private String strBoardgg = ""; private int numAttrib = 1; private int numUseState = 1; private int numXu = 1; private int numArtCount = 0; public Boards() { this.DBSQL = new DbTrans(); this.myDoText = new DoText(); } public Boards(String bsid) { this.DBSQL = new DbTrans(); this.myDoText = new DoText(); getBoards(bsid); } /** * 取得版面各项属性 * @param bsid 一级版区ID */ public void getBoards(String bsid) { SQL = "select * from boards where ID = "+bsid; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { this.strBoardID = rs.getString("boardID"); this.strBoardsName = rs.getString("boardsname"); this.strEBoardsName = rs.getString("eboardsname"); this.strBsMaster = rs.getString("bsmaster"); this.strBsMaster1 = rs.getString("bsmaster1"); this.strBsMaster2 = rs.getString("bsmaster2"); this.strBoardgg = rs.getString("boardgg"); this.numAttrib = rs.getInt("attrib"); this.numUseState = rs.getInt("usestate"); this.numXu = rs.getInt("xu"); this.numArtCount = rs.getInt("artcount"); } rs.close(); } catch (SQLException e){ } } public String getBoardID() { return this.strBoardID; } public String getBoardsName() { return this.strBoardsName; } public String getEBoardName() { return this.strEBoardsName; } public String getBsMaster() { return this.strBsMaster; } public String getBsMaster1() { return this.strBsMaster1; } public String getBsMaster2() { return this.strBsMaster2; } public String getBoardgg() { return this.strBoardgg; } public int getAttrib() { return this.numAttrib; } public int getUseState() { return this.numUseState; } public int getBoardsXu() { return this.numXu; } public int getArtCount() { return this.numArtCount; } /** * 取得版面自动序号 * @param bid 一级版区ID * @return int型版面自动序号 */ public int getAutoBoardsXu(String bid) { int numAutoBoardsXu = 1; SQL = "select max(xu)+5 as numAutoBoardsXu from boards where boardID = "+bid; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numAutoBoardsXu = rs.getInt("numAutoBoardsXu"); } rs.close(); if (numAutoBoardsXu == 0) { numAutoBoardsXu = 5; } } catch (SQLException e){ } return numAutoBoardsXu; } /** * 验证版副 * @param BsMaster1 版副字串 * @return 布尔逻辑值 如果都是注册用户返回真,否则返回假 */ public boolean checkBsMaster1(String BsMaster1) { StringTokenizer masterok = new StringTokenizer(BsMaster1,","); User myUser = new User(); while(masterok.hasMoreTokens()) { if (!myUser.isUser(masterok.nextToken())) { return false; } } return true; } /** * 判断版面名是否重复 * @param strBoardsName 中文版面名 * @param strEBoardsName 英文版面名 * @return 布尔逻辑值 已存在返回真,否则返回假 */ public boolean isHaveBoards(String strBoardsName, String strEBoardsName) { boolean isHaveBoards = false; int numIsHaveBoards = 0; SQL = "select count(*) as numIsHaveBoards from boards where boardsname='"+ strBoardsName +"' or eboardsname='" + strEBoardsName +"'"; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numIsHaveBoards = rs.getInt("numIsHaveBoards"); } rs.close(); } catch (SQLException e){ } if (numIsHaveBoards != 0) { isHaveBoards = true; } else { isHaveBoards = false; } return isHaveBoards; } public boolean isBoards(String bsid) { int numIsBoards = 0; SQL = "select count(*) as numIsBoards from boards where ID = "+bsid; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numIsBoards = rs.getInt("numIsBoards"); } rs.close(); } catch (SQLException e){ } if (numIsBoards == 1) { return true; } else { return false; } } public boolean isHaveBoards(String strBoardsName, String strEBoardsName,String bsid) { boolean isHaveBoards = false; int numIsHaveBoards = 0; SQL = "select count(*) as numIsHaveBoards from boards where (boardsname='"+ strBoardsName +"' or eboardsname='" + strEBoardsName +"') and ID <>"+bsid; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numIsHaveBoards = rs.getInt("numIsHaveBoards"); } rs.close(); } catch (SQLException e){ } if (numIsHaveBoards != 0) { isHaveBoards = true; } else { isHaveBoards = false; } return isHaveBoards; } /** * 增加版面 * @param bid 一级版区ID * @param strBoardsName 中文版面名 * @param strEBoardsName 英文版面名 * @param strBsMaster 斑竹 * @param strBsMaster1 版副 * @param strBsMaster2 隐身版竹 * @param strBoardsgg 版面公告 * @param strAttrib 版区属性 * @param strUseState 版面状态 * @param strXu 序 * @return 布尔逻辑值 添加成功返回真,否则返回假 */ public boolean addBoards(String bid, String strBoardsName, String strEBoardsName, String strBsMaster, String strBsMaster1, String strBsMaster2, String strBoardsgg, String strAttrib, String strUseState, String strXu) { boolean isCanAdd = false; SQL = "insert into boards (boardID,boardsname,eboardsname,bsmaster,bsmaster1,bsmaster2,boardgg,attrib,usestate,xu) values ('"+ bid +"','"+ strBoardsName +"','"+ strEBoardsName +"','"+ strBsMaster +"','"+ strBsMaster1 +"','"+ strBsMaster2 +"','"+ strBoardsgg +"','"+ strAttrib +"','"+ strUseState +"','"+ strXu +"')"; try { DBSQL.executeQuery(SQL); isCanAdd = true; } catch (SQLException e){ isCanAdd = false; } return isCanAdd; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -