商品热销排行【项目 商城】
商品熱銷排行【項目 商城】
- 商品熱銷排行
- 1.商品--創建數據表
- 2.商品--創建實體類
- 3.商品熱銷排行--持久層
- 3.1 規劃查詢的SQL語句
- 3.2 接口與抽象方法
- 3.3 配置SQL映射
- 4.商品熱銷排行--業務層
- 4.1 規劃異常
- 4.2 實現接口與抽象方法
- 4.3 實現抽象方法
- 5.商品熱銷排行--控制器
- 5.1 處理異常
- 5.2 設計請求
- 5.3 處理請求
- 6 商品熱銷排行--前端頁面
- 最后測試
商品熱銷排行
1.商品–創建數據表
1.實現user命令選中store數據庫。
use store;2.在store數據庫中創建t_product數據庫
/**/ /*!40101 SET NAMES utf8 */;CREATE TABLE t_product (id int(20) NOT NULL COMMENT '商品id',category_id int(20) DEFAULT NULL COMMENT '分類id',item_type varchar(100) DEFAULT NULL COMMENT '商品系列',title varchar(100) DEFAULT NULL COMMENT '商品標題',sell_point varchar(150) DEFAULT NULL COMMENT '商品賣點',price bigint(20) DEFAULT NULL COMMENT '商品單價',num int(10) DEFAULT NULL COMMENT '庫存數量',image varchar(500) DEFAULT NULL COMMENT '圖片路徑',status int(1) DEFAULT '1' COMMENT '商品狀態 1:上架 2:下架 3:刪除',priority int(10) DEFAULT NULL COMMENT '顯示優先級',created_time datetime DEFAULT NULL COMMENT '創建時間',modified_time datetime DEFAULT NULL COMMENT '最后修改時間',created_user varchar(50) DEFAULT NULL COMMENT '創建人',modified_user varchar(50) DEFAULT NULL COMMENT '最后修改人',PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000001','238',' 牛皮紙記事本 ',' 廣博(GuangBo) 10本裝40張A5牛皮紙記事本子日記本辦公軟抄本GBR0731 ',' 經典回顧!超值特惠!','23','99999','/images/portal/00GuangBo1040A5GBR0731/','1','62','2017-10-25 15:08:55','2017-10-25 15:08:55','admin ',' admin '); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000002','238',' 皮面日程本 ',' 廣博(GuangBo) 皮面日程本子 計劃記事本效率手冊米色FB60322 ',' 經典回顧!超值特惠!','46','99999','/images/portal/001GuangBo)FB60322/','1','49','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000003','238','16k記事本','廣博(GuangBo)16K115頁線圈記事本子日記本文具筆記本圖案隨機','經典回顧!超值特惠!','13','99999','/images/portal/01GuangBo16K115FB60506/','1','58','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000004','241','計算器','得力(deli)1548A商務辦公桌面計算器 太陽能雙電源','經典回顧!超值特惠!','58','99999','/images/portal/002calculator1548A/','1','42','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000005','241','圓珠筆','施耐德(Schneider) K15 經典款圓珠筆 (5支混色裝)','經典回顧!超值特惠!','29','99999','/images/portal/03SchneiderK15/','1','36','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000006','236','票據網格拉鏈袋','三木(SUNWOOD) C4523 票據網格拉鏈袋/文件袋 12個裝 顏色隨機','經典回顧!超值特惠!','28','99999','/images/portal/04_SUNWOODC452312/','1','53','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000007','163','燃 7000','戴爾Dell 燃700經典版金色','下單贈12000毫安移動電源','32999','99999','/images/portal/11DELLran7000gold/','1','59','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000008','163','燃 7000','戴爾Dell 燃700R1605經典版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','4549','99999','/images/portal/11DELLran7000R1605Ssilvery/','1','32','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000009','163','燃 7000','戴爾Dell 燃700學習版金色','下單贈12000毫安移動電源','39929','99999','/images/portal/11DELLran7000gold/','1','84','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000010','163','燃 7000','戴爾Dell 燃700R1605學習版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','5559','99999','/images/portal/11DELLran7000R1605Ssilvery/','1','21','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000011','163','燃 7000','戴爾Dell 燃700高配版金色','下單贈12000毫安移動電源','3994','99999','/images/portal/11DELLran7000gold/','1','56','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000012','163','燃 7000','戴爾Dell 燃700R1605高配版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','6559','99999','/images/portal/11DELLran7000R1605Ssilvery/','1','16','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000013','238','A5優品商務筆記本','齊心(COMIX)C5902 A5優品商務筆記本子記事本日記本122張','下單即送10400毫安移動電源!再贈手機魔法盒!','41','99999','/images/portal/02COMIXC5902A5122blue/','1','10','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000014','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3標準版金色','僅上海,廣州,沈陽倉有貨!預購從速!','4600','99999','/images/portal/12(DELL)XPS13gold/','1','1','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000015','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3標準版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','4601','99999','/images/portal/12DELLXPS13-silvery/','1','73','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000016','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3高配版金色','僅上海,廣州,沈陽倉有貨!預購從速!','4602','99999','/images/portal/12(DELL)XPS13gold/','1','64','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000017','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3高配版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','4604','99992','/images/portal/12DELLXPS13-silvery/','1','100','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000018','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3尊貴版金色','僅上海,廣州,沈陽倉有貨!預購從速!','4605','99999','/images/portal/12(DELL)XPS13gold/','1','7','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000019','163','XPS13-9360','戴爾(DELL)XPS13-9360-R1609 13.3尊貴版銀色','僅上海,廣州,沈陽倉有貨!預購從速!','4899','99999','/images/portal/12DELLXPS13-silvery/','1','34','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000020','163','IdeaPad310','聯想(Lenovo)IdeaPad310低配版黑色','清倉!僅北京,武漢倉有貨!','5119','99999','/images/portal/13LenovoIdeaPad310_black/','1','50','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000021','163','IdeaPad310','聯想(Lenovo)IdeaPad310低配版銀色','清倉!僅北京,武漢倉有貨!','5129','99999','/images/portal/13LenovoIdeaPad310_silvery/','1','48','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000022','163','IdeaPad310','聯想(Lenovo)IdeaPad310經典版黑色','清倉!僅北京,武漢倉有貨!','5119','99999','/images/portal/13LenovoIdeaPad310_black/','1','90','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000023','163','IdeaPad310','聯想(Lenovo)IdeaPad310經典版銀色','清倉!僅北京,武漢倉有貨!','5129','99999','/images/portal/13LenovoIdeaPad310_silvery/','1','6','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000024','163','IdeaPad310','聯想(Lenovo)IdeaPad310高配版黑色','清倉!僅北京,武漢倉有貨!','5119','99999','/images/portal/13LenovoIdeaPad310_black/','1','60','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000025','163','IdeaPad310','聯想(Lenovo)IdeaPad310高配版銀色','清倉!僅北京,武漢倉有貨!','5129','99999','/images/portal/13LenovoIdeaPad310_silvery/','1','80','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000026','163','YOGA710','聯想(Lenovo)YOGA710 14英寸(i7-7500U 8G 256GSSD 2G獨顯)金色','【0元獻禮】好評過萬,銷量傳奇!經典藍光電視,獨有自然光技術專利,過大年帶最好的回家!【0元白條試用,1001個拜年計劃】','59999','99999','/images/portal/14LenovoYOGA710 _gold/','1','19','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000027','163','YOGA710','聯想(Lenovo)YOGA710 14英寸(i7-7500U 8G 256GSSD 2G獨顯)銀色','【0元獻禮】好評過萬,銷量傳奇!經典藍光電視,獨有自然光技術專利,過大年帶最好的回家!【0元白條試用,1001個拜年計劃】','59999','99999','/images/portal/14LenovoYOGA710 _silvery/','1','55','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000028','163','小新310','聯想(Lenovo)小新310低配版黑色','清倉!僅北京,武漢倉有貨!','4939','99997','/images/portal/15Lenovo_xiaoxin_310_black/','1','19','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000029','163','小新310','聯想(Lenovo)小新310低配版銀色','清倉!僅北京,武漢倉有貨!','4839','99999','/images/portal/15Lenovo_xiaoxin_310_silvery/','1','27','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000030','163','小新310','聯想(Lenovo)小新310經典版黑色','清倉!僅北京,武漢倉有貨!','4739','99999','/images/portal/15Lenovo_xiaoxin_310_black/','1','78','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000031','163','小新310','聯想(Lenovo)小新310經典版銀色','清倉!僅北京,武漢倉有貨!','4639','99998','/images/portal/15Lenovo_xiaoxin_310_silvery/','1','9','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000032','163','小新310','聯想(Lenovo)小新310高配版黑色','清倉!僅北京,武漢倉有貨!','4539','99999','/images/portal/15Lenovo_xiaoxin_310_black/','1','9','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000033','163','小新310','聯想(Lenovo)小新310高配版銀色','清倉!僅北京,武漢倉有貨!','4439','99999','/images/portal/15Lenovo_xiaoxin_310_silvery/','1','18','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000034','163','YOGA900','聯想(Lenovo)YOGA900綠色','青春的活力 清新漂亮高端大氣上檔次','5200','99999','/images/portal/16LenovoYOGA900green/','1','63','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000035','163','YOGA900','聯想(Lenovo)YOGA900粉色','青春的活力 清新漂亮高端大氣上檔次','5200','99999','/images/portal/16LenovoYOGA900pink/','1','62','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000036','163','YOGA900','聯想(Lenovo)YOGA900紅色','青春的活力 清新漂亮高端大氣上檔次','5200','99999','/images/portal/16LenovoYOGA900red/','1','21','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000037','163','小新13旗艦版','聯想(Lenovo)小新Air13 Pro 13.3英寸14.8mm超輕薄筆記本電腦金色','青春的活力 青年專屬','6439','99998','/images/portal/17Lenovo)xiaoxinAir13Pro_gold/','1','16','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000038','163','小新13旗艦版','聯想(Lenovo)小新Air13 Pro 13.3英寸14.8mm超輕薄筆記本電腦銀色','青春的活力 青年專屬','6439','99998','/images/portal/17Lenovo)xiaoxinAir13Pro_silvery/','1','17','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000039','163','XPS15','戴爾(DELL) XPS15 銀色','限時特價!好評過萬條優秀產品!','3333','99999','/images/portal/18(DELL)XPS15_silvery/','1','37','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000040','163','15MF Pro','戴爾(DELL)魔方15MF Pro-R2505TSS靈越標準版','15.6英寸二合一翻轉筆記本電腦 (i5-7200U 8GB 1TB IPS Win10)觸控銀','4443','99999','/images/portal/19DELL15MF Pro/','1','35','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000041','163','XPS15-9550','戴爾(DELL) XPS15標準版','15.6英寸二合一翻轉筆記本電腦 (i5-7200U 8GB 1TGB IPS Win10)觸控','8443','99999','/images/portal/20DellXPS15-9550/','1','61','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000042','163','ThinkPad New s1','聯想ThinkPad New S1(01CD) i5 6代 紅色','經典回顧!超值特惠!','4399','99999','/images/portal/21ThinkPad_New_S1/','1','99','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000043','917','書包 bag','樂尚書包 電腦包 bag黑色','給你滿載而歸的喜悅!','89','99999','/images/portal/22_LEXON_LNE6025B06T/','1','12','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('10000044','917','書包 bag','樂尚書包 電腦包 bag粉色','給你滿載而歸的喜悅!','89','99999','/images/portal/22_LEXON_LNE6025B06T/','1','62','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000021','238','皮面日程本','廣博(GuangBo)皮面日程本子 計劃記事本效率手冊藍色FB60321','經典回顧!超值特惠!','22','99999','/images/portal/001GuangBo)FB60322/','1','73','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000391','163','XPS15','戴爾(DELL) XPS15 金色','限時特價!好評過萬條優秀產品!','3333','99999','/images/portal/18(DELL)XPS15_silvery/','1','81','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000401','163','15MF Pro','戴爾(DELL)魔方15MF Pro-R2505TSS靈越高配版','15.6英寸二合一翻轉筆記本電腦 (i5-7200U 8GB 1TB IPS Win10)觸控白','4443','99997','/images/portal/19DELL15MF Pro/','1','86','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000402','163','15MF Pro','戴爾(DELL)魔方15MF Pro-R2505TSS靈越玩家版','15.6英寸二合一翻轉筆記本電腦 (i7-7200U 8GB 512GB IPS Win10)觸控銀','6443','99999','/images/portal/19DELL15MF Pro/','1','84','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000403','163','15MF Pro','戴爾(DELL)魔方15MF Pro-R2505TSS靈越旗艦版','15.6英寸二合一翻轉筆記本電腦 (i7-7200U 8GB 512GB IPS Win10)觸控白','6443','99999','/images/portal/19DELL15MF Pro/','1','63','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000411','163','XPS15-9550','戴爾(DELL) XPS15升級版 ','15.6英寸二合一翻轉筆記本電腦 (i5-7200U 8GB 256GB IPS Win10)觸控','8443','99999','/images/portal/20DellXPS15-9550/','1','60','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000412','163','XPS15-9550','戴爾(DELL) XPS15高配版','15.6英寸二合一翻轉筆記本電腦 (i7-7200U 8GB 1TB IPS Win10)觸控','8443','99999','/images/portal/20DellXPS15-9550/','1','13','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000413','163','XPS15-9550','戴爾(DELL) XPS15專業版','15.6英寸二合一翻轉筆記本電腦 (i7-7200U 8GB 256GB IPS Win10)觸控','8443','99999','/images/portal/20DellXPS15-9550/','1','83','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000421','163','ThinkPad New s1','聯想ThinkPad New S1(01CD) i7 6代 紅色','經典回顧!超值特惠!','6399','99999','/images/portal/21ThinkPad_New_S1/','1','74','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000422','163','ThinkPad New s1','聯想ThinkPad New S1(01CD) i5 6代 黃色','經典回顧!超值特惠!','4399','99999','/images/portal/21ThinkPad_New_S1/','1','23','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000424','163','ThinkPad New s1','聯想ThinkPad New S1(01CD) i5 6代 藍色','經典回顧!超值特惠!','4399','99999','/images/portal/21ThinkPad_New_S1/','1','87','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin'); insert into `t_product` (`id`, `category_id`, `item_type`, `title`, `sell_point`, `price`, `num`, `image`, `status`, `priority`, `created_time`, `modified_time`, `created_user`, `modified_user`) values('100000425','163','ThinkPad New s1','聯想ThinkPad New S1(01CD) i7 6代 藍色','經典回顧!超值特惠!','6399','99999','/images/portal/21ThinkPad_New_S1/','1','59','2017-10-25 15:08:55','2017-10-25 15:08:55','admin','admin');t_product.sql
2.商品–創建實體類
創建com.cy.store.entity.Product類,并繼承BaseEntity類。在類中聲明與數據科中對應的屬性。
/** 商品數據的實體類 */ public class Product extends BaseEntity implements Serializable {private Integer id;private Integer categoryId;private String itemType;private String title;private String sellPoint;private Long price;private Integer num;private String image;private Integer status;private Integer priority;//**** }Product
3.商品熱銷排行–持久層
3.1 規劃查詢的SQL語句
查詢熱銷商品列表的SQL語句。
SELECT * FORM t_product WHERE status=1 ORDER BY piority DESC LIMIT 0,43.2 接口與抽象方法
package com.cy.store.mapper;import com.cy.store.entity.Product;import java.util.List;public interface ProductMapper {/* 查詢熱銷商品的前四名*/List<Product> findHotList(); }3.3 配置SQL映射
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.cy.store.mapper.ProductMapper"><resultMap id="ProductEntityMap" type="com.cy.store.entity.Product"><id column="id" property="id"/><result column="category_id" property="categoryId"/><result column="item_type" property="itemType"/><result column="sell_point" property="sellPoint"/><result column="created_user" property="createdUser"/><result column="created_time" property="createdTime"/><result column="modified_user" property="modifiedUser"/><result column="modified_time" property="modifiedTime"/></resultMap><!-- 查詢熱銷商品的前四名:List<Product> findHostList() --><select id="findHotList" resultMap="ProductEntityMap">SELECT * FROM t_product WHERE status=1 ORDER BY priority DESC LIMIT 0,4</select></mapper>ProductMapper–findHotList
4.商品熱銷排行–業務層
4.1 規劃異常
說明:無異常4.2 實現接口與抽象方法
package com.cy.store.service;import com.cy.store.entity.Product;import java.util.List;/* 處理商品數據的業務層接口 */ public interface IProductService {/*查詢熱銷商品的前四名*/List<Product> findHotList();}4.3 實現抽象方法
創建IProductService接口,并在接口中添加findHotList()方法。
package com.cy.store.service.impl;import com.cy.store.entity.Product; import com.cy.store.mapper.ProductMapper; import com.cy.store.service.IProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;import java.util.List;/** 處理商品數據的業務層實現類 */ @Service public class ProductServiceImpl implements IProductService {@Autowiredprivate ProductMapper productMapper;@Overridepublic List<Product> findHotList() {List<Product> list = productMapper.findHotList();for (Product product : list) {product.setPriority(null);product.setCreatedUser(null);product.setCreatedTime(null);product.setModifiedUser(null);product.setModifiedTime(null);}return list;} }ProductServiceImpl–findHotList
5.商品熱銷排行–控制器
5.1 處理異常
說明:無異常5.2 設計請求
1.設計用戶提交的請求,并設計響應的方法
請求路徑:/products/hot_list 請求參數:無 請求類型: GET 響應結果:JsonResult<List<Product>> 是否攔截:否,需要將index.html和/products/**請求添加白名單2.在LoginInterceptorConfigurer中將index.html頁面和/products/**請求添加白名單
patterns.add("/web/index.html");patterns.add("/products/**");LoginInterceptorConfigurer–/products
5.3 處理請求
1.創建ProductController類繼承BaseController類,類添加@RestController和@RequestMapping(“products”)注解,并在類中添加業務層對象。
2.在類中添加處理請求的getHotList()方法。
ProductController–getHotList
3.完成后啟動項目,直接訪問測試。
6 商品熱銷排行–前端頁面
1.在index.html給“熱銷排行”列表的div標簽設置id屬性值。
<div id="hot-list" class="panel-body panel-item">2.在index.html頁面中body標簽內部的最后,添加展示熱銷排行商品的代碼。
<!-- showHotList --><script type="text/javascript">$(document).ready(function() {showHotList();});function showHotList() {$("#hot-list").empty();$.ajax({url: "/products/hot_list",type: "GET",dataType: "JSON",success: function(json) {let list = json.data;console.log("count=" + list.length);for (let i = 0; i < list.length; i++) {console.log(list[i].title);let html = '<div class="col-md-12">'+ '<div class="col-md-7 text-row-2"><a href="product.html?id=#{id}">#{title}</a></div>'+ '<div class="col-md-2">¥#{price}</div>'+ '<div class="col-md-3"><img src="..#{image}collect.png" class="img-responsive" /></div>'+ '</div>';html = html.replace(/#{id}/g, list[i].id);html = html.replace(/#{title}/g, list[i].title);html = html.replace(/#{price}/g, list[i].price);html = html.replace(/#{image}/g, list[i].image);$("#hot-list").append(html);}}});}</script><!-- showHotList -->index.html–showHotList
最后測試
說明:圖片存儲在portal下
README–商品熱銷排行
總結
以上是生活随笔為你收集整理的商品热销排行【项目 商城】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 嵌入式ARM下使用ALSA USB声卡
- 下一篇: 漏斗图轻松解读数据