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

📄 forumbookmark.java

📁 BBS论坛设计JSP+MYSQL
💻 JAVA
字号:
package com.bcxy.bbs.forum;
/**
 * <p>Title:</p>
 * <p>Description:</p>
 * <p>Copyright:</p>
 * <p>Company: www.liyunet.com</p>
 * 
 * @author lishujiang
 * @version 1.0
 */
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;

import com.bcxy.bbs.util.GCookie;
import com.bcxy.bbs.util.ParamUtil;
import com.bcxy.db.SqlQuery;
import com.bcxy.util.SysUtil;

public class ForumBookMark
{
	public ForumBookMark(){
	}
	public  static void addFav(HttpServletRequest request) throws Exception{
		int forumID;
		try{
			forumID=ParamUtil.getInt(request,"forumID");
		}
		catch(Exception e){
			throw new Exception("请指定论坛版面。");
		}
		int announceID;
		try{
			announceID=ParamUtil.getInt(request,"announceID");
		}
		catch(Exception e){
			throw new Exception("请指定相关贴子或者是非法的贴子参数。");
		}

		int rootID;
		try{
			rootID=ParamUtil.getInt(request,"rootID");
		}
		catch(Exception e){
			throw new Exception("请指定相关贴子或者是非法的贴子参数。");
		}

		////////////////////////////////////
		String url="dispbbs.jsp?forumID="+forumID+"&rootID="+rootID+"&announceID="+announceID;
		String sql="select topic,rootid,announceid,boardid from bbs1 where announceid="+announceID+" and rootid="+rootID+" and boardid="+forumID;
		SqlQuery rs = new SqlQuery(sql);
		if(!rs.next()){
			throw new Exception("没有相关贴子。");
		}
		String topic=rs.getString(1);
		topic = SysUtil.encodeInDB(topic);
		String userName=GCookie.getCookieValue(request,"UJBBUName","");
		
		sql="insert into bookmark(username,topic,url,addtime) values('"+userName+"','"+topic+"','"+url+"',now())";
		rs.doUpdate(sql);
	}
	public static Vector getBookMarkList(HttpServletRequest request) throws Exception{
		String userName=GCookie.getCookieValue(request,"UJBBUName","");
		String sql="select * from bookmark where username='"+userName+"' order by id desc";
		SqlQuery rs = new SqlQuery(sql);

		Vector bookMarkList=new Vector();
		while(rs.next()){
			BookMark bookMark=new BookMark();
			bookMark.setID(rs.getInt(1));
			bookMark.setUserName(rs.getString(2));
			bookMark.setURL(rs.getString(3));
			bookMark.setTopic(rs.getString(4));
			bookMark.setAddTime(rs.getString(5));
			bookMarkList.add(bookMark);
		}
		return bookMarkList;

	}
	public static void delBookMark(HttpServletRequest request) throws Exception{
		int ID;
		String userName=GCookie.getCookieValue(request,"UJBBUName","");
		
		try{
			ID=ParamUtil.getInt(request,"id");
		}
		catch(Exception e){
			throw new Exception("请指定相应的参数!");
		}
		String sql="delete from bookmark where username='"+userName+"' and id="+ID;
		SqlQuery dbc=new SqlQuery();
		dbc.doUpdate(sql);
	}

}

⌨️ 快捷键说明

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