翻出2018的Java84班的二阶段项目-商城项目

一个电子商城分析(疯购)

数据库:crazybuy;

1

商品类别

crazybuy_ product_ category

2

商品

crazybuy_ product

3

用户

crazybuy_ user

4

订单

crazybuy_ order

5

订单详情

crazybuy_ order_detail

6

评论

crazybuy_comment

7

广告、新闻

crazybuy_news

购物车:

表字段:提供给你的,分析字段。

DROP TABLE IF EXISTS crazybuy_product_category;

create table crazybuy_product_category(

       epc_id int primary key auto_increment,

       epc_name varchar(20) not null,

       epc_parent_id int,

       constraint fk_epc_parent_id foreign key (epc_parent_id) references crazybuy_product_category (epc_id)

);

 

DROP TABLE IF EXISTS crazybuy_product_category;

create table crazybuy_product_category(

       epc_id int primary key auto_increment,

       epc_name varchar(20) not null,

       epc_parent_id int,

       constraint fk_epc_parent_id foreign key (epc_parent_id) references crazybuy_product_category (epc_id)

);

 

insert into crazybuy_product_category values(-1,'ROOT',null);

insert into crazybuy_product_category values(null,'图书影像',-1);

insert into crazybuy_product_category values(null,'手机数码',-1);

insert into crazybuy_product_category values(null,'服饰/内衣',-1);

insert into crazybuy_product_category values(null,'珠宝/饰品',-1);

insert into crazybuy_product_category values(null,'小说',1);

insert into crazybuy_product_category values(null,'教材',1);

insert into crazybuy_product_category values(null,'其他书籍',1);

insert into crazybuy_product_category values(null,'音乐',1);

insert into crazybuy_product_category values(null,'手机',2);

insert into crazybuy_product_category values(null,'相机',2);

insert into crazybuy_product_category values(null,'数码配件',2);

insert into crazybuy_product_category values(null,'电脑',2);

insert into crazybuy_product_category values(null,'品牌女装',3);

insert into crazybuy_product_category values(null,'精品男装',3);

insert into crazybuy_product_category values(null,'内衣',3);

insert into crazybuy_product_category values(null,'时尚饰品',4);

insert into crazybuy_product_category values(null,'手表',4);

insert into crazybuy_product_category values(null,'太阳镜',4);

select * from crazybuy_product_category;

 

 

DROP TABLE IF EXISTS crazybuy_product;

create table crazybuy_product(

       ep_id  int primary key auto_increment,

       ep_name varchar(40) not null COMMENT '商品名称',

       ep_description varchar(200) COMMENT '商品描述',

       ep_price decimal(10,2) not null COMMENT '商品价格',

       ep_stock decimal(10,0) not null COMMENT '商品库存',

       ep_status decimal(6,0) default 1 COMMENT '商品状态,-1.禁用,1.普通,2.特价,3.热卖',

       epc_id int not null COMMENT '大类别 外键',

       epc_child_id int COMMENT '小类别 外键',

       ep_file_name varchar(200) not null COMMENT '图片',

       constraint fk_epc_id foreign key (epc_id) references crazybuy_product_category (epc_id),

       constraint fk_epc_child_id foreign key (epc_child_id) references crazybuy_product_category (epc_id)

);

 

insert into crazybuy_product values(null,'MIUI/小米 2A(MI2A)','小米 型号:2A(MI2A) 上市时间:2013年 13年上市月份:4月 网络类型:沃-联通',1547.00,990,2,2,9,'images/product/1.jpg');

insert into crazybuy_product values(null,'Samsung/三星 I9100G','I9100G 品牌:三星 上市时间:2011年 11年上市月份:12月 网络类型:沃-联通',1269.00,990,3,2,9,'images/product/3.jpg');

insert into crazybuy_product values(null,'Sony/索尼 LT26ii','LT26ii 品牌:索尼 上市时间:2012年 12年上市月份:8月 网络类型:沃-联通',1721.00,990,1,2,9,'images/product/4.jpg');

insert into crazybuy_product values(null,'Samsung/三星 I9100','i9100 galaxy s2 品牌:三星 上市时间:2011年 11年上市月份:7月',1684.00,990,1,2,9,'images/product/5.jpg');

insert into crazybuy_product values(null,'Huawei/华为 C8813D ','上市时间:2013年13年上市月份:2月',1028.00,990,1,2,9,'images/product/6.jpg');

insert into crazybuy_product values(null,'Samsung/三星 I9082','I9082 品牌:三星 上市时间:2012年 12年上市月份:12月 网络类型:沃-联通',889.00,990,2,2,9,'images/product/7.jpg');

insert into crazybuy_product values(null,'Sony/索尼 LT26w Xperia','LT26W 品牌:索尼 上市时间:2012年 12年上市月份:8月 网络类型:GSM/WCDMA',1769.00,990,1,2,9,'images/product/8.jpg');

insert into crazybuy_product values(null,'Sony Ericsson/索尼爱立信','LT18i/Xperia Arc S 品牌:索尼爱立信 上市时间:2011年 11年上市月份:8月',1317.00,990,1,2,9,'images/product/9.jpg');

insert into crazybuy_product values(null,'Lenovo/联想 S890','S890 品牌:联想 上市时间:2012年 12年上市月份:11月 网络类型:沃-联通',1049.00,990,1,2,9,'images/product/10.jpg');

