重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
汗,你这个标题说的有点大啊,成千上万页代码就你这一个问题就能解决的吗。
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的新平网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
现在敲代码都是钱,你还想完整代码,还分页,有人回答你这个问题就真心不错了。
平时在线10k人大概是让你创建一个数据库连接池,大小设置10k。
下面是一个图书商城的数据库表部分,供你参考
set utf8
DROP TABLE IF EXISTS d_product;
CREATE TABLE d_product (//用来存放总商品,入图书种类
id int(12) NOT NULL auto_increment,
product_name varchar(100) NOT NULL,
description varchar(100) default NULL,
add_time bigint(20) default NULL,
fixed_price double NOT NULL,
dang_price double NOT NULL,
keywords varchar(200) default NULL,
has_deleted int(1) NOT NULL default '0',
product_pic varchar(200) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_product VALUES (23,'上课睡觉的故事','上课睡觉的故事',1237873000234,200,180,'key',0,'15.jpg');
DROP TABLE IF EXISTS d_book;
CREATE TABLE d_book (//用来存放图书的具体内容
id int(12) NOT NULL,
author varchar(200) NOT NULL,
publishing varchar(200) NOT NULL,
publish_time bigint(20) NOT NULL,
word_number varchar(15) default NULL,
which_edtion varchar(15) default NULL,
total_page varchar(15) default NULL,
print_time int(20) default NULL,
print_number varchar(15) default NULL,
isbn varchar(25) default NULL,
author_summary text NOT NULL,
catalogue text NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_book VALUES (24,'阿斗,'地球出版社',1237873000234,'1万','1','100',1,NULL,'12345678','无描述,'好书!');
DROP TABLE IF EXISTS d_category;
CREATE TABLE d_category (//商城图书目录
id int(12) NOT NULL auto_increment,
turn int(10) NOT NULL,
en_name varchar(200) NOT NULL,
name varchar(200) NOT NULL,
description varchar(200),
parent_id int(10),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_category VALUES (1,1,'Book','图书',NULL,0);
DROP TABLE IF EXISTS d_category_product;
CREATE TABLE d_category_product (//这个是连接目录和书籍具体信息的表
id int(12) NOT NULL auto_increment,
product_id int(10) NOT NULL,
cat_id int(10) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_category_product VALUES (72,24,1);
DROP TABLE IF EXISTS d_item;
CREATE TABLE d_item (//这个订单条目表
id int(12) NOT NULL auto_increment,
order_id int(10) NOT NULL,
product_id int(10) NOT NULL,
product_name varchar(100) NOT NULL,
dang_price double NOT NULL,
product_num int(10) NOT NULL,
amount double NOT NULL,
PRIMARY KEY (id)
)
DROP TABLE IF EXISTS d_order;
CREATE TABLE d_order (//订单表
id int(10) NOT NULL auto_increment,
user_id int(10) NOT NULL,
status int(10) NOT NULL,
order_time bigint(20) NOT NULL,
order_desc varchar(100) default NULL,
total_price double NOT NULL,
receive_name varchar(100) default NULL,
full_address varchar(200) default NULL,
postal_code varchar(8) default NULL,
mobile varchar(20) default NULL,
phone varchar(20) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS d_receive_address;
CREATE TABLE d_receive_address (//收件人信息表
id int(12) NOT NULL auto_increment,
user_id int(11) NOT NULL,
receive_name varchar(20) NOT NULL,
full_address varchar(200) NOT NULL,
postal_code varchar(8) NOT NULL,
mobile varchar(15) default NULL,
phone varchar(20) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
insert into d_receive_address values(1, 6,'Java','sun.cn','10000800','12345','67890');
insert into d_receive_address values(2, 6,'JavaJavaJava','ibm.cn','10000600','12345','67890');
DROP TABLE IF EXISTS d_user;
CREATE TABLE d_user (//用户表,用户信息
id int(12) NOT NULL auto_increment,
email varchar(50) NOT NULL,
nickname varchar(50) default NULL,
password varchar(50) NOT NULL,
user_integral int(12) NOT NULL default '0',
is_email_verify char(3),
email_verify_code varchar(50) default NULL,
last_login_time bigint default NULL,
last_login_ip varchar(15) default NULL,
PRIMARY KEY (id),
UNIQUE KEY email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
第一个不就是一对多吗? 我给你看看已订单号进行关联
订单号,订单日期,用户姓名,送货地址
1 2015/9/1 kill 北京
订单项id,订单号,商品名称,商品价格,商品数量)
123 1 泡面 10 100
223 1 纯净水 11 111
省,市,区,街道 订单号
1 1 1 1 1
2 2 2 2 1
strust2 (我没有用过不过我一般是这样做的)
直接用用后台进行校验
//订单对象模型
import java.util.List;
public class Order {
private String orderID;//订单号
private String createTime;//订单创建时间
private String customerName;//顾客姓名
private ListGood goods;//订单上的商品
//构造方法,对订单的订单号、订单创建时间和顾客姓名三个属性进行初始化
public Order(String orderID, String createTime, String customerName) {
super();
this.orderID = orderID;
this.createTime = createTime;
this.customerName = customerName;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public ListGood getGoods() {
return goods;
}
public void setGoods(ListGood goods) {
this.goods = goods;
}
public String getOrderID() {
return orderID;
}
public void setOrderID(String orderID) {
this.orderID = orderID;
}
//计算总金额
public int getAmount() {
int price2=0;
for(Good good4: goods){
int price = good4.getGoodPrice();
price2 =price+price2;
}
return price2;
}
}
//商品对象模型
package com.test;
public class Good {
private String goodID;//商品号
private String goodName;//商品名称
private Integer goodPrice;//商品单价
public Good(String goodID, String goodName, Integer goodPrice) {
super();
this.goodID = goodID;
this.goodName = goodName;
this.goodPrice = goodPrice;
}
public String getGoodID() {
return goodID;
}
public void setGoodID(String goodID) {
this.goodID = goodID;
}
public String getGoodName() {
return goodName;
}
public void setGoodName(String goodName) {
this.goodName = goodName;
}
public int getGoodPrice() {
if(goodPrice 0)
{
return goodPrice;
}else
{
//获取商品单价时如果数值为负数则声明抛出异常Exception
throw new IllegalArgumentException("商品价格小于0");
}
}
public void setGoodPrice(Integer goodPrice) {
this.goodPrice = goodPrice;
}
}
//main方法
public class TestOrder {
/**
* @param args
*/
public static void main(String[] args) {
ListGood goods =new ArrayListGood();
Good good1=new Good("aa","商品A",10);
Good good2=new Good("bb","商品B",15);
Good good3=new Good("bb","商品B",16);
goods.add(good1);
goods.add(good2);
goods.add(good3);
Order order1 = new Order("id","20140227","都叫兽");
order1.setGoods(goods);
//计算订单总额
System.out.println("");
System.out.println("订单号为:"+order1.getOrderID()+"的订单总额为:"+order1.getAmount());
System.out.println("");
}
}
import java.util.Scanner;
public class AddCustomer{
public static void main(String[] args){
System.out.printIn("MyShopping管理系统 客户信息管理 添加客户信息\n");
int custNo; //会员号
int birthday; //会员生日
int points = 0; //会员积分
Scanner input=new Scanner(System.in);
for(int i=0;i3;i++){ //循环录入会员信息
System.out.printIn("请输入会员号(4位整数):");
custNo = input.nextInt();
System.out.printIn("请输入会员生日(月\日用两位整数表示):");
custNo = input.next();
System.out.printIn("请输入会员积分:");
custNo = input.nextInt();
if(custNo1000||custNo9999){ //会员号无效则跳出
System.out.printIn("客户号"+custNo+"是无效会员号!");
System.out.printIn("录入信息失败\n");
contiune;
}
System.out.printIn("您录入的会员信息是:");
System.out.printIn(custNo+" "+birthday+" "+points+ "\n");
}
System.out.printIn("程序结束!");
}
}