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

📄 follownotedao.java

📁 一个仿造淘宝的jsp网站。功能比较完善
💻 JAVA
字号:
package com.jc.taobao.gjj.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.jc.taobao.gjj.db.DBManager;
import com.jc.taobao.gjj.entity.FollowNote;

public class FollowNoteDAO  {
	DBManager dm = new DBManager();

	public int delete(Integer id) {
		String sql = "delete from follownote where fid=" + id;
		return dm.updb(sql);
	}

	public int merge(FollowNote fn) {
		String sql = "update follownote set userid=" + fn.getUserid()
				+ ",mid=" + fn.getMid() + ",'" + fn.getFollowtitle()
				+ "','" + fn.getFollowmessage() + "' where fid=" + fn.getFid();
		return dm.updb(sql);
	}

	public int save(FollowNote fn) {
		String sql = "insert into follownote values("+fn.getUserid()
		+","+fn.getMid()+",'"+fn.getFollowtitle()+"','"+fn.getFollowmessage()+"','"+fn.getFollowtime()+"')";
		return dm.updb(sql);
	}
	
	private List<FollowNote> query(String sql)//查询
	{
		List<FollowNote> list = new ArrayList<FollowNote>();
		ResultSet rs = dm.getRs(sql);
		try {
			while(rs.next())
			{
				FollowNote follow = new FollowNote();
				follow.setFid(rs.getInt("fid"));
				follow.setUserid(rs.getInt("userid"));
				follow.setMid(rs.getInt("mid"));
				follow.setFollowtitle(rs.getString("followtitle"));
				follow.setFollowmessage(rs.getString("followmessage"));
				follow.setFollowtime(rs.getString("followtime"));
				list.add(follow);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
	 public List<FollowNote> querybyALL()//查询所有跟贴信息
	 {
		 String sql="select * from follownote";
		 return query(sql);
	 }
	 
	 public int queryfollownoteCount()
	 {
		 int follownotecount=0;
		 String sql="select count(*) as follownotecount from follownote";
		 try {
			ResultSet rs=dm.getRs(sql);
			 while(rs.next())
			 {
				 follownotecount=rs.getInt("follownotecount");
			 }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return follownotecount;
	 }
	 
	 public List<FollowNote> querybyFid(Integer fid)//根据跟贴号查询跟贴信息
	 {
		 String sql="select * from follownote where fid="+fid;
		 return query(sql);
	 }
	 
	 public List<FollowNote> querybymid(Integer mid)//根据主帖号查询跟贴信息
	 {
		 String sql="select * from follownote where mid="+mid;
		 return query(sql);
	 }
	 
	 public List<FollowNote> querybyfollowtitle(FollowNote follow)//根据跟贴标题查询跟贴信息
	 {
		 String sql="select * from follownote where followtitle like'"+"%"+follow.getFollowtitle()+"%"+"'";
		 return query(sql);
	 }
	 public List<FollowNote> querybyfollowmessage(FollowNote follow)//根据跟贴内容查询跟贴信息
	 {
		 String sql="select * from follownote where followmessage like'"+"%"+follow.getFollowmessage() +"%"+"'";
		 return query(sql);
	 }
	 public int queryfollowcountbymid(Integer mid)
	 {
		 int followcount=0;
		 String sql="select count(fid) as followcount from follownote where mid="+mid;
		 try {
			ResultSet rs=dm.getRs(sql);
			 while(rs.next())
			 {
				 followcount=rs.getInt("followcount");
			 }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return followcount;
	 }
	public List<FollowNote> queryFollowbyuserId(Integer userid)
	{
		String sql="select * from follownote where userid="+userid;
		return query(sql);
	}
	
	public ArrayList queryzuijiamasternote()
	{
		ArrayList alfollo=new ArrayList();
		String sql="select top 6 mid,mm=count(mid) from follownote group by mid order by mm desc";
		ResultSet rs=dm.getRs(sql);
		try {
			while(rs.next())
			{
			   alfollo.add(rs.getInt("mid"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return alfollo;
	}
	
	
	
}

⌨️ 快捷键说明

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