insert into crazybuy_product values(null,'HTC T329D','品牌:HTC HTC型号:T329D 上市时间:2012年 12年上市月份:12月 网络类型:双模',1120.00,990,1,2,9,'images/product/11.jpg');

insert into crazybuy_product values(null,'LG F100','F100 品牌:LG 上市时间:2012年 12年上市月份:7月 网络类型:沃-联通 主屏尺',1091.00,990,1,2,9,'images/product/12.png');

insert into crazybuy_product values(null,'Huawei/华为 A199','A199 品牌:华为 上市时间:2013年 13年上市月份:4月 网络类型:双模',1838.00,990,3,2,9,'images/product/13.jpg');

insert into crazybuy_product values(null,'Motorola/摩托罗拉 XT788','xt788 品牌:摩托罗拉 上市时间:2012年 12年上市月份:10月 网络类型',1112.00,990,1,2,9,'images/product/14.jpg');

insert into crazybuy_product values(null,'Samsung/三星 Galaxy S 2 LTE HD','品牌:三星 上市时间:2011年 11年上市月份:11月',1498.00,990,1,2,9,'images/product/15.jpg');

insert into crazybuy_product values(null,'OPPO U705T','品牌:OPPO OPPO型号:U705T 上市时间:2012年 12年上市月份:12月 网络类型:G3',1498.00,990,1,2,9,'images/product/16.jpg');

insert into crazybuy_product values(null,'Coolpad/酷派 8730','品牌:酷派 上市时间:2013年 网络类型:G3-移动 主屏尺寸:5.0英寸',1432.00,990,3,2,9,'images/product/17.jpg');

insert into crazybuy_product values(null,'Sony/索尼 LT26I Xperia S','品牌:索尼 上市时间:2012年 12年上市月份:3月 网络类型:沃-联通',1906.00,990,1,2,9,'images/product/18.jpg');

insert into crazybuy_product values(null,'Motorola/摩托罗拉 XT910','XT910 品牌:摩托罗拉 上市时间:2011年 11年上市月份:11月 网络类型',1660.00,990,1,2,9,'images/product/19.jpg');

insert into crazybuy_product values(null,'LG LU6200 ','P930/Optimus LTE 品牌:LG 上市时间:2011年 11年上市月份:10月 网络类型',1229.00,990,1,2,9,'images/product/20.jpg');

 

 

-- 21 - 30(饰品)

insert into crazybuy_product values(null,'JPF 925纯银项链','吊坠短款锁骨首饰 韩版银饰品时尚',58.01,850,2,4,16,'images/product/21.jpg');

insert into crazybuy_product values(null,'艾念正品 925纯银手链','女士时尚韩版银首饰品,名师设计,超显气质、品味的项链',69.62,850,1,4,16,'images/product/22.jpg');

insert into crazybuy_product values(null,'银千惠925纯银手链 韩版时尚','心形首饰 生日礼物 可刻字',99.00,850,1,4,16,'images/product/23.jpg');

insert into crazybuy_product values(null,'乐天韩国进口饰品','雪纺玫瑰花蕾丝发饰头饰韩版韩式发绳发圈',31.00,850,3,4,16,'images/product/24.jpg');

insert into crazybuy_product values(null,'小天鹅水晶项链 ','女 短款 韩国 首饰 生日礼物',58.01,850,2,4,16,'images/product/25.jpg');

insert into crazybuy_product values(null,'茗琳正品采用施华洛世奇水晶项链','女短款锁骨 韩版 时尚 韩国饰品',3109.01,850,1,4,16,'images/product/26.jpg');

insert into crazybuy_product values(null,'伊泰莲娜饰品批发','日韩 可爱 甜美 光板镜面爱心 项链 送女友',15.50,850,1,4,16,'images/product/27.jpg');

insert into crazybuy_product values(null,'欧美不规则几何装饰项链锁骨链','韩国衣服配饰短款女时尚颈链饰品',19.90,850,1,4,16,'images/product/28.jpg');

insert into crazybuy_product values(null,'饰品可爱满钻五角星无耳洞耳环','饰品',14.09,850,1,4,16,'images/product/29.jpg');

insert into crazybuy_product values(null,'珍珠软链韩式短发新娘头饰套装','结婚额饰品配婚纱',39.00,850,1,4,16,'images/product/30.jpg');

-- 31 - 40(精品男装)

insert into crazybuy_product values(null,'2件79包邮 凡兔男士短袖t恤','由于这款T恤采用的是吊染工艺,所以建议亲在洗涤过程中请用冷水洗涤,请勿用温水,或者彩漂洗涤!',55.00,750,1,3,14,'images/product/31.jpg');

insert into crazybuy_product values(null,'爱立登中老年男装短袖T恤衫','高端的设计,完美的穿着效果,充分展现中老年男性的魅力!夏天单穿,秋冬打底穿,一年四季都可穿着,商务百搭,100%实拍,保证您收到货比照片更好!',49.00,750,1,3,14,'images/product/32.jpg');

insert into crazybuy_product values(null,'梦特娇2013新款男装短袖T恤','锦标,常规袖丝含量95%以上',216.00,750,1,3,14,'images/product/33.jpg');

insert into crazybuy_product values(null,'2013夏装新款 韩国无头人图案男装','此款T恤布料采用高档棉加莱卡的组合是夏季T恤首选,加入莱卡后的棉固色和耐洗涤性都增强了不少,不变形,不褪色,不透,不缩水。',39.00,750,1,3,14,'images/product/34.jpg');

