forumnewsmanager.java

来自「一个用jsp写的完整的论坛源代码」· Java 代码 · 共 92 行

JAVA
92
字号
package com.bcxy.bbs.forum;

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

import java.util.Vector;

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

public class ForumNewsManager {

	public static ForumNews getForumNews(int forumID)
			throws ForumNewsNotFoundException {
		ForumNews temp = null;
		try {
			temp = (ForumNews)CacheManager.getCache(ENV.FORUM_NEWS).get("news"+(forumID));
			if(temp==null){
				temp = new ForumNews(forumID);
				CacheManager.getCache(ENV.FORUM_NEWS).put("news"+(forumID),temp);
			}
			return temp;
		} catch (Exception e) {
			throw new ForumNewsNotFoundException();
		}

	}

	/**
	 * 
	 * @param newsID
	 * @return
	 * @throws Exception
	 */
	public static ForumNews getSignalForumNews(int newsID) throws Exception {
		ForumNews forumNews = null;
		try {
			forumNews = (ForumNews)CacheManager.getCache(ENV.GATEWAY).get("news"+newsID);
			if(forumNews==null){
				forumNews = new ForumNews(newsID);
				CacheManager.getCache(ENV.GATEWAY).put("news"+(newsID),forumNews);
			}
		} catch (Exception e) {
			throw new ForumNewsNotFoundException();
		}
		return forumNews;
	}

	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public static Vector getForumNewsVector() throws Exception {
		JdbcWrapper jw = new JdbcWrapper("select id from " + BBSConst.TABLE_BBSNEWS + "  order by id desc");		
		Vector forumNewsVector = new Vector();
		while (jw.next()) {
			int id = jw.getInt(1);
			ForumNews forumNews = getSignalForumNews(id);
			forumNewsVector.add(forumNews);
		}
		return forumNewsVector;
	}

	/**
	 * 
	 * @param forumID
	 * @return
	 * @throws Exception
	 */
	public static Vector getForumNewsVector(int forumID) throws Exception {
		JdbcWrapper jw = new JdbcWrapper("select id from " + BBSConst.TABLE_BBSNEWS + " where boardID="
				+ forumID + " order by id desc");		
		Vector forumNewsVector = new Vector();
		while (jw.next()) {
			int id = jw.getInt(1);
			ForumNews forumNews = getSignalForumNews(id);
			forumNewsVector.add(forumNews);
		}
		return forumNewsVector;
	}
}

⌨️ 快捷键说明

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