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

📄 forumlinkadmin.java

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

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

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 ForumLinkAdmin {

	private static Logger log = Logger.getLogger(ForumLinkAdmin.class);
	
	public ForumLinkAdmin() {
	}

	public static void saveNew(HttpServletRequest request) throws Exception {
		ForumAdmin.checkAdmin(request);
		String url = ParamUtil.getString(request, "url");
		String readme = ParamUtil.getString(request, "readme");
		String name = ParamUtil.getString(request, "name");
		if (url == null || readme == null || name == null){
			throw new Exception("请输入完整联盟论坛信息。");
		}
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.prepareStatement("insert into " + BBSConst.TABLE_BBSLINK + "(boardname,readme,url) values(?,?,?)");
			jw.setString(1, name);
			jw.setString(2, readme);
			jw.setString(3, url);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("添加联盟论坛出错", e);
			throw e;
		} finally {
			jw.close();
		}
	}

	public static void saveEdit(HttpServletRequest request) throws Exception {
		ForumAdmin.checkAdmin(request);
		int forumLinkID;
		try {
			forumLinkID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请您选择论坛的ID.");
		}
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.prepareStatement("update " + BBSConst.TABLE_BBSLINK + " set boardname=?,readme=?,url=? where id="
							+ forumLinkID);
			jw.setString(1, ParamUtil.getString(request, "name", ""));
			jw.setString(2, ParamUtil.getString(request, "readme", ""));
			jw.setString(3, ParamUtil.getString(request, "url", ""));
			jw.executeUpdate();
			CacheManager.getCache(ENV.FORUM_LINK).remove(String.valueOf(forumLinkID));
		} catch (Exception e) {
			log.error("修改联盟论坛出错", e);
			throw e;
		} finally {
			jw.close();
		}
	}

	public static void del(HttpServletRequest request) throws Exception {
		ForumAdmin.checkAdmin(request);
		int forumLinkID;
		try {
			forumLinkID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请您选择论坛的ID.");
		}
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.executeUpdate("delete from " + BBSConst.TABLE_BBSLINK + " where id=" + forumLinkID);
		} catch (Exception e) {
			log.error("删除联盟论坛出错", e);
			throw e;
		}
		jw.close();
	}

	public static void updateOrders(HttpServletRequest request)
			throws Exception {
		ForumAdmin.checkAdmin(request);
		int newforumLinkID;
		int forumLinkID;
		try {
			newforumLinkID = ParamUtil.getInt(request, "newid");
			forumLinkID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请您选择论坛的ID.");
		}
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.executeUpdate("update " + BBSConst.TABLE_BBSLINK + " set id=" + newforumLinkID
					+ " where id=" + forumLinkID);
		} catch (Exception e) {
			log.error("更新联盟论坛ID出错", e);
			throw e;
		} finally {
			jw.close();
		}
	}

}

⌨️ 快捷键说明

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