insert into crazybuy_product values(null,'男夏装潮男韩版修身男士短袖t恤','独特的撞色大V领,拥有永不落伍的时尚气场,展现出个性的潮流魅力。',55.30,750,2,3,14,'images/product/35.jpg');

insert into crazybuy_product values(null,'雁翎金甲中国风短袖T恤男士半袖','吊染,常规袖,棉质,凸显中国文化。',59.00,750,1,3,14,'images/product/36.jpg');

insert into crazybuy_product values(null,'jerryjack男装2013新款夏装半袖','天然纤维拥有良好的透气性和吸湿性,好比一件会呼吸的衣服',48.00,750,2,3,14,'images/product/37.jpg');

insert into crazybuy_product values(null,'韩黛薇 短袖t恤男韩版潮男装','采用双车缝制走线,平整车工紧密细致,牢固不变,整齐简洁',49.00,750,1,3,14,'images/product/38.jpg');

insert into crazybuy_product values(null,'夏装英伦兰博基尼纯棉男士短袖','穿在身上就仿佛是在午后,靠在藤椅,任阳光洋洋散散的打在身上。',58.00,750,1,3,14,'images/product/39.jpg');

insert into crazybuy_product values(null,'新款休闲夏装男短袖男士立领T恤','压花,劲拼,纯色,宽松型,含棉量50%-69%青少年地 最佳选择。',30.00,750,1,3,14,'images/product/40.jpg');

-- 41 - 60(图书)

insert into crazybuy_product values(null,'畅销读物小小孩影院早教书','采用最尖端的印刷工艺和材料,导致我们的产品成本比其他品牌更高!网上还有一些便宜劣质童书,那些和我们是完全没有可比性的!',33.80,970,1,1,7,'images/product/41.jpg');

insert into crazybuy_product values(null,'水木乐','幼儿学习看图书 宝宝最爱早教卡书0-3岁婴儿早教认知卡片早教卡早教书认知卡片8本包邮',3.50,970,1,1,7,'images/product/42.jpg');

insert into crazybuy_product values(null,'宝贝晚安故事','包邮儿童书籍故事书早教童话图书儿童正版宝宝早教书籍睡前故事',25.80,970,1,1,7,'images/product/43.jpg');

insert into crazybuy_product values(null,'365夜','儿童故事书 宝宝睡前故事书 幼儿图书0-3岁 童话故事书 早教书 ',39.80,970,1,1,7,'images/product/44.jpg');

insert into crazybuy_product values(null,'3D立体书','早教 立体书 0-3-6岁婴幼儿宝宝书籍儿童故事书睡前图书4册包邮',35.00,970,1,1,7,'images/product/45.jpg');

insert into crazybuy_product values(null,'左右脑','易读宝 点读笔 有声图书 左右脑开发 2、3.4.5.6.7岁单本价5.8折',12.00,970,1,1,7,'images/product/46.jpg');

insert into crazybuy_product values(null,'动物','满百包邮 0-3岁宝宝撕不烂 启蒙认知卡片 儿童图书籍 yp091 16册',1.00,970,0,1,7,'images/product/47.jpg');

insert into crazybuy_product values(null,'我3岁了','小红花幼儿潜能开发我3-4-5-6岁了 儿童宝宝早教书籍 智力图书',8.80,970,1,1,7,'images/product/48.jpg');

insert into crazybuy_product values(null,'人物','包邮 0-3岁宝宝看图识字 启蒙认知 婴儿幼儿童图书籍 早教书卡片',38.00,970,3,1,7,'images/product/49.jpg');

insert into crazybuy_product values(null,'狼来了','小小孩 经典故事① 2-3-4-5-6岁儿童幼儿宝宝早教睡前故事图书籍',9.00,970,1,1,7,'images/product/50.jpg');

insert into crazybuy_product values(null,'我不给你','包邮0-3-6岁婴幼儿童话故事图书小狐狸绘本我家宝贝第1套情商管理',45.00,970,1,1,7,'images/product/51.jpg');

insert into crazybuy_product values(null,'翻一番,变一变','小红花0-1-2-3岁宝宝图书认知翻翻书 翻一翻变一变婴幼儿童书籍',6.50,970,1,1,7,'images/product/52.jpg');

insert into crazybuy_product values(null,'看图找不同','快易典有声图书《看图找不同》幼儿早教有声书点读书',40.00,970,1,1,7,'images/product/53.jpg');

insert into crazybuy_product values(null,'我喜欢书','我喜欢书 幼儿园童小学生绘本经典批发宝宝读物图书012345-67岁',3.50,970,1,1,7,'images/product/54.jpg');

insert into crazybuy_product values(null,'启蒙大卡','启蒙大卡 撕不烂早教书 0-1岁婴儿图书 宝宝认知书籍正版礼盒装',45.00,970,1,1,7,'images/product/55.jpg');

insert into crazybuy_product values(null,'恐龙','儿童小百科_恐龙图书_幼儿书籍畅销童书儿童百科全书 特价图书',27.00,970,3,1,7,'images/product/56.jpg');

insert into crazybuy_product values(null,'安全','小婴孩童书 儿童图书幼儿大开眼界百科绘本 宝宝安全教育书读本',4.00,970,1,1,7,'images/product/57.jpg');

insert into crazybuy_product values(null,'十万个为什么','满4本包邮婴幼儿童十万个为什么全套注音版畅销百科全书图书3-6岁',6.95,970,1,1,7,'images/product/58.jpg');

