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

📄 bookstoreservicejdbcimp.java

📁 servlet实现网上书店查询
💻 JAVA
字号:
package com.ghy.bookstore.service;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ghy.bookstore.book.dao.BookDao;
import com.ghy.bookstore.book.model.BookVO;
import com.ghy.bookstore.order.dao.OrderDao;
import com.ghy.bookstore.order.model.OrderItem;
import com.ghy.bookstore.order.model.OrderVO;
import com.ghy.bookstore.user.dao.UserDao;
import com.ghy.bookstore.user.model.UserVO;

public class BookStoreServiceJdbcImp implements BookStoreService {
	UserDao userdao;

	BookDao bookdao;

	OrderDao orderdao;

	public BookStoreServiceJdbcImp() {
		userdao = new UserDao();
		bookdao = new BookDao();
		orderdao = new OrderDao();

	}

	public boolean checkUserName(String name) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		// TODO Auto-generated method stub
		return this.userdao.checkUserName(name);
	}

	public void createUser(UserVO user) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		userdao.createUser(user);

	}

	public boolean login(UserVO user) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		return this.userdao.login(user);

	}

	public UserVO findUserByName(String name) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		return this.userdao.findUserByName(name);
	}

	public String findFirstCatId() throws IOException, InstantiationException,
			IllegalAccessException, ClassNotFoundException, SQLException {

		return this.bookdao.findFirstCatId();
	}

	public int getBookCount(int mode, String catId, String field, String key)
			throws IOException, InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {

		return this.bookdao.getBookCount(mode, catId, field, key);
	}

	public ArrayList findAllBookCat() throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {

		return this.bookdao.findAllBookCat();
	}

	public ArrayList<BookVO> findBookWithCat(int i, String catId, String key,
			String field) throws SQLException, IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException {
		return this.bookdao.findBookWithCat(i, catId, key, field);
	}

	public BookVO findBookByID(String id) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		return this.bookdao.findBookByID(id);
	}

	public OrderVO createOrderWithItems(OrderVO order, ArrayList list)
			throws IOException, InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		double totalprice = 0;
		if (list != null) {
			for (int i = 0; i < list.size(); i++) {
				OrderItem shopcart = (OrderItem) list.get(i);
				totalprice = totalprice + shopcart.getPrice()
						* shopcart.getMount();
			}

		}
		order.setTotal(totalprice);
		String orderid = this.orderdao.createOrder(order);
		order.setId(orderid);
		return order;
	}

	public void createOrderItem(OrderItem shopcart, String orderid)
			throws IOException, InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		this.orderdao.createOrderItem(shopcart, orderid);

	}

	public ArrayList searchOrderByUser(UserVO user) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		return this.orderdao.searchOrderByUser(user);
	}

	public void deleteOrder(String orderId) throws IOException,
			InstantiationException, IllegalAccessException,
			ClassNotFoundException, SQLException {
		this.orderdao.deleteOrder(orderId);

	}

	public ArrayList findAllBooks() throws IOException, InstantiationException,
			IllegalAccessException, ClassNotFoundException, SQLException {
		// TODO Auto-generated method stub
		return this.bookdao.findAllBooks();
	}

}

⌨️ 快捷键说明

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