1. 程式人生 > 實用技巧 >翻出2018的Java84班的二階段專案-商城專案

翻出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','李明','男','[email protected]','15939923063','河南鄭州金水區','',2);

insert into crazybuy_user values('zs12345','zs12345','張三','男','[email protected]','15938750383','河南鄭州金水區','',1);

insert into crazybuy_user values('lucy','lucy12345','路西','女','[email protected]','13523451532','北京朝陽區','',1);

insert into crazybuy_user values('tom','tom12345','湯姆','男','[email protected]','15138006548','河南鄭州二七區','',1);

insert into crazybuy_user values('jack','jack12345','傑克','男','[email protected]','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個商品。還有分頁。

點選某個商品:

點選購買要登陸:

登陸成功後點擊“購買”如下:

繼續挑選商品

改變數量,總價會變。

也可以從購物車移除。

點“結算”