insert into crazybuy_product values(null,'幼儿唐诗','幼儿唐诗 宝宝早教图书 婴儿早教具 宝宝认知卡片 宝宝书',3.00,970,1,1,7,'images/product/59.jpg');

insert into crazybuy_product values(null,'汉语拼音','亲子启蒙书 早教翻翻书 认知卡 识字卡 幼儿图书 早教书 汉语拼音',3.80,970,1,1,7,'images/product/60.jpg');

-- 70 - 92(品牌女装)

insert into crazybuy_product values(null,'贝蒂艾维2013夏季女装新品韩版大码打底衫','这是一款能创造奇迹的宝贝!!!每5个女人看到它,就会有1位带它回家!!!因为它超级漂亮,还超级显瘦!因为它超级正品,还超级便宜!每个女人都爱它!!!',49.90,1000,1,3,13,'images/product/71.jpg');

insert into crazybuy_product values(null,'2013夏季 新款韩版女装假两件拼色宽松大码','雅依梦品牌最新力作!韩国2013最新人气连衣裙韩国进口版型+大牌质量=平民价格!活动期内36.8元包邮!订单量大按付款顺序排单发货!早付款早发货!你懂的!仅亏活动期!活动后恢复原价78元',36.80,1000,1,3,13,'images/product/72.jpg');

insert into crazybuy_product values(null,'夏季女装新款韩版修身蕾丝雪纺连衣裙','热卖30000件,我们一直被别人模仿,但从未被超越过,仿版横行,请认准依然纯正品购买。正品保护,实拍已经通过云图片认证,并保护中,请勿盗图',99.00,1000,1,3,13,'images/product/73.jpg');

insert into crazybuy_product values(null,'女士t恤短袖2013初夏装新款上衣半袖衣服','女士t恤短袖2013初夏装新款上衣半袖衣服韩版纯棉女装修身白色t桖,闪耀亮片 夏装纯棉短袖女T恤',74.00,1000,1,3,13,'images/product/74.jpg');

insert into crazybuy_product values(null,'半袖女装新款夏装韩版初夏宽松短袖','掌柜“疯”了,只为冲量和人气,第一批3000件已抢光,第二批限量2000件,三天抢光,现最后一批亏本500件,卖完立刻涨价,数量有限,最后一批快抢完了,亲们抓紧时间抢购!',30.00,1000,1,3,13,'images/product/75.jpg');

insert into crazybuy_product values(null,'2013夏季新款牛奶丝印花短袖V领连衣裙','每个ID限购3件,超出一件加5元邮费,以此类推,亏本冲销量,喜欢还价的亲们请绕道,见谅!',49.00,1000,1,3,13,'images/product/76.jpg');

insert into crazybuy_product values(null,'春款夏装短袖新款雪纺袖公主连衣裙','包邮!2013春款夏装短袖新款雪纺袖公主连衣裙雪纺女装打底裙L935,一件包邮!只限申通快递!',129.00,1000,1,3,13,'images/product/77.jpg');

insert into crazybuy_product values(null,'撞糖果色休闲裤超短裤女裤子夏季韩版','2013夏装新款女装 撞糖果色休闲裤超短裤女裤子夏季韩版热裤裙裤',58.00,1000,1,3,13,'images/product/78.jpg');

insert into crazybuy_product values(null,'新款夏装新品女式韩版修身上衣显瘦','注意:价格都只是目前暂时的,后面由于要考虑推广成本等,会陆续随机性涨价,所以要买要提前。另外大的码数,特别是2XL及以上的码数用料成本是XL以下码数的2倍还不止,所以是有2个价格,还请大码客户体谅 ',44.90,1000,3,3,13,'images/product/79.jpg');

insert into crazybuy_product values(null,'2013春款女装韩版夏季新款t恤','销量猛增,为了更高效的发货,本店默认圆通,申通快递,请亲们留言备注快递,备注快递者优先发货!Bling女孩,店庆冲2皇冠',29.00,1000,2,3,13,'images/product/80.jpg');

insert into crazybuy_product values(null,'包邮女装2013夏装新款 短袖T恤','季大促推广期,虽然亏本出售,但依然为亲们提供7天无理由退换服务,更低销售价格,更高的服务水准,让亲买更放心。',30.00,1000,1,3,13,'images/product/81.jpg');

insert into crazybuy_product values(null,'2013夏装卡通打底衫韩版时尚宽松t恤','T恤系列均为均码为正常码M左右,根据图片上效果的修身和宽松不同的款式分别适合155-165身高,80-120体重的MM穿着 ',19.00,1000,3,3,13,'images/product/82.jpg');

insert into crazybuy_product values(null,'2013夏装新款韩版女装V领修身上衣','简洁大方款式,是经典不败的时尚理念。中长款松紧收腰设计,完美打造黄金身材比例,蕾丝飞飞袖,优雅点缀,和夏风谈一场永不说再见的恋爱。',89.00,1000,2,3,13,'images/product/83.jpg');

insert into crazybuy_product values(null,'2013夏季新款韩版修身女t恤','原价60元,吐血价9.9元3件包邮,限量秒杀5万件!现在随便发个快递都十几元,本款衣服只售价9.9元5万件卖完恢复29.9元不包邮,欲购从速!抓住机会我们用事实说话',9.90,1000,1,3,13,'images/product/84.jpg');

