项目介绍
跟学了2022尚硅谷书城项目,自己的代码完成了,现在将整个项目的过程做一个分享:
码云地址如下,需要的可以自行fork
书城项目源码
书城的跟学步骤每一篇博客都有详细记录可以看下:
书城跟学推文1
书城跟学推文2
书城跟学推文3
项目类图
根据项目类图,确定数据库各个实体之间的关系如下:
sql建表和添加数据
CREATE DATABASE bookdb CHAR SET utf8;
USE bookdb ;
CREATE TABLE `t_book` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`bookImg` VARCHAR(200) NOT NULL,
`bookName` VARCHAR(20) DEFAULT NULL,
`price` DOUBLE(10,2) DEFAULT NULL,
`author` VARCHAR(20) DEFAULT NULL,
`saleCount` INT(11) DEFAULT NULL,
`bookCount` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
/*Data for the table `t_book` */
INSERT INTO `t_book`(`id`,`bookImg`,`bookName`,`price`,`author`,`saleCount`,`bookCount`) VALUES (1,'cyuyanrumenjingdian.jpg','C语言入门经典',99.00,'亚历山大',8,197),(2,'santi.jpg','三体',48.95,'周杰伦',18,892),(3,'ailuntulingzhuan.jpg','艾伦图灵传',50.00,'刘若英',12,143),(4,'bainiangudu.jpg','百年孤独',40.00,'王力宏',3,98),(5,'biancheng.jpg','边城',30.00,'刘德华',2,99),(6,'jieyouzahuodian.jpg','解忧杂货店',27.00,'东野圭吾',5,100),(7,'zhongguozhexueshi.jpg','中国哲学史',45.00,'冯友兰',3,100),(8,'huranqiri.jpg','忽然七日',19.00,'劳伦',50,200),(9,'sudongpozhuan.jpg','苏东坡传',20.00,'林语堂',50,300),(10,'fusang.jpg','扶桑',20.00,'严歌岑',10,89),(11,'geihaizideshi.jpg','给孩子的诗',23.00,'北岛',5,99);
CREATE TABLE `t_user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`uname` VARCHAR(20) NOT NULL,
`pwd` VARCHAR(32) NOT NULL,
`email` VARCHAR(100) DEFAULT NULL,
`role` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uname` (`uname`)
) ENGINE=INNODB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
/*Data for the table `t_user` */
INSERT INTO `t_user`(`id`,`uname`,`pwd`,`email`,`role`) VALUES (1,'lina','ok','lina@sina.com.cn',0),(2,'kate','ok','hello_kate@126.com',1),(3,'鸠摩智','ok','jiujiu@126.com',0),(4,'宝2021','ok','bao2021@sohu.com.cn',0),(5,'宝2022','123','bao2022@sohu.com.cn',0);
/*Table structure for table `t_cart_item` */
CREATE TABLE `t_cart_item` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`book` INT(11) DEFAULT NULL,
`buyCount` INT(11) DEFAULT NULL,
`userBean` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_cart_book` (`book`),
KEY `FK_cart_user` (`userBean`),
CONSTRAINT `FK_cart_book` FOREIGN KEY (`book`) REFERENCES `t_book` (`id`),
CONSTRAINT `FK_cart_user` FOREIGN KEY (`userBean`) REFERENCES `t_user` (`id`)
) ENGINE=INNODB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8;
/*Data for the table `t_cart_item` */
INSERT INTO `t_cart_item`(`id`,`book`,`buyCount`,`userBean`) VALUES (9,1,1,2),(10,5,1,1),(11,1,2,1),(12,2,13,1),(13,3,2,1),(14,4,1,1),(15,6,1,1),(16,7,1,1),(17,8,1,1),(18,9,1,1),(19,10,1,1),(20,11,4,1);
/*Table structure for table `t_order` */
CREATE TABLE `t_order` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`orderNo` VARCHAR(128) NOT NULL,
`orderDate` DATETIME DEFAULT NULL,
`orderUser` INT(11) DEFAULT NULL,
`orderMoney` DOUBLE(10,2) DEFAULT NULL,
`orderStatus` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `orderNo` (`orderNo`),
KEY `FK_order_user` (`orderUser`),
CONSTRAINT `FK_order_user` FOREIGN KEY (`orderUser`) REFERENCES `t_user` (`id`)
) ENGINE=INNODB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
/*Data for the table `t_order` */
INSERT INTO `t_order`(`id`,`orderNo`,`orderDate`,`orderUser`,`orderMoney`,`orderStatus`) VALUES (4,'5eaab6146dc54e0482fdb8b6120c229b_20211025112519','2021-10-25 11:25:20',1,506.90,0),(5,'f5a22aac925d42eabc6b49c45a3eb74f_20211025113004','2021-10-25 11:30:04',1,48.95,0),(6,'8a245df4359e4224b531cf121c4acab3_20211025113019','2021-10-25 11:30:20',1,0.00,0),(7,'b521cd49ab2943f0bbc0630c95978f1c_20211025113039','2021-10-25 11:30:40',1,48.95,0),(8,'d4f366a82cd4491c9899b181753804b4_20211025113151','2021-10-25 11:31:52',1,48.95,0),(9,'8f5869a839f4483e947bd2c3163f3c23_20211025113159','2021-10-25 11:31:59',1,48.95,0),(10,'c5fcd95dbe7f49669f96b4ad6444ae6b_20211025120531','2021-10-25 12:05:32',1,147.95,0),(11,'6240ec3e5ac04e3583e1beb75a9e94ec_20211025120542','2021-10-25 12:05:42',1,147.95,0);
/*Table structure for table `t_order_item` */
CREATE TABLE `t_order_item` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`book` INT(11) DEFAULT NULL,
`buyCount` INT(11) DEFAULT NULL,
`orderBean` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_detail_book` (`book`),
KEY `FK_detail_order` (`orderBean`),
CONSTRAINT `FK_detail_book` FOREIGN KEY (`book`) REFERENCES `t_book` (`id`),
CONSTRAINT `FK_detail_order` FOREIGN KEY (`orderBean`) REFERENCES `t_order` (`id`)
) ENGINE=INNODB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
/*Data for the table `t_order_item` */
INSERT INTO `t_order_item`(`id`,`book`,`buyCount`,`orderBean`) VALUES (6,1,1,4),(7,2,2,4),(8,10,1,4),(9,3,5,4),(10,4,1,4),(11,2,1,5),(12,2,1,7),(13,2,1,8),(14,2,1,9),(15,1,1,10),(16,2,1,10),(17,1,1,11),(18,2,1,11);
-- 图书
SELECT * FROM bookdb.`t_book`;
-- 用户
SELECT * FROM bookdb.`t_user`;
-- 订单 外键t_user(orderUser)
SELECT * FROM bookdb.`t_order`;
-- 订单详情 外键t_book(book),t_order(orderBean)
SELECT * FROM bookdb.`t_order_item`;
-- 购物车项 外键t_book(book),t_user(userBean)
SELECT * FROM bookdb.`t_cart_item`;
界面展示
用户登录界面
用户注册界面
首页
添加购物车
我的购物车
我的订单
文章来源:https://www.toymoban.com/news/detail-520595.html
功能说明
用户注册:会校验数据库用户是否存在,不存在则可以注册。
用户登录:用户登录后正常跳转主界面。
主界面:实现价格查询和添加购物车,可以进入购物车。
购物车:可以添加商品数量。
我的订单:可以看到订单的概况文章来源地址https://www.toymoban.com/news/detail-520595.html
到了这里,关于Java web 2022跟学尚硅谷书城项目完整开源分享的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!