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

📄 product.java

📁 在线拍卖系统
💻 JAVA
字号:
package j2eebbs;

import java.sql.ResultSet;
import java.util.Date;
import java.util.Vector;

public class Product {

	private int id;

	private String name;

	private String introduce;//介绍
	
	private String image;//图片

	private int type;//产品类型

	private Date submitDate ;//发布产品时间

	private int endTime ;//过期时间,单位为天  比如 1天,2天

	private int price ;//初始价格

	private int status = 1 ;//产品状态 1未审核 2审核通过


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Date getSubmitDate() {
		return submitDate;
	}

	public void setSubmitDate(Date submitDate) {
		this.submitDate = submitDate;
	}

	public int getEndTime() {
		return endTime;
	}

	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Product( String name, String introduce, String image,
			int type,  int endTime, int price) {
		super();
		this.name = name;
		this.introduce = introduce;
		this.image = image;
		this.type = type;
		this.endTime = endTime;
		this.price = price;
	}

	
	public Product() {
		// TODO Auto-generated constructor stub
	}

	public static Vector search(DB db) throws Exception {
		Vector productVector = new Vector();
		ResultSet rs;
		String strSql;
		strSql = "select * from product";
		rs = db.OpenSql(strSql);
		while (rs.next()) {
			Product product = new Product();
			product.setId(rs.getInt("id"));
			product.setImage(rs.getString("image"));
			product.setIntroduce(rs.getString("introduce"));
			product.setName(rs.getString("name"));
			product.setPrice(rs.getInt("price"));
			product.setStatus(rs.getInt("status"));
			product.setSubmitDate(rs.getDate("submitDate"));
			product.setType(rs.getInt("type"));
			product.setEndTime(rs.getInt("endtime"));
			productVector.add(product);
		}
		return productVector;
	}
	public static Vector getUserProduct(DB db,int userid) throws Exception {
		Vector productVector = new Vector();
		ResultSet rs;
		String strSql;
		strSql = "select * from product where userid="+userid;
		rs = db.OpenSql(strSql);
		while (rs.next()) {
			Product product = new Product();
			product.setId(rs.getInt("id"));
			product.setImage(rs.getString("image"));
			product.setIntroduce(rs.getString("introduce"));
			product.setName(rs.getString("name"));
			product.setPrice(rs.getInt("price"));
			product.setStatus(rs.getInt("status"));
			product.setSubmitDate(rs.getDate("submitDate"));
			product.setType(rs.getInt("type"));
			product.setEndTime(rs.getInt("endtime"));
			productVector.add(product);
		}
		return productVector;
	}

	public  boolean insert(DB db) throws Exception {
		String strSql;
		strSql = "insert into product(name,introduce,type,endtime,submitDate,price,image,status)values" +
				"('" + name + "','" + introduce + "','"+ type + "','"+ endTime + "','"+ submitDate + "','"+ price + "','"+ image + "','"+ status+"')";
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}
	}

	public static boolean delete(DB db, int id) throws Exception {
		String strSql;
		strSql = "delete from product where id=" + id;
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}
	}

}

⌨️ 快捷键说明

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