e拍在线拍卖系统系统.doc_第1页
e拍在线拍卖系统系统.doc_第2页
e拍在线拍卖系统系统.doc_第3页
e拍在线拍卖系统系统.doc_第4页
e拍在线拍卖系统系统.doc_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

常 州 机 电 职 业 技 术 学 院一 正文1. 课题描述2. 开发环境3. 采用的技术4. 需求分析5. 数据库设计6. 阶段项目的流程7. 功能运行的效果二 课程设计小结三 参考文献四 附表正文一、 课题描述E拍在线拍卖系统是一个C2C在线交易平台,交易以拍卖的方式完成。二、需求分析、1 用户注册2 用户登录、注销3. 浏览正在拍卖的商品4 查看商品出价价格5 普通用户登录后,可以:添加自己要拍卖的东西对正在拍卖的商品进行竞价对自己拍卖的商品选择买家成交三、数据库设计Message(发帖)字段名称数据类型长度是否为空messageIDint4否titleVarchar50否messageContentVarchar500是writeVarchar20是writeDateVarchar30是countint否News(新闻)字段名称数据类型长度是否为空备注NewsIDInt4否新闻idtitleVarchar50否新闻标题NewsContentVarchar400是新闻内容createTimeDatatime25是发布时间Products(商品)字段名称数据类型长度是否为空备注proidInt4否商品id,主键proNameVarchar20否商品的名称proBrandVarchar20是商品品牌proModelVarchar20是型号pripricefloat默认是价格propicVarchar60是商品图片proDescVarchar500是商品介绍REVERT字段名称数据类型长度是否为空revertIDInt4否messageIDInt4否ContentVarchar300是WriterVarchar20是writerDateVarchar30是REVERT字段名称数据类型长度是否为空userIDInt4usernameVarchar20PasswordVarchar20StatusInt4四、业务类描述(Java代码)Dao类实体类:代码:package y2ssh.zhangcuishan.dao.hibimpl;import java.io.Serializable;import java.util.List;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.criterion.Example;public abstract class BaseHibernateDAO protected Session getSession() return HibernateSessionFactory.getSession(); protected void add(Object item)try Transaction tx = getSession().beginTransaction(); getSession().save(item); mit(); catch (RuntimeException re) throw re; protected Object get(Serializable id,Class clazz)try Object item = getSession() .get(clazz, id);return item; catch (RuntimeException re) throw re; protected void del(Serializable id,Class clazz)try Transaction tx = getSession().beginTransaction(); getSession().delete(this.get(id, clazz); mit(); catch (RuntimeException re) throw re; protected void update(Object item)try Transaction tx = getSession().beginTransaction(); getSession().update(item); mit(); catch (RuntimeException re) throw re; protected List search(Object condition,Class clazz)try List results = getSession() .createCriteria(clazz) .add(Example.create(condition) .list(); return results; catch (RuntimeException re) throw re; package y2ssh.zhangcuishan.dao.hibimpl;import java.io.Serializable;import java.util.List;import y2ssh.zhangcuishan.dao.BidDAO;import y2ssh.zhangcuishan.entity.Bid;public class BidDAOHibimpl extends BaseHibernateDAO implements BidDAO public void add(Bid item) super.add(item);public void del(Serializable key) super.del(key, Bid.class);public Bid get(Serializable key) Bid item = (Bid)super.get(key, Bid.class);return item;public List search(Bid condition) List ret = super.search(condition, Bid.class);return ret;public void update(Bid item) super.update(item);package y2ssh.zhangcuishan.dao.hibimpl;import java.io.Serializable;import java.util.List;import y2ssh.zhangcuishan.dao.GoodsDAO;import y2ssh.zhangcuishan.entity.Goods;public class GoodsDAOHibimpl extends BaseHibernateDAO implements GoodsDAO public void add(Goods item) super.add(item);public void del(Serializable key) super.del(key, Goods.class);public Goods get(Serializable key) Goods item = (Goods)super.get(key, Goods.class);return item;public List search(Goods condition) List ret = super.search(condition, Goods.class);return ret;public void update(Goods item) super.update(item);package y2ssh.zhangcuishan.dao.hibimpl;import org.hibernate.HibernateException;import org.hibernate.Session;import org.hibernate.cfg.Configuration;public class HibernateSessionFactory private static String CONFIG_FILE_LOCATION = /hibernate.cfg.xml;private static final ThreadLocal threadLocal = new ThreadLocal(); private static Configuration configuration = new Configuration(); private static org.hibernate.SessionFactory sessionFactory; private static String configFile = CONFIG_FILE_LOCATION; private HibernateSessionFactory() public static Session getSession() throws HibernateException Session session = (Session) threadLocal.get();if (session = null | !session.isOpen() if (sessionFactory = null) rebuildSessionFactory();session = (sessionFactory != null) ? sessionFactory.openSession(): null;threadLocal.set(session); return session; public static void rebuildSessionFactory() try configuration.configure(configFile);sessionFactory = configuration.buildSessionFactory(); catch (Exception e) System.err.println(% Error Creating SessionFactory %);e.printStackTrace(); public static void closeSession() throws HibernateException Session session = (Session) threadLocal.get(); threadLocal.set(null); if (session != null) session.close(); public static org.hibernate.SessionFactory getSessionFactory() return sessionFactory;public static void setConfigFile(String configFile) HibernateSessionFactory.configFile = configFile;sessionFactory = null;public static Configuration getConfiguration() return configuration;package y2ssh.zhangcuishan.dao.hibimpl;import java.util.List;import y2ssh.zhangcuishan.dao.UserDAO;import y2ssh.zhangcuishan.entity.User;public class UserDAOHibimpl extends BaseHibernateDAO implements UserDAOpublic User get(java.io.Serializable key)User item = (User)super.get(key, User.class);return item;public void add(User item) super.add(item);public List search(User condition) List ret = super.search(condition, User.class);return ret;package y2ssh.zhangcuishan.dao.jdbcimpl;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public abstract class BaseJdbcDAO private String dbUser = sa;private String dbPwd = pwd;private String driver = com.microsoft.jdbc.sqlserver.SQLServerDriver;private String url = jdbc:microsoft:sqlserver:/localhost:1433;DataBaseName=epai; protected Connection conn = null; protected Statement stmt = null; protected PreparedStatement pstmt = null; protected ResultSet rs = null; private Connection getConn() Connection conn = null; try Class.forName(driver); conn = DriverManager .getConnection( url, dbUser, dbPwd); catch (Exception e) e.printStackTrace(); return conn; protected void openConn() this.conn = getConn(); protected void closeAll() if (rs != null) try rs.close(); catch (SQLException e) e.printStackTrace(); if (stmt != null) try stmt.close(); catch (SQLException e) e.printStackTrace(); if (pstmt != null) try pstmt.close(); catch (SQLException e) e.printStackTrace(); if (conn != null) try conn.close(); catch (SQLException e) e.printStackTrace(); package y2ssh.zhangcuishan.dao.jdbcimpl;import java.io.Serializable;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import y2ssh.zhangcuishan.dao.UserDAO;import y2ssh.zhangcuishan.entity.User;public class UserDAOJdbcImpl extends BaseJdbcDAO implements UserDAO public void add(User item) openConn(); String sql = INSERT INTO t_user (user_name, user_password, user_id_code, user_tel, user_addr, user_zip, user_status) + VALUES ( ?, ?, ?, ?, ?, ?, ? ); try pstmt = conn.prepareStatement(sql); int index = 1; pstmt.setString(index+, item.getUserName(); pstmt.setString(index+, item.getUserPassword(); pstmt.setString(index+, item.getUserIdCode(); pstmt.setString(index+, item.getUserTel(); pstmt.setString(index+, item.getUserAddr(); pstmt.setString(index+, item.getUserZip(); pstmt.setInt(index+, item.getUserStatus(); pstmt.executeUpdate(); catch (SQLException e) e.printStackTrace(); closeAll();SuppressWarnings(unchecked)public List search(User condition) List list = new ArrayList();String sql = SELECT user_id,user_name, user_password, user_id_code, user_tel, user_addr, user_zip, user_status + FROM t_user WHERE 1=1 ; if (condition!=null) if (condition.getUserId()!=0) sql += AND user_id = + condition.getUserId(); if (condition.getUserName()!=null & !condition.getUserName().trim().equals() sql += AND user_name like % + condition.getUserName() + % ; openConn(); try stmt = conn.createStatement(); rs = stmt.executeQuery(sql); while (rs.next() User item = new User(); item.setUserId(rs.getInt(user_id); item.setUserName(rs.getString(user_name); item.setUserPassword(rs.getString(user_password); item.setUserIdCode(rs.getString(user_id_code); item.setUserTel(rs.getString(user_tel); item.setUserAddr(rs.getString(user_addr); item.setUserZip(rs.getString(user_zip); item.setUserStatus(rs.getInt(user_status); list.add(item); catch (SQLException e) e.printStackTrace(); closeAll(); return list;public User get(Serializable key) / TODO 自动生成方法存根return null;package y2ssh.zhangcuishan.dao;import java.util.List;import y2ssh.zhangcuishan.entity.Bid;public interface BidDAO public void add(Bid item);public void del(java.io.Serializable key);public void update(Bid item);public Bid get(java.io.Serializable key);public List search(Bid condition);package y2ssh.zhangcuishan.dao;import java.util.List;import y2ssh.zhangcuishan.entity.Goods;public interface GoodsDAO public void add(Goods item);public void del(java.io.Serializable key);public void update(Goods item);public Goods get(java.io.Serializable key);public List search(Goods condition);package y2ssh.zhangcuishan.dao;import java.util.List;import y2ssh.zhangcuishan.entity.User;public interface UserDAO public User get(java.io.Serializable key);public void add(User item);public List search(User condition);package y2ssh.zhangcuishan.entity;import java.util.Date;public class Bid implements java.io.Serializable private static final long serialVersionUID = -7098966278403802603L;private Long bidId; private Date bidTime; private Double bidPrice; private Integer bidStatus; private Goods goods; private User buyer; public User getBuyer() return buyer;public void setBuyer(User buyer) this.buyer = buyer;public Goods getGoods() return goods;public void setGoods(Goods goods) this.goods = goods; public Bid() public Bid(Goods goodsId, User buyerId, Date bidTime, Double bidPrice, Integer bidStatus) this.goods = goodsId; this.buyer = buyerId; this.bidTime = bidTime; this.bidPrice = bidPrice; this.bidStatus = bidStatus; public Long getBidId() return this.bidId; public void setBidId(Long bidId) this.bidId = bidId; public Date getBidTime() return this.bidTime; public void setBidTime(Date bidTime) this.bidTime = bidTime; public Double getBidPrice() return this.bidPrice; public void setBidPrice(Double bidPrice) this.bidPrice = bidPrice; public Integer getBidStatus() return this.bidStatus; public void setBidStatus(Integer bidStatus) this.bidStatus = bidStatus; package y2ssh.zhangcuishan.entity;import java.util.Date;import java.util.HashSet;import java.util.Set;import y2ssh.zhangcuishan.util.JbUtils;public class Goods implements java.io.Serializable private static final long serialVersionUID = -4649216120593895204L; private Long goodsId; private String goodsName; private Double goodsPrice; private String goodsPic; private String goodsDesc; private Date beginTime; private Date endTime; public String toString() return this.goodsId + . + this.goodsName; private Set bids = new HashSet(0); private User saler; private User buyer; private Integer goodsStatus; public Goods() public Goods(String goodsName, Double goodsPrice, User salerId, Integer goodsStatus) this.goodsName = goodsName; this.goodsPrice = goodsPrice; this.saler = salerId; this.goodsStatus = goodsStatus; public Goods(String goodsName, Double goodsPrice, String goodsPic, String goodsDesc, User salerId, Date beginTime, Date endTime, User buyerId, Integer goodsStatus) this.goodsName = goodsName; this.goodsPrice = goodsPrice; this.goodsPic = goodsPic; this.goodsDesc = goodsDesc; this.saler = salerId; this.beginTime = beginTime; this.endTime = endTime; this.buyer = buyerId; this.goodsStatus = goodsStatus; public Long getGoodsId() return this.goodsId; public void setGoodsId(Long goodsId) this.goodsId = goodsId; public String getGoodsName() return this.goodsName; public void setGoodsName(String goodsName) this.goodsName = goodsName; public Double getGoodsPrice() return this.goodsPrice; public void setGoodsPrice(Double goodsPrice) this.goodsPrice = goodsPrice; public String getGoodsPic() return this.goodsPic; public void setGoodsPic(String goodsPic) this.goodsPic = goodsPic; public String getGoodsDesc() return this.goodsDesc; public void setGoodsDesc(String goodsDesc) this.goodsDesc = goodsDesc; public Date getBeginTime() return this.beginTime; public void setBeginTime(Date beginTime) this.beginTime = beginTime; public Date getEndTime() return this.endTime; public void setEndTime(Date endTime) this.endTime = endTime; public User getBuyer() return buyer;public void setBuyer(User buyer) this.buyer = buyer;public User getSaler() return saler;public void setSaler(User saler) this.saler = saler;public Integer getGoodsStatus() return this.goodsStatus; public void setGoodsStatus(Integer goodsStatus) this.goodsStatus = goodsStatus; public Set getBids() return bids;public void setBids(Set bids) this.bids = bids; public String getBeginTimeString() return JbUtils.formatDate(this.beginTime);public void setBeginTimeString(String beginTime) this.beginTime = JbUtils.parseDate(beginTime);public String getEndTimeString() return JbUtils.formatDate(this.endTime);public void se

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论