insert into crazybuy_product values(null,'2013夏季碎花吊带裙圆点连衣裙夏','马上购买,即送限量版,价值29.9元店铺全年包邮卡(非实物卡)!',39.00,1000,3,3,13,'images/product/85.jpg');

insert into crazybuy_product values(null,'夏款女装修身雪纺裙子连衣裙','数量有限、心动还需行动,按照亲们的付款顺序发货,涨价在即先拍先发货,限时再打折只需29.8元,送模特身上原装腰带还包邮!另送神秘小礼物····',29.80,1000,2,3,13,'images/product/86.jpg');

insert into crazybuy_product values(null,'韩版女装时尚半袖修身款无袖女款T恤 ','喜欢的MM先收藏好下宝贝,过期不候!原价:78元,今日抢拍价:28元,还包邮',28.00,1000,1,3,13,'images/product/87.jpg');

insert into crazybuy_product values(null,'新款连衣裙女吊带工字背心长裙背心裙','这款连衣裙采用的是莫代尔的面料,(*^__^*) 嘻嘻……给力吧,买了绝不后悔,不买才会后悔噢!亲们,注意了。别家110CM的都要卖到45元哦。',19.90,1000,3,3,13,'images/product/88.jpg');

insert into crazybuy_product values(null,'上衣打底衫女装韩版t恤雪纺衫短袖','朋友休闲聚会 婚宴 派对等,让你格外抢眼 压倒群芳!!同样也是女人衣橱里值得收藏的一件,质量有保证,超美的限量版··珍藏版·人手必备··',39.50,1000,3,3,13,'images/product/89.jpg');

insert into crazybuy_product values(null,'2013夏季新款韩版女装包臀短袖T恤 ','2013夏季新款韩版女装胖MM大码蝙蝠袖宽松休闲中长款包臀短袖T恤',33.00,1000,1,3,13,'images/product/90.jpg');

-- 90 - 92(太阳镜)

insert into crazybuy_product values(null,'威派男士太阳镜男','威派A690男士偏光太阳镜墨镜偏光男士铝美镜腿司机镜,新店开业,3折大促,此款现在仅45元秒杀,涨价是必然的,请亲尽早下手,涨价了可不再少价了的哦',45.00,800,2,4,18,'images/product/91.jpg');

insert into crazybuy_product values(null,'街拍欧美复古大圆形太阳眼镜女墨镜','2013年度亏本促销,市场价在:60-180元左右,包邮并配送:1、眼镜袋 2、眼镜布,亏本价 亏本赚吆喝!请勿再议价,谢谢您的理解!!',21.90,800,3,4,18,'images/product/92.jpg');

 

select * from crazybuy_product

DROP TABLE IF EXISTS crazybuy_user;

create table crazybuy_user(

       eu_user_name varchar(20) primary key COMMENT '用户名',

       eu_password varchar(20) not null COMMENT '密码',

       eu_actual_name varchar(20) not null COMMENT '真实姓名',

       eu_sex char(2) default '男' not null COMMENT '性别',

       eu_email varchar(20) not null COMMENT '电子邮件',

       eu_mobile varchar(11) not null COMMENT '电话',

       eu_address varchar(200) not null COMMENT '地址',

       eu_photo_url varchar(100) COMMENT '头像',

       eu_status decimal(6,0) default 1 COMMENT '1为普通用户,2为管理员'

);

 

-- table crazybuy_user

insert into crazybuy_user values('admin','admin','李明','男','admin@163.com','15939923063','河南郑州金水区','',2);

insert into crazybuy_user values('zs12345','zs12345','张三','男','zhangsan@163.com','15938750383','河南郑州金水区','',1);

insert into crazybuy_user values('lucy','lucy12345','路西','女','lucy111@163.com','13523451532','北京朝阳区','',1);

insert into crazybuy_user values('tom','tom12345','汤姆','男','tom111@163.com','15138006548','河南郑州二七区','',1);

insert into crazybuy_user values('jack','jack12345','杰克','男','jack111@163.com','15939980758','上海市丰庆路','',1);

select * from crazybuy_user;

 

 

--create table crazybuy_order(订单表)

DROP TABLE IF EXISTS crazybuy_order;

create table crazybuy_order(

       eo_id int primary key auto_increment,

       eo_user_name varchar(20) not null,

       eo_user_address varchar(200) not null,

       eo_create_time datetime not null,

       eo_status decimal(6,0) not null  COMMENT '1下单,2审核通过,3配货,4送货中,5收货并确认',

       eo_type decimal(6,0) not null   COMMENT '1货到付款,2网上支付',

       constraint fk_eo_user_name foreign key (eo_user_name) references crazybuy_user (eu_user_name)

);

-- create table crazybuy_order_detail(订单详情表)

DROP TABLE IF EXISTS crazybuy_order_detail;

create table crazybuy_order_detail(

       eod_id int primary key auto_increment,

       eo_id int not null COMMENT '订单id',

       ep_id int not null COMMENT '商品id',

       eod_decimal decimal(6,0) not null COMMENT '数量',

       constraint fk_eo_id foreign key (eo_id) references crazybuy_order (eo_id),

           constraint fk_ep_id foreign key (ep_id) references crazybuy_product (ep_id)

);

-- create table crazybuy_news(新闻表)

DROP TABLE IF EXISTS crazybuy_news;

