网上书店

 

网上书店系统

流程分析;

业务流程代码详解

持久化代码详解

tils包下的类

页面效果

数据库

 

一,流程分析;

1  登陆方式

网上购物系统要求用户一定要先登陆才能购买,登陆时有两中情况,一种是先登录才能浏览商品,另一种是可以先浏览商品,在购买前都可登陆 ,本列采用第一种方式,

2  浏览商品

   当用户成功登陆后,到商品展示页面,如果商品多时,可以提供分页供用户浏览和提供几种搜索的方式供用户查找想要的商品

3  选择商品

   当用户选择某种商品时,显示这中商品的详细信息

4  购买商品

   当用户选择购买这种商品时,把商品添加到购物车,显示这购物车中所有商品的详细信息清单,并计算出购物车中的所有商品的总价。

5  确认购买

   当用户确认购买时,需要显示用户注册的详细信息予以确认,如果信息需要修改,用户可修改后再提交确认信息,用户提交信息后,生成购物清单,持久化到数据库,将不能再更改。

 

 

二,业务流程代码详解

1,  用户登陆

用户登陆时,需要验证用户名和密码,

代码:略....

2,  浏览商品

查询商品,本例中,只显示所有商品信息的列表信息,

可以把商品信息查询出后放入session中,供页面获取显示。

代码: ....

3,  选择商品

用户选择某种商品时,可按该商品的id到数据库中查找,然后把该商品放入Session中,供页面显示和购买时调用。

代码:

request.getSession().setAttribute("books",this.getBookService().findBookAll());

 注: this.getBookService().findBookAll() 这段代码是查询所有的商品的信息

4,  购买商品

用户购买某个商品时,后台执行的流程如下:

/**创建一个session对象*/

       HttpSession session = request.getSession();

       /**创建一个购物订单的引用 */

       ShoppingCart cart = null;  

       /** 创建一个购物详细清单 */

       ShoppingCartItem cartItem = null;

       // session中获取图书列表 */

       List list = (List) session.getAttribute("bookdetail");

           //获取到列表中的第一本书

       Book book = (Book) list.iterator().next();

       //创建一张清单列表

       cartItem = new ShoppingCartItem();

       //把书放入清单列表

       cartItem.setBook(book);

        //判断一下session中是否有清单,如果没有说明是第一次购物,就给他创建一个购物车

       //如果session中已经有了清单,说明不是第一次购物了,就还让用户用他原来的的购物车

       if (session.getAttribute("items") == null) {

           cart = new ShoppingCart();

       } else {

           cart = (ShoppingCart) session.getAttribute("cart");

       }

       //现在有了购物车,就把购物清单加入到购物车

       cart.addItem(cartItem);  //此方法请参照下面的additem()方法

       //查询出当前购物车中的购物详细清单列表

       List items = cart.getItems();

       //把购物清单和购物车放入session

       session.setAttribute("items", items);

       session.setAttribute("cart", cart);

       //把总价计算出放入session

       session.setAttribute("total",new Double(cart.getTotalPrice()));

 

//-----------------------------------------------------------------------

//添加购物详细清单的方法

public void addItem(ShoppingCartItem newItem){

                                   //参间如下面findiltem();方法

       ShoppingCartItem cartItem = this.findItem(newItem.getBookId());

       if(cartItem != null){

           cartItem.setQuantity(cartItem.getQuantity()+newItem.getQuantity());

       }else{

           items.add(newItem);

       }

    }

//----------------------------------------------------------------------

//根据id查找详细清单

public ShoppingCartItem findItem(int itemId){

       ShoppingCartItem item = null;

       int num = items.size();

       for(int i = 0;i < num;i++){

           ShoppingCartItem cartItem = (ShoppingCartItem)items.get(i);

           if(itemId == cartItem.getBookId()){

              item = cartItem;

              break;

           }

       }

       return item;

    }

 

 

5,  确定购买

当用户点击了购买某中商品后,经过上一步代码处理,到我的购物车页面,在这个页面,显示当前选择的购物清单,并计算出总价,提供给用户可操作的有继续购物,删除一条详细清单,清空购物车,确认购买等操作

5.1  继续购物;当用户选择继续购物时,回到第2步,显示商品信息给用户操作

5.2  删除操作;当用户选择删除时,删除购物清单所对应的一条详细清单信息

