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

📄 forumstylemanager.java

📁 一个用jsp写的完整的论坛源代码
💻 JAVA
字号:
package com.bcxy.bbs.forum;

/**
 * Title:
 * Description:
 * Copyright:
 * Company: www.liyunet.com
 * 
 * @author lishujiang	
 * @version 1.0
 */

import java.util.Vector;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.bcxy.bbs.util.BBSConst;
import com.bcxy.bbs.util.ParamUtil;
import com.bcxy.cache.CacheManager;
import com.bcxy.conf.ENV;
import com.bcxy.db.JdbcWrapper;

public class ForumStyleManager {
	
	private static Logger log = Logger.getLogger(ForumStyleManager.class);
	
	public static ForumStyle getForumStyle(int styleID)
	{
		ForumStyle fs = null;
		try{
			fs = (ForumStyle)CacheManager.getCache(ENV.GATEWAY).get("forumstyle"+styleID);
			if(fs==null){
				fs = new ForumStyle(styleID);
				CacheManager.getCache(ENV.GATEWAY).put("forumstyle"+styleID, fs);
			}
		}catch(ForumStyleNotFoundException e){
			log.error("论坛样式不存在", e);
		}catch(Exception e){
			log.error("取得论坛样式出错", e);
		}
		return fs;
	}
	
	public static Vector getForumStyles()
	{
		Vector fss = new Vector();
		JdbcWrapper jw = new JdbcWrapper();		
		try{
			jw.executeQuery("select id from " + BBSConst.TABLE_FORUMSTYLE + " where flag!=0 order by id");
			while(jw.next()){
				ForumStyle fs = getForumStyle(jw.getInt(1));
				fss.add(fs);
			}
		}catch(Exception e){
			log.error("取得论坛样式出错", e);
		}finally{
			jw.close();
		}
		return fss;
	}

	public static Vector getAllForumStyles()
	{
		Vector fss = new Vector();
		JdbcWrapper jw = new JdbcWrapper();		
		try{
			jw.executeQuery("select id from " + BBSConst.TABLE_FORUMSTYLE + " order by id");
			while(jw.next()){
				ForumStyle fs = getForumStyle(jw.getInt(1));
				fss.add(fs);
			}
		}catch(Exception e){
			log.error("取得论坛样式出错", e);
		}finally{
			jw.close();
		}
		return fss;
	}

	public static void saveNew(HttpServletRequest request) throws Exception{
		int id = ParamUtil.getInt(request, "id", 0);
		String styleName = ParamUtil.getString(request, "stylename", "");
		int flag = ParamUtil.getInt(request, "flag", 0);
		String tableBack = ParamUtil.getString(request, "Tableback", "");
		String aTableBack = ParamUtil.getString(request, "aTableback", "");
		String tableTitle = ParamUtil.getString(request, "Tabletitle", "");
		String aTableTitle = ParamUtil.getString(request, "aTabletitle", "");
		String tableBody = ParamUtil.getString(request, "Tablebody", "");
		String aTableBody = ParamUtil.getString(request, "aTablebody", "");
		String tableContent = ParamUtil.getString(request, "TableContent", "");
		String tableFont = ParamUtil.getString(request, "TableFont", "");
		String alertFont = ParamUtil.getString(request, "AlertFont", "");
		String bodyBgImage = ParamUtil.getString(request, "bodybgimage", "");
		JdbcWrapper jw = new JdbcWrapper();
		String sql = null;
		try{
			sql = " insert into " + BBSConst.TABLE_FORUMSTYLE + "(id,stylename,tableback,atableback,tabletitle,atabletitle,tablebody,atablebody,tablefont,tablecontent,alertfont,flag,bodybgimage) "
				+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?) ";
			jw.prepareStatement(sql);
			int i = 1;
			jw.setInt(i++, id);
			jw.setString(i++,styleName);
			jw.setString(i++,tableBack);
			jw.setString(i++,aTableBack);
			jw.setString(i++,tableTitle);
			jw.setString(i++,aTableTitle);
			jw.setString(i++,tableBody);
			jw.setString(i++,aTableBody);
			jw.setString(i++,tableFont);
			jw.setString(i++,tableContent);
			jw.setString(i++,alertFont);
			jw.setInt(i++, flag);
			jw.setString(i++,bodyBgImage);
			jw.executeUpdate();
		}catch(Exception e){
			log.error("添加论坛样式出错", e);
			throw new Exception("添加论坛样式出错");
		}finally{
			jw.close();
		}
	}
	
	public static void saveEdit(HttpServletRequest request) throws Exception{
		int id = ParamUtil.getInt(request, "editid", 0);
		int newid = ParamUtil.getInt(request, "id", 0);
		String styleName = ParamUtil.getString(request, "stylename", "");
		int flag = ParamUtil.getInt(request, "flag", 0);
		String tableBack = ParamUtil.getString(request, "Tableback", "");
		String aTableBack = ParamUtil.getString(request, "aTableback", "");
		String tableTitle = ParamUtil.getString(request, "Tabletitle", "");
		String aTableTitle = ParamUtil.getString(request, "aTabletitle", "");
		String tableBody = ParamUtil.getString(request, "Tablebody", "");
		String aTableBody = ParamUtil.getString(request, "aTablebody", "");
		String tableContent = ParamUtil.getString(request, "TableContent", "");
		String tableFont = ParamUtil.getString(request, "TableFont", "");
		String alertFont = ParamUtil.getString(request, "AlertFont", "");
		String bodyBgImage = ParamUtil.getString(request, "bodybgimage", "");
		JdbcWrapper jw = new JdbcWrapper();
		String sql = null;
		try{
			sql = " update " + BBSConst.TABLE_FORUMSTYLE + " set id=?,stylename=?,tableback=?,atableback=?,tabletitle=?,atabletitle=?,tablebody=?,atablebody=?,tablefont=?,tablecontent=?,alertfont=?,flag=?,bodybgimage=? "
				+ " where id=? ";
			jw.prepareStatement(sql);
			int i = 1;
			jw.setInt(i++, newid);
			jw.setString(i++,styleName);
			jw.setString(i++,tableBack);
			jw.setString(i++,aTableBack);
			jw.setString(i++,tableTitle);
			jw.setString(i++,aTableTitle);
			jw.setString(i++,tableBody);
			jw.setString(i++,aTableBody);
			jw.setString(i++,tableFont);
			jw.setString(i++,tableContent);
			jw.setString(i++,alertFont);
			jw.setInt(i++, flag);
			jw.setString(i++,bodyBgImage);
			jw.setInt(i++, id);
			jw.executeUpdate();
			//
			CacheManager.getCache(ENV.GATEWAY).remove("forumstyle"+id);
		}catch(Exception e){
			log.error("修改论坛样式出错", e);
			throw new Exception("修改论坛样式出错");
		}finally{
			jw.close();
		}		
	}
	
	public static void del(HttpServletRequest request) throws Exception{
		int id = ParamUtil.getInt(request, "id", 0);
		JdbcWrapper jw = new JdbcWrapper();
		String sql = null;
		try{
			sql = " delete from " + BBSConst.TABLE_FORUMSTYLE + " where id=? ";
			jw.prepareStatement(sql);
			jw.setInt(1, id);
			jw.executeUpdate();
		}catch(Exception e){
			log.error("删除论坛样式出错", e);
			throw new Exception("删除论坛样式出错");
		}finally{
			jw.close();
		}
	}
}

⌨️ 快捷键说明

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