create table crazybuy_news(

       en_id int primary key auto_increment,

       en_title varchar(40) unique not null COMMENT '标题',

       en_content varchar(1000) not null COMMENT '内容',

       en_create_time datetime default now() COMMENT '创建时间'

);

--create table crazybuy_comment(留言表)

DROP TABLE IF EXISTS crazybuy_comment;

create table crazybuy_comment(

       ec_id int primary key auto_increment,

       ec_reply varchar(200)  COMMENT '回复',

       ec_content varchar(200) not null  COMMENT '回复内容',

       ec_create_time datetime not null  COMMENT '创建时间',

       ec_reply_time datetime  COMMENT '回复时间',

       ec_user_name varchar(20) not null  COMMENT '用户名',

       constraint fk_ec_user_name foreign key (ec_user_name) references crazybuy_user (eu_user_name)

);

 

 

 

表与表之间的关联关系

 

前期准备工作:搭建后台

 

  1. 建实体(表与实体的对应)

1.1表名:crazybuy_ product_ category

实体名:ProductCategory

字段---属性命名:

1.2表名:crazybuy_ product

实体名:Product

1.3表名:crazybuy_ user

实体名:User

1.4表名:crazybuy_ order

实体名:Order

1.5表名:crazybuy_ order_detail

实体名:OrderDetail

1.6表名:crazybuy_comment

实体名:Comment

1.7表名:crazybuy_news

实体名:News

  1. 写DbUtil
  2. 写Dao

UserDao

   用户登陆  返回类型User  方法名login 参数(用户名,密码)

ProductDao

      查询所有  List<Product>  findAllProduct

  1. 通过商品状态获取部分商品

public List<Product> getProductsByStatus(int status, int number)

  1. 通过类别获取商品,并限制数据范围

public List<Product> getProductsByCategory(int id, int level, int pageSize, int pageIndex)

  1. 获取指定商品类别ID的商品数量

public int getCountByCategory(int id, int level)

  1. 获取可以显示的总页数

public int getTotalPages(int count, int pageSize)

  1. 通过ID获取商品信息

public Product getProductById(int id)

  1. 通过ID删除商品

public int deleteById(int id, int columnType)

  1. 添加一条商品

public int insert(Product product)

  1. 更新一条商品

public int update(Product product)

  1. 禁用一个商品

public int setDisable(int id)

  1. 写Dao的实现类
  2. 写测试类

项目结构

各个接口中的方法

UserDao

package com.crazybuy.dao;

 

import java.util.List;

 

import com.crazybuy.entity.User;

 

/**

 * 用户数据访问层接口

 *

 * @author 汤Emily

 * @version 2017-4-16

 */

public interface UserDao {

         /**

          * 登陆

          *

          * @param user

          *            用户对象

          * @return 用户对象

          */

         public User login(User user) throws Exception;

 

         /**

          * 查找用户

          *

          * @param user

          *            用户

          * @return 用户集合对,为null则表示未找到

          */

         public List<User> findUser(User user) throws Exception;

 

         /**

          * 添加用户

          *

          * @param user

          *            用户对象

          * @return 受影响的行数

          */

         public int insert(User user) throws Exception;

 

         /**

          * 验证用户名是否存在

          *

          * @param userName

          *            用户名

          * @return

          */

         public boolean checkUserNameIsExist(String userName) throws Exception;

 

         /**

          * 获取所有用户

          *

          * @return 用户集合

          */

         public List<User> getUsers() throws Exception;

 

         /**

          * 通过用户名获取用户信息

          *

          * @param userName

          *            用户名

          * @return 用户对象

          */

         public User getUserByUserName(String userName) throws Exception;

 

         /**

          * 更新用户信息

          *

          * @param user

          *            用户对象

          * @return true成功 false失败

          */

         public boolean update(User user) throws Exception;

 

         /**

          * 删除一个用户

          *

          * @param userName

          *            用户名

          * @return true成功 false失败

          */

         public boolean delete(String userName) throws Exception;

}

 

ProductCategoryDao

package com.crazybuy.dao;

 

import java.util.List;

 

import com.crazybuy.entity.ProductCategory;

 

/**

 * 商品类别数据访问层接口

 *

 * @author 汤Emily

 * @version 2017-4-16

 */

public interface ProductCategoryDao {

         /**

          * 获取所有商品类别

          *

          * @return 商品类别集合

          */

         public List<ProductCategory> getAll() throws Exception;

 

         /**

          * 通过ID获取一个类别

          *

          * @param id

          *            编号

          * @return 商品类别对象

          */

         public ProductCategory getProductCategoryById(int id) throws Exception;

 

         /**

          * 添加商品类别

          *

          * @param pc

          *            商品类别对象

          * @return true成功 false失败

          */

         public boolean insert(ProductCategory pc) throws Exception;

 

         /**

          * 更新商品类别

          *

          * @param pc

          *            商品类别对象

          * @return true成功 false失败

          */

         public boolean update(ProductCategory pc) throws Exception;

 

         /**

          * 通过ID删除商品类别

          *

          * @param id

          *            编号

          * @return true成功 false失败

          */

         public boolean deleteById(int id) throws Exception;

 

         /**

          * 通过父分类ID删除商品类别

          *

          * @param id

          *            父分类编号

          * @return true成功 false失败

          */

         public boolean deleteByParentId(int id) throws Exception;

}

 

ProductDao

package com.crazybuy.dao;

 

import java.util.List;

 

import com.crazybuy.entity.Product;

 