5.3  清空购物车;但用户选择购物清单时,清空购物车;

     具体操作:先获取购物车,

ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");

cart.emptyCart();

//-------------------------------------

   //清空列表中的内容 items是一个List 的引用

    public void emptyCart(){

       items.clear();

    }

 

5.4 确认购买;当用户选择确认购买时,把用户的详细信息列出给用户确认,如果用户有需要修改的地方,用户可修改后再提交确认信息,这时,将生成购物订单持久到数据库,部分关键代码如下:

/**声明一个购物车*/

       ShoppingCart cart = null;

       //获取用户提交的个人信息

       String customerName = ordercheckForm.getCustomerName();

       String email = ordercheckForm.getEmail();

       String telephone = ordercheckForm.getTelephone();

       String post = ordercheckForm.getPost();

       String address = ordercheckForm.getAddress();

      

       String user = this.checkUser(request, response);

   

       if (user != null && user.length() > 3) {

           //sessiong中获取用户

           Customer cust = (Customer) request.getSession()

                  .getAttribute("user");

          

           //session中获取购物车

           cart = (ShoppingCart) session.getAttribute("cart");

           //创建一个订单对象

           Orders order = new Orders();

           //创建一个HashSet 对象

           HashSet set = new HashSet();

           //把购物的总价写如订单

           order.setTotalprice(new Double(cart.getTotalPrice()));

           //把用户id写入订单

           order.setCustId(cust.getCustomerId());

           //遍历购物车中的详细清单信息

           Iterator it = cart.getItems().iterator();

           while (it.hasNext()) {

              //获取用户购物详细清单

              ShoppingCartItem cartitem = (ShoppingCartItem) it.next();

              //创建一个订单明细表

              Orderitem orderitem = new Orderitem();

              //把购物详细清单中的书的id加入订单明细表

              orderitem.setBookid(new Integer(cartitem.getBookId()));

              //把购物详细清单中的书的quantity加入订单详细列表

              orderitem.setQuantity(new Integer(cartitem.getQuantity()));

              //把订单对象写入到订单详细列表对象中

              orderitem.setOrders(order);

              //把订单放入HashSet

              set.add(orderitem);

           }

           //形成订单列表

           order.setOrderItems(set);

           //把订单持久化到数据库,参见如下@1详解

           this.getOrderService().saveNewOrder(order);

           //user对象保存到session 中,保证他购物完后还能正常继续购物

           session.setAttribute("user", cust);

           //清空购物车

           cart.emptyCart();

@1详解:this.getOrderService().saveNewOrder(order);

在这行代码中,我们只看到保存了订单信息到数据库,而没有把订单明细信息添加到数据库,但执行完后我们会发现,数据库中订单明细表中也添加了所有的订单信息,这是怎么加进去的呢?这就要看我们的Hibernate的对象关系映射之间的关系了,在这里,订单表和订单明细表是一对多的关系。我们看订单明细表 订单表中的映射文件

订单明细表 OrderItems.hbm.xml

<many-to-one name="orders"

                class="com.ascent.bean.Orders"

              cascade="all"

 outer-join="false"

 update="false"

insert="false"

              column="order_id" not-null="true" />

 

订单表 Orders.hbm.xml

<set name="orderItems" table="orderitem" lazy="false"

           inverse="false" cascade="all" sort="unsorted">

           <key column="order_id" />

           <one-to-many class="com.ascent.bean.Orderitem" />

       </set>

 

 

 

 

     从这两个映射文件中我们可以看出,订单明细表和订单表之间是多对一双向关联关系,当保存订单信息时,hibernate会根据他们之间的映射关系,自动保存订单明细表的信息

BaseAction.java源代码代码

package com.ascent.struts.action;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionError;

import org.apache.struts.action.ActionErrors;

import com.ascent.bean.Customer;

import com.ascent.business.IBookService;

import com.ascent.business.ICustomerService;

import com.ascent.business.IOrderItemService;

import com.ascent.business.IOrderService;

import com.ascent.util.AppContext;

 

public class BaseAction extends Action {

   

    public BaseAction() {

       super();

    }

 

    protected IBookService getBookService() {

       return (IBookService) AppContext.getInstance().getAppContext().getBean(

              "bookService");

    }

 

    protected IOrderService getOrderService() {

       return (IOrderService) AppContext.getInstance().getAppContext()

              .getBean("orderService");

    }

 

    protected ICustomerService getCustomerService() {

       return (ICustomerService) AppContext.getInstance().getAppContext()

              .getBean("customerService");

    }

 

    protected IOrderItemService getOrderItemService() {

       return (IOrderItemService) AppContext.getInstance().getAppContext()

               .getBean("orderItemService");

    }

    /**

     * 这个方法判断用户是否登陆

     * @param request

     * @param response

     * @return

     */

    protected String checkUser(HttpServletRequest request,

           HttpServletResponse response) {

       Customer user = null;

       user = (Customer) request.getSession().getAttribute("user");

       if (user == null) {

           System.out.println("you have no loginning!!!!");

           ActionErrors errors = new ActionErrors();

           errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionError(

                  "errors.login"));

           this.saveErrors(request, errors);

           return null;

       } else {

           return user.getCustName();

       }

    }

}

 

 

