package org.tarena.dao.impl;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.tarena.dao.ProductDao;
import org.tarena.domain.Book;
import org.tarena.domain.Product;
/**
* book 分类dao接口的实现 完成book数据CRUD功能
*
* @author soft01
*
*/
public class JDBCBookDaoImpl extends JDBCBaseDao implements ProductDao {
/**
* FIND_BY_CATI sql 语句 通过d_category_product的cat_id来查找books集合
*/
private static final String FIND_BY_CATID = "select dp.*,db.* from d_category_product dcp join d_product dp on (dcp.product_id=dp.id) join d_book db on (dp.id=db.id) where dcp.cat_id = ? limit ?,?";
/**
* FIND_BY_RECOMMEND sql 语句 通过开发者的意愿来查找books集合
*/
private static final String FIND_BY_RECOMMEND = "select dp.*,db.* from d_product dp join d_book db on (db.id=dp.id) order by db.id limit ?,?";
/**
* FIND_BY_NEW sql 语句 通过上架时间查找books集合
*/
private static final String FIND_BY_NEW = "select dp.*,db.* from d_product dp join d_book db on (db.id=dp.id) order by dp.add_time desc limit ?,?";
/**
* FIND_BY_HOT sql 语句 通过销售量查找books集合
*/
private static final String FIND_BY_HOT = "select dp.*,db.* from d_product dp join d_book db on(db.id=dp.id) left join (select product_id,sum(product_num) sale_num from d_item group by product_id ) t1 on (t1.product_id=dp.id) order by t1.sale_num desc limit ?,?";
/**
* FIND_BY_HOT sql 语句 查找新书销售榜books集合
*/
private static final String FIND_BY_HOTBOARD = "select dp.*,db.* from d_product dp join d_book db on(db.id=dp.id) left join (select product_id,sum(product_num) sale_num from d_item group by product_id ) t1 on (t1.product_id=dp.id) order by t1.sale_num desc,dp.add_time desc limit ?,?";
/**
* FIND_BY_id sql 语句 通过商品id来查找books集合
*/
private static final String FIND_BY_ID = "select dp.*,db.* from d_product dp join d_book db on (db.id=dp.id and dp.id=?)";
/**
* findByCatId(int cid,int begin,int size)
* 通过d_category_product的cat_id来查找books集合
*/
public List<Product> findByCatId(int cid, int begin, int size)
throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(FIND_BY_CATID);
ps.setInt(1, cid);
ps.setInt(2, begin);// 分页起始页
ps.setInt(3, size);// 页面大小
ResultSet rs = ps.executeQuery();
List<Product> pros = new ArrayList<Product>();
while (rs.next()) {
Book book = new Book();
bookInit(rs, book);
pros.add(book);
}
closeConnection();
return pros;
}
/**
* bookInit抽取方法 用来构造book对象
*
* @param rs
* @param book
* @throws SQLException
*/
private void bookInit(ResultSet rs, Book book) throws SQLException {
book.setId(rs.getInt("id"));
book.setProduct_name(rs.getString("product_name"));
book.setFixed_price(rs.getDouble("fixed_price"));
book.setDang_price(rs.getDouble("dang_price"));
book.setProduct_pic(rs.getString("product_pic"));
book.setAdd_time(rs.getLong("add_time"));
book.setAuthor(rs.getString("author"));
book.setDescription(rs.getString("description"));
book.setPublishing(rs.getString("publishing"));
book.setPublish_time(rs.getLong("publish_time"));
book.setKeywords(rs.getString("keywords"));
book.setHas_delete(rs.getInt("has_deleted"));
book.setWord_number(rs.getString("word_number"));
book.setWhich_edtion(rs.getString("which_edtion"));
book.setTotal_page(rs.getString("total_page"));
book.setPrint_time(rs.getLong("print_time"));
book.setPrint_number(rs.getString("print_number"));
book.setIsbn(rs.getString("isbn"));
book.setAuthor_summary(rs.getString("author_summary"));
book.setCatalogue(rs.getString("catalogue"));
}
/**
* findByRecommend()编辑推荐书籍 按照 d_book id 降序排列
*/
public List<Product> findByRecommend(int begin, int size) throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(
FIND_BY_RECOMMEND);
ps.setInt(1, begin);// 分页起始页
ps.setInt(2, size);// 页面大小
ResultSet rs = ps.executeQuery();
List<Product> pros = new ArrayList<Product>();
while (rs.next()) {
Book book = new Book();
bookInit(rs, book);
pros.add(book);
}
closeConnection();
return pros;
}
/**
* findByNew()新书上架 按照 add_time 升序排列
*/
public List<Product> findByNew(int begin, int size) throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(FIND_BY_NEW);
ps.setInt(1, begin);// 分页起始页
ps.setInt(2, size);// 页面大小
ResultSet rs = ps.executeQuery();
List<Product> pros = new ArrayList<Product>();
while (rs.next()) {
Book book = new Book();
bookInit(rs, book);
pros.add(book);
}
closeConnection();
return pros;
}
/**
* findByHot()热书畅销 按照 d_order找查找销售数量 降序排列
*/
public List<Product> findByHot(int begin, int size) throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(FIND_BY_HOT);
ps.setInt(1, begin);// 分页起始页
ps.setInt(2, size);// 页面大小
ResultSet rs = ps.executeQuery();
List<Product> pros = new ArrayList<Product>();
while (rs.next()) {
Book book = new Book();
bookInit(rs, book);
// System.out.println("book_id>>"+book.getId());
pros.add(book);
}
closeConnection();
return pros;
}
/**
* findByHot()热书畅销 按照 d_order找查找销售数量 降序排列
*/
public List<Product> findByHotBoard(int begin, int size) throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(
FIND_BY_HOTBOARD);
ps.setInt(1, begin);// 分页起始页
ps.setInt(2, size);// 页面大小
ResultSet rs = ps.executeQuery();
List<Product> pros = new ArrayList<Product>();
while (rs.next()) {
Book book = new Book();
bookInit(rs, book);
// System.out.println("book_id>>"+book.getId());
pros.add(book);
}
closeConnection();
return pros;
}
/**
* findById()通过产品id来查找该product信息
*/
public Product findById(int id) throws Exception {
// TODO Auto-generated method stub
PreparedStatement ps = openConnection().prepareStatement(FIND_BY_ID);
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
Book book = null;
if (rs.next()) {
book = new Book();
bookInit(rs, book);
// System.out.println("book_id>>"+book.getId());
}
closeConnection();
return book;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
当当图书购物网源码+数据库
共685个文件
gif:232个
html:170个
jpg:68个
5星 · 超过95%的资源 需积分: 44 132 下载量 193 浏览量
2011-12-02
17:44:48
上传
评论 16
收藏 6.07MB RAR 举报
温馨提示
开发工具:MyEclipse + Tomcat + MySql 技术实现:Struts2 + Ajax + JDBC + jQuery + JSP 项目描述:该项目是基于MVC思想的电子商务系统,系统分为四个模块:用户模块(实现用户的注册、登录等)、产品浏览模块(主界面、分类浏览等)、购物车模块(产品添加,删除,恢复,数量更改)、订单模块(订单生成,订单管理)。
资源推荐
资源详情
资源评论
收起资源包目录
当当图书购物网源码+数据库 (685个子文件)
OrderAction.class 7KB
JDBCBookDaoImpl.class 6KB
SessionCartServiceImpl.class 6KB
JDBCUserDaoImpl.class 4KB
JDBCOrderDaoImpl.class 4KB
Book.class 3KB
BookListAction.class 3KB
CartAction.class 3KB
Product.class 3KB
Address.class 3KB
User.class 3KB
Category.class 3KB
JDBCCategoryDaoImpl.class 3KB
LoginAction.class 3KB
RegistAction.class 2KB
ImageUtil.class 2KB
DBUtil.class 2KB
ImageAction.class 2KB
CategoryAction.class 2KB
VerifyAction.class 2KB
Item.class 2KB
Order.class 1KB
EmailUtil.class 1KB
RecommendAction.class 1KB
HotBoardAction.class 1KB
VerifyCodeUtil.class 1KB
CartFactory.class 1KB
DegistUtil.class 1KB
NewAction.class 1KB
HotAction.class 1KB
ValidAction.class 1KB
ProductAction.class 1KB
BaseAction.class 1KB
LoginInterceptor.class 1KB
DbookTest.class 1KB
CategoryAction1.class 1KB
CheckEmailAction.class 1KB
DaoFactory.class 1KB
CartItem.class 1KB
PageAction.class 906B
DBCartServiceImpl.class 902B
JDBCBaseDao.class 615B
ProductDao.class 583B
UserDao.class 503B
OrderDao.class 470B
CategoryDao.class 393B
CartService.class 272B
.classpath 1KB
book.css 29KB
book.css 25KB
unite_header20100419.css 20KB
second.css 19KB
comm_answer.css 19KB
register_login.css 14KB
book_head090107.css 13KB
login.css 12KB
list.css 10KB
shopping_vehicle.css 9KB
shopping_head.css 5KB
booksaleslist.css 5KB
page_bottom.css 3KB
dangdang.css 2KB
public_footer090310.css 2KB
public_footer.css 2KB
research.css 2KB
stylesheet.css 1KB
secBook_Show.css 1KB
navi.css 1KB
pubsug090107.css 555B
Thumbs.db 48KB
Thumbs.db 38KB
Thumbs.db 29KB
Thumbs.db 19KB
Thumbs.db 16KB
Thumbs.db 10KB
Thumbs.db 8KB
Thumbs.db 7KB
Thumbs.db 6KB
Thumbs.db 6KB
Thumbs.db 6KB
Thumbs.db 5KB
ancz081216_button05.gif 25KB
xssj_banner.gif 8KB
d_introduce.gif 5KB
ddnewhead_logo.gif 4KB
cheap4.gif 4KB
cheap3.gif 4KB
cheap2.gif 4KB
cheap1.gif 3KB
logo.gif 3KB
logo.gif 3KB
window_loading.gif 2KB
book_logo.gif 2KB
back_window.gif 2KB
title_bg.gif 2KB
pic_myshopping.gif 2KB
butt_balance.gif 2KB
ddb_1.gif 2KB
label3.gif 1KB
book_dangdang.gif 1KB
共 685 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
kansuny
- 粉丝: 2
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 建筑工程消防验收现场评定表.docx
- 交叉检查记录表(急救分中心).doc
- 交叉检查记录表(社区服务中心和乡镇卫生院).doc
- 居家适老化改造补贴实施细则产品功能表.docx
- 井田勘探探矿权出让收益评估报告( 模板).doc
- 髋关节功能丧失程度评定表.docx
- 买断式回购应急确认对话报价申请单.docx
- 每月质量安全调度会议纪要.docx
- 每月电梯安全调度会议纪要.docx
- 每周电梯质量安全排查报告.docx
- 每周电梯安全排查报告.docx
- 每月质量安全调度会议纪要表.docx
- 排水管网情况表.docx
- 聘请服务审批表(表格模板).docx
- 培训班次计划表.doc
- 密闭式输液表格、注意事项.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页