/**

 * 商品数据访问层接口

 *

 * @author 汤Emily

 * @version 2017-4-16

 */

public interface ProductDao {

         /**

          * 通过商品状态获取部分商品

          *

          * @param Status

          *            商品状态

          * @param number

          *            商品条数

          * @return 商品集合

          */

         public List<Product> getProductsByStatus(int status, int number)

                            throws Exception;

 

         /**

          * 通过类别获取商品,并限制数据范围

          *

          * @param id

          *            商品类别ID

          * @param level

          *            类别级别 * 1.类别级别 id不是-1,level不是-1,查大类 2.level为2就查子类数量

          *            3.id=-1,level为-1(代表根) ep_status状态没禁用 查所有的商品

          * @param pageSize

          *            每页显示数量

          * @param pageIndex

          *            页码

          * @return 商品集合

          */

         public List<Product> getProductsByCategory(int id, int level, int pageSize,

                            int pageIndex) throws Exception;

 

         /**

          * 获取指定商品类别ID的商品数量,level就是控制调哪一条 sql语

          *

          * @param id

          *            商品类别ID

          * @param level

          *            类别级别 * 1.类别级别 id不是-1,level不是-1,查大类 2.level为2就查子类数量

          *            3.id=-1,level为-1(代表根) ep_status状态没禁用 查所有的商品

          * @return 商品数量

          */

         public int getCountByCategory(int id, int level) throws Exception;

 

         /**

          * 获取可以显示的总页数

          *

          * @param count

          *            商品数量

          * @param pageSize

          *            每页显示数量

          * @return 总页数 10条数据,每页显示3条,求多少页4 10%3==0?10/3 : 10/3+1

          */

         public int getTotalPages(int count, int pageSize) throws Exception;

 

         /**

          * 通过ID获取商品信息

          *

          * @param id

          *            商品ID

          * @return 商品对象

          */

         public Product getProductById(int id) throws Exception;

 

         /**

          * 通过ID删除商品

          *

          * @param id

          *            编号

          * @param columnType

          *            列类型。 1:商品ID 2:分类ID 3:子分类ID

          * @return true成功 false失败

          */

         public boolean deleteById(int id, int columnType) throws Exception;

 

         /**

          * 添加一条商品

          *

          * @param product

          *            商品对象

          * @return true成功 false失败

          */

         public boolean insert(Product product) throws Exception;

 

         /**

          * 更新一条商品

          *

          * @param product

          *            商品对象

          * @return true成功 false失败

          */

         public boolean update(Product product) throws Exception;

 

         /**

          * 禁用一个商品

          *

          * @param id

          *            商品ID

          * @return true成功 false失败

          */

         public boolean setDisable(int id) throws Exception;

}

上面三个dao要求当天完成。

三个dao接口实现类中sql语句参考:

UserDaoImpl

package com.crazybuy.dao.impl;

 

import java.util.List;

 

import com.crazybuy.dao.UserDao;

import com.crazybuy.entity.User;

 

public class UserDaoImpl implements UserDao {

 

         @Override

         public boolean checkUserNameIsExist(String userName) throws Exception {

                   String sql = "select 1 from easybuy_user where eu_user_name=?";

                   return false;

         }

 

         @Override

         public boolean delete(String userName) throws Exception {

                   String sql = "delete from easybuy_user where eu_user_name = ?";

                   return false;

         }

 

         @Override

         public List<User> findUser(User user) throws Exception {

                   String sql = "select * from easybuy_user where eu_user_name=? and eu_password=?";

                   return null;

         }

 

         @Override

         public User getUserByUserName(String userName) throws Exception {

                   String sql = "select * from easybuy_user where eu_user_name = ?";

                   return null;

         }

 

         @Override

         public List<User> getUsers() throws Exception {

                   String sql = "select * from easybuy_user";

                   return null;

         }

 

         @Override

         public int insert(User user) throws Exception {

                   String sql = "insert into easybuy_user values(?,?,?,?,?,?,?,?,default)";

                   return 0;

         }

 

         @Override

         public User login(User user) throws Exception {

                   String sql = "select * from easybuy_user where eu_user_name=? and eu_password=?";

                   return null;

         }

 

         @Override

         public boolean update(User user) throws Exception {

                   String sql = "update easybuy_user set eu_password=?,eu_actual_name=?,eu_sex=?,eu_email=?,eu_mobile=?,eu_address=? where eu_user_name=?";

                   return false;

         }

 

}

ProductCategoryDaoImpl

package com.crazybuy.dao.impl;

 

import java.util.List;

 

import com.crazybuy.entity.ProductCategory;

 

public class ProductCategoryDaoImpl implements

                   com.crazybuy.dao.ProductCategoryDao {

 

         @Override

         public boolean deleteById(int id) throws Exception {

                   String sql = "delete from easybuy_product_category where epc_id = ?";

                   return false;

         }

 

         @Override

         public boolean deleteByParentId(int id) throws Exception {

                   String sql = "delete from easybuy_product_category where epc_parent_id = ?";

                   return false;

         }

 

         @Override

         public List<ProductCategory> getAll() throws Exception {

                   String sql = "select * from easybuy_product_category";

                   return null;

         }

 

         @Override

         public ProductCategory getProductCategoryById(int id) throws Exception {

                   String sql = "select * from easybuy_product_category where epc_id = ?";

                   return null;

         }

 

         @Override

         public boolean insert(ProductCategory pc) throws Exception {

                   String sql = "insert into easybuy_product_category(epc_name,epc_parent_id) values(?,?)";

                   return false;

         }

 

         @Override

         public boolean update(ProductCategory pc) throws Exception {

                   String sql = "update easybuy_product_category set epc_name=?,epc_parent_id=? where epc_id=?";

                   return false;

         }

 

}