三,持久化代码详解:

1,  BookHibernateDAO.java

package com.ascent.dao.hibernate;

import java.util.ArrayList;

import java.util.List;

import org.apache.log4j.LogManager;

import org.apache.log4j.Logger;

import org.springframework.orm.hibernate.support.HibernateDaoSupport;

import com.ascent.bean.Book;

import com.ascent.dao.IBookDAO;

 

public class BookHibernateDAO extends HibernateDaoSupport implements IBookDAO {

 

    private static final Logger LOGGER = LogManager.getLogger(BookHibernateDAO.class);

   

    private static final String LOAD_ALL = "from Book book order by book.bookId desc";

 

    private static final String LOAD_BY_AUTHOR = "from Book book where book.bookAuthor = ? order by book.bookId desc";

 

    private static final String LOAD_BY_NAME = "from Book book where book.bookName = ? order by book.bookId desc";

 

    public BookHibernateDAO() {

       super();

    }

    public Book saveBook(Book book) {

       try {

           this.getHibernateTemplate().saveOrUpdate(book);

           LOGGER.debug("保存书籍成功!");

           return book;

       } catch (Exception ex) {

           LOGGER.error("保存图书失败!",ex);

           ex.printStackTrace();

           return null;

       }

    }

    public Book getBook(Integer id) {

       LOGGER.debug("根据图书ID得到一个图书对象!");

       return (Book)this.getHibernateTemplate().get(Book.class,id);

    }

    public List findBookAll() {

       try{

           return this.getHibernateTemplate().find(LOAD_ALL);

       }catch(Exception ex){

           LOGGER.error("未能得到所有图书列表!",ex);

           ex.printStackTrace();

           return new ArrayList();

       }

    }

