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

📄 bbsarticlemanager.java

📁 一个目前正在上线运行的JSP企业网站系统
💻 JAVA
字号:
package com.gforce.gfoa;

/**
 * <p>Title: 西部信托网站项目</p>
 * <p>Description: 西部信托网站项目</p>
 * <p>Copyright: 版权所有 2004 (c) 西安吉力科技发展有限公司  Copyright (c) 2004 GForce Sceince & Technology</p>
 * <p>Company: 西安吉力科技发展有限公司 (GForce Sceince & Technology)</p>
 * @author 马登军
 * @version 1.0
 */
import com.gforce.currency.*;
import com.gforce.currency.database.*;
import java.sql.*;
import java.util.*;

public class BBSArticleManager
    extends RecordManager {
    public BBSArticleManager() {
    }

    protected final static String TableName = "BBSArticle"; //定义声明本类操作表名称为“UserInfo”
    protected final static String IDFieldName = "ID"; //定义声明主键或者可以确定唯一记录的字段名称为“ID”,必须为自增整型
    protected final static String[] NumericFieldsName = {"FartherID","IsReqRe","ViewTimes","IsTop","BoardID","PublishUserID","IsLock"}; //声明数值型字段名称
    protected final static String[] StringFieldsName = {
        "Title", "Expression"}; //声明字符型字段名称
    protected final static String[] DatetimeFieldsName = {"PublishTime"}; //声明日期时间型字段名称
    protected final static String[] TextFieldsName = {"Content"}; //声明大字符串型字段名称

    /**
     * 根据字段名称获取插入数据时表单元素名称
     * @param strFieldName  字段名称
     * @return  表单素名称
     */
    protected String InsertParament(String strFieldName) {
        return "" + strFieldName + ""; //可以根据需要加前缀、后缀
    }

    /**
     * 根据字段名称获取修改数据时表单元素名称
     * @param strFieldName  字段名称
     * @return  表单素名称
     */
    protected String UpdateParament(String strFieldName) {
        return "" + strFieldName + ""; //可以根据需要加前缀、后缀
    }

    /**
     * 获取本类操作表名称
     * @return  表名称
     */
    public String getTableName() { //获取本类操作表名称
        return TableName;
    }

    protected String getIDFieldName() { //获取主键或者可以确定唯一记录的字段名称
        return IDFieldName;
    }

    protected String[] getNumericFieldsName() { //获取数值型字段名称
        return NumericFieldsName;
    }

    protected String[] getStringFieldsName() { //获取字符型字段名称
        return StringFieldsName;
    }

    protected String[] getDatetimeFieldsName() { //获取日期时间型字段名称
        return DatetimeFieldsName;
    }

    protected String[] getTextFieldsName() { //获取大字符串型字段名称
        return TextFieldsName;
    }

    /**
     * 获取指定ID的数据集
     * @param strID 要检索的ID
     * @return 指定ID的数据集
     */
    public static Vector getRecordByID(String strID)
    {
       return getRecordBySearch(strID,"","","","","","","","","","","","","","","");
    }

     /**
      * 获取指定ID的数据集
      * @param intID 要检索的ID
      * @return 指定ID的数据集
      */
     public static Vector getRecordByID(int intID)
     {
        return getRecordBySearch(intID + "","","","","","","","","","","","","","","","");
     }

     /**
      * 获取符合指定搜索条件记录的数据集
      * @param strIDs String
      * @param strTitle String
      * @param strFartherID String
      * @param strIsReqRe String
      * @param strPublishTimeFrom String
      * @param strPublishTimeTo String
      * @param strContent String
      * @param strIsTop String
      * @param strBoardID String
      * @param strPublishUserID String
      * @param strIsLock String
      * @param strBoardName String
      * @param strGroupName String
      * @param strNickName String
      * @param strOrderBy String
      * @param strIsDesc String
      * @return Vector 符合指定搜索条件记录的数据集
      */
     public static Vector getRecordBySearch(String strIDs,String strTitle,String strFartherID,String strIsReqRe,String strPublishTimeFrom,String strPublishTimeTo,String strContent,String strIsTop,String strBoardID,String strPublishUserID,String strIsLock,String strBoardName,String strGroupName,String strNickName,String strOrderBy,String strIsDesc)
    {
      String strSQL = "select a.[ID],a.[Title],a.[Expression],a.[FartherID],a.[IsReqRe],a.[PublishTime],a.[Content],a.[ViewTimes],a.[IsTop],a.[BoardID],a.[PublishUserID],a.[IsLock],b.[BoardName],c.[GroupName],d.[NickName] from " + TableName + " as a left outer join BBSBoard as b on (a.[BoardID]=b.[ID]) left outer join BBSBoardGroup as c on (b.[GroupID]=c.[ID]) left outer join BBSUserInfo as d on(a.[PublishUserID]=d.[ID]) WHERE a.[ID] > 0";
      if (strIDs.trim().length() > 0)
      {
        strSQL += " and (a.[ID] in (" + strIDs + "))";
      }

      if (strTitle.trim().length() > 0)
      {
        strSQL += " and a.[Title] like '%" + strTitle + "%'";
      }
      if (strFartherID.trim().length() > 0)
      {
        strSQL += " and a.[FartherID] in (" + strFartherID + ")";
      }
      if (strIsReqRe.trim().length() > 0)
      {
        if (strIsReqRe.equalsIgnoreCase("True"))
        {
          strSQL += " and a.[IsReqRe] = 1";
        }
        else if (strIsReqRe.equalsIgnoreCase("False"))
        {
          strSQL += " and a.[IsReqRe] = 0";
        }
      }
      if (strPublishTimeFrom.trim().length() > 0)
      {
        strSQL += " and a.[PublishTime]>='" + strPublishTimeFrom + " 00:00:00.000'";
      }
      if (strPublishTimeTo.trim().length() > 0)
      {
        strSQL += " and a.[PublishTime]<='" + strPublishTimeTo + " 23:59:59.999'";
      }
      if (strContent.trim().length() > 0)
      {
        strSQL += " and a.[Content] like '%" + strContent + "%'";
      }
      if (strIsTop.trim().length() > 0)
      {
        if (strIsTop.equalsIgnoreCase("True"))
        {
          strSQL += " and a.[IsTop] = 1";
        }
        else if (strIsTop.equalsIgnoreCase("False"))
        {
          strSQL += " and a.[IsTop] = 0";
        }
      }
      if (strBoardID.trim().length() > 0)
      {
        strSQL += " and a.[BoardID] in (" + strBoardID + ")";
      }
      if (strPublishUserID.trim().length() > 0)
      {
        strSQL += " and a.[PublishUserID] in (" + strPublishUserID + ")";
      }
      if (strIsLock.trim().length() > 0)
      {
        if (strIsLock.equalsIgnoreCase("True"))
        {
          strSQL += " and a.[IsLock] = 1";
        }
        else if (strIsLock.equalsIgnoreCase("False"))
        {
          strSQL += " and a.[IsLock] = 0";
        }
      }
      if (strBoardName.trim().length() > 0)
      {
        strSQL += " and b.[BoardName] like '%" + strBoardName + "%'";
      }
      if (strGroupName.trim().length() > 0)
      {
        strSQL += " and c.[GroupName] like '%" + strGroupName + "%'";
      }
      if (strNickName.trim().length() > 0)
      {
        strSQL += " and d.[NickName] like '%" + strNickName + "%'";
      }
      if (strOrderBy.trim().length() > 0)
      {
        if (strIsDesc.equalsIgnoreCase("True"))
        {
          strSQL += " Order by " + strOrderBy + " desc";
        }
        else
        {
          strSQL += " Order by " + strOrderBy + "";
        }
      }
      else
      {
        strSQL += " Order by a.ID desc";
      }
      Vector vt = SQLManager.GetResultSet(strSQL);
      return vt;
  }

  /**
   * 更新文章显示次数
   * @param strIDs String 文章IDs
   * @param iAddTimes int 更新次数
   */
  public static void addArticleShowTimes(String strIDs,int iAddTimes)
  {
    SQLManager.ExcuteSQL("Update " + TableName + " set ViewTimes=ViewTimes + (" + iAddTimes + ") where ID in (" + strIDs + ")");
  }

  /**
   * 更新文章显示次数
   * @param strIDs String 文章IDs
   */
  public static void addArticleShowTimes(String strIDs)
  {
    addArticleShowTimes(strIDs,1);
  }

  /**
   * 重载插入记录的方法,增加用户发表文章数的自动计算和用户等级的自动调整
   * @param m_request Request 包含文章信息的Request
   * @return int 发表文章的ID或者错误代码
   */
  public int InsertRecord(Request m_request)
    {
      int iReturnValue = 0;
      iReturnValue = super.InsertRecord(m_request);
      SQLManager.ExcuteSQL("Update BBSUserInfo set ArticleNum=ArticleNum+1 where ID in (" + m_request.GetString(InsertParament("PublishUserID")) + ")");
      Vector vBBSPost = SQLManager.GetResultSet("Select top 1 ID from BBSPost Where MinArticleNum<(Select ArticleNum from BBSUserInfo where ID in (" + m_request.GetString(InsertParament("PublishUserID")) + ")) Order By MinArticleNum desc");
      if(vBBSPost.size()>0)
      {
        SQLManager.ExcuteSQL("BBSUserInfo set PostID=" + ((Vector)vBBSPost.get(0)).get(0).toString() + " where ID in (" + m_request.GetString(InsertParament("PublishUserID")) + ")");
      }
      return iReturnValue;
    }

}

⌨️ 快捷键说明

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