ProductDaoImpl

package com.crazybuy.dao.impl;

 

import java.util.List;

 

import com.crazybuy.dao.ProductDao;

import com.crazybuy.entity.Product;

 

public class ProductDaoImpl implements ProductDao {

 

         @Override

         public boolean deleteById(int id, int columnType) throws Exception {

                   String sql = "delete from easybuy_product where";

                   if (columnType == 1) {

                            sql += " ep_id = ?";

                   } else if (columnType == 2) {

                            sql += " epc_id = ?";

                   } else if (columnType == 3) {

                            sql += " epc_child_id = ?";

                   } else {

                            return false;

                   }

                   return false;

         }

 

         @Override

         // 1 2

         public int getCountByCategory(int id, int level) throws Exception {

                   String sql = "select count(*) from easybuy_product where epc_id = ? and ep_status != -1";

                   if (level == 2) {

                            sql = "select count(*) from easybuy_product where epc_child_id = ? and ep_status != -1";

                   }

                   if (id == -1 && level == -1) {

                            sql = "select count(*) from easybuy_product where ep_status != -1";

                   }

                   //

                   return 0;

         }

 

         @Override

         public Product getProductById(int id) throws Exception {

                   String sql = "select * from easybuy_product where ep_id = ?";

                   return null;

         }

 

         @Override

         public List<Product> getProductsByCategory(int id, int level, int pageSize,

                            int pageIndex) throws Exception {

                   String sql = "select * from easybuy_product where epc_id = ? and ep_status != -1 limit ?,?";

                   if (level == 2) {

                            sql = "select * from easybuy_product where epc_child_id = ? and ep_status != -1 limit ?,?";

                   }

                   if (id == -1 && level == -1) {

                            sql = "select * from easybuy_product where ep_status != -1 limit ?,?";

                   }

                   return null;

         }

 

         @Override

         public List<Product> getProductsByStatus(int status, int number)

                            throws Exception {

                   String sql = "select * from easybuy_product where ep_status = ?  limit 0,?";

                   return null;

         }

 

         @Override

         public int getTotalPages(int count, int pageSize) throws Exception {

                   return count % pageSize == 0 ? count / pageSize : count / pageSize + 1;

         }

 

         @Override

         public boolean insert(Product product) throws Exception {

                   String sql = "insert into easybuy_product values(null,?,?,?,?,?,?,?,?)";

                   return false;

         }

 

         @Override

         public boolean setDisable(int id) throws Exception {

                   String sql = "update easybuy_product set ep_status=-1 where ep_id=?";

                   return false;

         }

 

         @Override

         public boolean update(Product product) throws Exception {

                   String sql = "update easybuy_product set ep_name=?,ep_description=?,ep_price=?,ep_stock=?,ep_status=?,epc_id=?,epc_child_id=?,ep_file_name=? where ep_id=?";

                   return false;

         }

 

}

 

 

 

后台的展示页面

  1. 登陆(用户名,密码,验证码)
  2. 后面管理界面(全是html文件)

如何组织页面

  index.html

  index.jsp

include/header.jsp

    建一个文件夹叫include,建一个高级jsp叫header.jsp

    在里面建一个lefter.jsp

在include外面建一个index.jsp

    引进来

   <%@ include file="include/header.jsp" %>

特点是:将两个页面代码先混在一起,再编译。不能有相同的变量名,html,body,title。

  <jsp:include>  各自编译再混在一起。

include/lefter.jsp

中间部分

老板接到客户需求,先会让产品经理画出原型,客户满意了交部分定金,然后ui开始设计(ps),再前端设计成html,再到web前端,

再到后台。

user.html改为user.jsp(跟刚才一样组合)

点左边“用户管理”

 

GetUsersServlet

说明:什么叫业务层。

业务层,完成一件事件需要几个步骤。

去银行转帐: 发生两件事情,你的钱少了,对方的钱多了。调了两次更新语句。 结帐,注册(先查用户是否被注册,然后再决定是否能注册)

 而我们以前dao层,单个的CRUD。

业务层怎么写?和dao写法基本上一样。

也会有业务层的实现类。

 

 

 

 

 

 

 

 

后台登陆:

用户管理:

点击“新增”:

点击“修改”:

点击“删除”:

分类管理

点击“新增”

点击“修改”

 

点击“删除”,有被“商品”表引用的是不能删除的。

商品管理

显示所有,带分页功能。

点击“新增”

以下的可以做成联动形式。

 

 

点击“修改”:

点击“删除”:

新闻管理

点击“新闻管理”:带分页显示功能

点击“添加”:

点击“修改”:

点击“删除”:

留言管理

点击“留言管理”:带分页显示

点击“修改”:

点击“删除”:

订单管理

点击“订单管理”:带分页的查询

点击“修改”:

点击“删除”:

商城主页

最近浏览是5条记录

点击“服饰内衣”,显示3行,每行4个,共12个商品。还有分页。

点击某个商品:

点击购买要登陆:

登陆成功后点击“购买”如下:

继续挑选商品

改变数量,总价会变。

也可以从购物车移除。

点“结算”

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤永红

一分也是爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值