    public List findBookByAuthor(String author) {

       try{

           LOGGER.debug("按作者取得图书列表");

           return this.getHibernateTemplate().find(LOAD_BY_AUTHOR,author);

       }catch(Exception ex){

           LOGGER.error("未能按作者取得图书列表!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }  

    public List findBookByName(String name) {

       try{

           return this.getHibernateTemplate().find(LOAD_BY_NAME,name);

       }catch(Exception ex){

           LOGGER.error("未能按书名得到图书列表!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }

    public void removeBook(Book book) {

       LOGGER.debug("从数据库中删除指定图书");

       this.getHibernateTemplate().delete(book);

    }

}

 

2  CustomerHibernateDAO.java

package com.ascent.dao.hibernate;

 

import java.util.ArrayList;

import java.util.List;

 

import org.apache.log4j.LogManager;

import org.apache.log4j.Logger;

import org.springframework.orm.hibernate.support.HibernateDaoSupport;

 

import com.ascent.bean.Customer;

import com.ascent.dao.ICustomerDAO;

 

public class CustomerHibernateDAO

    extends HibernateDaoSupport

    implements ICustomerDAO {

   

    private static final Logger LOGGER = LogManager.getLogger(CustomerHibernateDAO.class);

   

    private static final String LOAD_ALL = "from Customer cust order by cust.customerId desc";

 

    private static final String LOAD_BY_NAME = "from Customer cust where cust.custName = ? order by cust.customerId desc";

    public CustomerHibernateDAO() {

       super();

    }

    public Customer saveCustomer(Customer customer){

       try{

           this.getHibernateTemplate().save(customer);

           LOGGER.debug("保存用户信息到数据库成功!");

           return customer;

       }catch(Exception ex){

           LOGGER.error("保存用户信息到数据库失败!");

           ex.printStackTrace();

           return null;

       }

    }

 

    public Customer getCustomer(Integer id){

       LOGGER.debug("根据用户ID得到用户信息!");

       return (Customer)this.getHibernateTemplate().get(Customer.class,id);

    }

    public List findCustomerAll(){

       try{

           LOGGER.debug("得到所有用户列表!");

           return this.getHibernateTemplate().find(LOAD_ALL);         

       }catch(Exception ex){

           LOGGER.error("获取所有用户列表失败!");

           return new ArrayList();

       }

    }

    public List findCustomerByName(String name){

       try{

           LOGGER.debug("根据用户姓名得到用户信息!");

           return this.getHibernateTemplate().find(LOAD_BY_NAME,name);

       }catch(Exception ex){

           LOGGER.error("根据用户姓名获取用户信息失败!");

           ex.printStackTrace();

           return null;

       }

    }

    public void removeCustomer(Customer customer){

       LOGGER.debug("从数据库中删除指定用户信息!");

       this.getHibernateTemplate().delete(customer);

    }

}

 

 

3   OrderHibernateDAO.java

package com.ascent.dao.hibernate;

import java.util.ArrayList;

import java.util.HashSet;

import java.util.Iterator;

import java.util.List;

 

import net.sf.hibernate.HibernateException;

import net.sf.hibernate.Session;

import net.sf.hibernate.Transaction;

 

import org.apache.log4j.LogManager;

import org.apache.log4j.Logger;

import org.springframework.orm.hibernate.support.HibernateDaoSupport;

 

import com.ascent.bean.Orders;

import com.ascent.bean.Orderitem;

import com.ascent.dao.IOrderDAO;

 

public class OrderHibernateDAO

   extends HibernateDaoSupport

   implements IOrderDAO{

   

    private static final Logger LOGGER = LogManager.getLogger(OrderHibernateDAO.class);

   

    private static final String LOAD_ALL = "from Order ord order by ord.orderId desc";

 

    private static final String LOAD_BY_CUST = "from Order ord where ore.CustId = ? order by ord.orderId desc";

 

    public OrderHibernateDAO() {

       super();

    }  

    public Orders saveOrder(Orders order){

 

       try{

            LOGGER.debug("保存订单信息到数据库!");

           this.getHibernateTemplate().save(order);

            Iterator it = order.getOrderItems().iterator();

            while(it.hasNext()){

            LOGGER.debug("保存订单明细项到数据库!");

            Orderitem item = (Orderitem)it.next();

            this.getHibernateTemplate().save(item);

            }

           

           return order;

       }catch(Exception ex){

           LOGGER.error("保存订单和订单明细失败!");

           ex.printStackTrace();

           return null;

       }

    }

 

    public Orders getOrder(Integer id){

       LOGGER.debug("根据订单ID取得订单对象!");

       return (Orders)this.getHibernateTemplate().get(Orders.class,id);

    }

 

    public List findOrderAll(){

       try{

           LOGGER.debug("获取所有订单信息列表!");

           return this.getHibernateTemplate().find(LOAD_ALL);

       }catch(Exception ex){

           LOGGER.error("获取所有订单信息列表失败!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }

 

    public List findOrderByCust(Integer custId){

       try{

           LOGGER.debug("根据用户ID获取用户相应的订单列表!");

           return this.getHibernateTemplate().find(LOAD_BY_CUST,custId);

       }catch(Exception ex){

           LOGGER.error("根据用户ID获取用户订单列表失败!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }

 

    public void removeOrder(Orders order){

       LOGGER.debug("从数据库中删除指定订单");

       this.getHibernateTemplate().delete(order);

    }

 

}

 

4  OrderItemHibernateDAO.java

package com.ascent.dao.hibernate;

import java.util.ArrayList;

import java.util.List;

import org.apache.log4j.LogManager;

import org.apache.log4j.Logger;

import org.springframework.orm.hibernate.support.HibernateDaoSupport;

import com.ascent.bean.Orderitem;

import com.ascent.dao.IOrderItemDAO;

public class OrderItemHibernateDAO

   extends HibernateDaoSupport

   implements IOrderItemDAO {

   

    private static final Logger LOGGER = LogManager.getLogger(OrderItemHibernateDAO.class);

   

    private static final String LOAD_ALL = "from Orderitem oi order by oi.orderitemID desc";

 

    private static final String LOAD_BY_BOOK = "from Orderitem oi where oi.bID = ? order by oi.orderitemID desc";

 

    public OrderItemHibernateDAO() {

       super();

       // TODO Auto-generated constructor stub

    }

   

    public Orderitem saveOrderitem(Orderitem orderitem){

       try{

           LOGGER.debug("保存订单明显项到数据库!");

           this.getHibernateTemplate().save(orderitem);

           return orderitem;

       }catch(Exception ex){

           LOGGER.error("保存订单明细项到数据库失败!");

           ex.printStackTrace();

           return null;

       }

    }

 

   

    public Orderitem getOrderitem(Integer id){

       LOGGER.debug("根据订单明显项ID获取该订单项信息!");

       return (Orderitem)this.getHibernateTemplate().get(Orderitem.class,id);

    }

 

    public List findOrderitemAll(){

       try{

           LOGGER.debug("获取所有订单明显项列表!");

           return this.getHibernateTemplate().find(LOAD_ALL);

       }catch(Exception ex){

           LOGGER.error("获取所有订单明明细项列表失败!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }

    public List findOrderitemByBook(Integer bookId){

       try{

           LOGGER.debug("根据书籍ID获取对应该书的所有订单明细项列表!");

           return this.getHibernateTemplate().find(LOAD_BY_BOOK,bookId);

       }catch(Exception ex){

           LOGGER.error("根据书籍ID获取对应该书的所有订单明细项列表失败!");

           ex.printStackTrace();

           return new ArrayList();

       }

    }

    public void removeOrderItem(Orderitem orderitem){

       LOGGER.debug("删除指定的订单明细项");

       this.getHibernateTemplate().delete(orderitem);

    }

 

}

 

四,utils包下的类

1  AppContext

package com.ascent.util;

import org.springframework.context.support.*;

public class AppContext {

    /**定义一个上下文环境的变量*/

  private static AppContext instance;

  private AbstractApplicationContext appContext;

 

  public synchronized static AppContext getInstance() {

    if (instance == null) {

      instance = new AppContext();

    }

    return instance;

  }

 

  private AppContext() {

    this.appContext = new ClassPathXmlApplicationContext(

        "applicationContext.xml");

  }

 

  public AbstractApplicationContext getAppContext() {

    return appContext;

  }

}

 

 

 

package com.ascent.util;

 

import java.util.LinkedList;

import java.util.List;

 

public class ShoppingCart {

   

    private List items = null;

      

    public ShoppingCart(){

       items = new LinkedList();

    }

   

    public List getItems(){

       return this.items;

    }

    /**

     * 添加购物清单

     * @param newItem

     */

    public void addItem(ShoppingCartItem newItem){

       ShoppingCartItem cartItem = this.findItem(newItem.getBookId());

       if(cartItem != null){

           cartItem.setQuantity(cartItem.getQuantity()+newItem.getQuantity());

       }else{

           items.add(newItem);

       }

    }

   

    public void removeItem(int itemId){

       System.out.print("======remove invoking !!");

       ShoppingCartItem item = findItem(itemId);

       if(item != null){

           System.out.println("==========prepeared remove");

           items.remove(item);

           System.out.println("==========item is removed");

       }else{

           System.out.println("=========item is not found");

       }

    }

   

    public void deleteItem(ShoppingCartItem newItem){

       items.remove(newItem);

    }

   

   

    public void emptyCart(){

       items.clear();

    }

    /**

     * 计算价格

     * @return

     */

    public double getTotalPrice(){

       double total = 0.0;

       int size = items.size();

       for(int i = 0;i< size;i++){

           total += ((ShoppingCartItem)items.get(i)).getBookPrice()*((ShoppingCartItem)items.get(i)).getQuantity();

       }

       return total;

    }

    /**

     * 根据 id 从购物详细清单中查找是否有这条清单

     * @param itemId 购物清单id

     * @return 购物清单

     */

    public ShoppingCartItem findItem(int itemId){

       ShoppingCartItem item = null;

       int num = items.size();

       for(int i = 0;i < num;i++){

           ShoppingCartItem cartItem = (ShoppingCartItem)items.get(i);

           if(itemId == cartItem.getBookId()){

              item = cartItem;

              break;

           }

       }

       return item;

    }

 

}

 

2  AppContext.java

package com.ascent.util;

 

import java.io.Serializable;

 

import com.ascent.bean.Book;

 

public class ShoppingCartItem implements Serializable {

    private Book book = null;

    private int quantity = 1;

   

    public void setBook(Book book){

       this.book = book;

    }

   

    public Book getBook(){

       return this.getBook();

    }

   

    public int getQuantity(){

       return this.quantity;

    }

   

    public void setQuantity(int quantity){

       this.quantity = quantity;

    }

   

    public int getBookId()

    {

        return this.book.getBookId().intValue();

    }

   

    public double getBookPrice(){

       return this.book.getBookPrice().doubleValue();

    }

   

    public String getBookName(){

       return this.book.getBookName();

    }

   

    public String getBookAuthor(){

       return this.book.getBookAuthor();

    }

 

}

 

 

五,页面效果

 

1 登陆页面

 

 

2显示信息页面,

商品详细信息页

 

3,我的购物车页

确认信息页

 

 

六,              数据库

 

1  表间关系

 

2,  数据库脚本

 

/*

SQLyog Enterprise - MySQL GUI v6.14

MySQL - 5.0.41-community-nt : Database - bookstoressh

*********************************************************************

*/

/*!40101 SET NAMES utf8 */;

 

/*!40101 SET SQL_MODE=''*/;

 

create database if not exists `bookstoressh`;

 

USE `bookstoressh`;

 

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

 

/*Table structure for table `book` */

 

DROP TABLE IF EXISTS `book`;

 

CREATE TABLE `book` (

  `book_name` varchar(100) NOT NULL default '',

  `book_id` int(11) NOT NULL auto_increment,

  `book_author` varchar(100) NOT NULL default '',

  `book_price` double NOT NULL default '0',

  `image` varchar(100) NOT NULL default '',

  `descibe` varchar(200) NOT NULL default '',

  PRIMARY KEY  (`book_id`)

) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

 

/*Data for the table `book` */

 

insert  into `book`(`book_name`,`book_id`,`book_author`,`book_price`,`image`,`descibe`) values ('corejava',1,'dfs',78,'image/10.gif','good,it is the success door to java'),('ejb',2,'zhangsan',99.9,'image/9.gif','enterprise java bean'),('jsp',4,'ccc',44,'image/7.gif','java server page'),('struts',9,'cbnm',44,'image/4.gif','java server page'),('spring',10,' qiuyn',22,'image/5.gif','java data base connection');

 

/*Table structure for table `customer` */

 

DROP TABLE IF EXISTS `customer`;

 

CREATE TABLE `customer` (

  `customer_id` int(11) NOT NULL auto_increment,

  `cust_name` varchar(100) NOT NULL default '',

  `password` varchar(100) NOT NULL default '',

  `email` varchar(100) NOT NULL default '',

  `phone` varchar(30) default NULL,

  `address` varchar(100) default NULL,

  `postcode` varchar(30) default NULL,

  PRIMARY KEY  (`customer_id`)

) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

 

/*Data for the table `customer` */

 

insert  into `customer`(`customer_id`,`cust_name`,`password`,`email`,`phone`,`address`,`postcode`) values (1,'luojs','luojs','luojs@123.com','123456789','beijing',''),(2,'feifei','feifei','feifie@fei.com','987654321','yunnankunming',NULL);

 

/*Table structure for table `orderitem` */

 

DROP TABLE IF EXISTS `orderitem`;

 

CREATE TABLE `orderitem` (

  `orderItem_id` int(11) NOT NULL auto_increment,

  `quantity` int(11) NOT NULL default '0',

  `order_id` int(11) NOT NULL default '0',

  `bookid` int(11) NOT NULL default '0',

  PRIMARY KEY  (`orderItem_id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

/*Data for the table `orderitem` */

 

/*Table structure for table `orders` */

 

DROP TABLE IF EXISTS `orders`;

 

CREATE TABLE `orders` (

  `order_id` int(11) NOT NULL auto_increment,

  `cust_id` int(11) NOT NULL default '0',

  `totalprice` double NOT NULL default '0',

  PRIMARY KEY  (`order_id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

/*Data for the table `orders` */

 

/*Table structure for table `tableid` */

 

DROP TABLE IF EXISTS `tableid`;

 

CREATE TABLE `tableid` (

  `id` int(11) NOT NULL default '0',

  `IDValue` int(11) NOT NULL default '0',

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

/*Data for the table `tableid` */

 

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值