├── .idea ├── .gitignore ├── artifacts │ └── web_war_exploded.xml ├── codeStyles │ └── codeStyleConfig.xml ├── dataSources.xml ├── dictionaries │ └── 19931.xml ├── encodings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── libraries │ ├── jstl.xml │ └── mysql_connector_java_5_1_25.xml ├── misc.xml ├── modules.xml ├── sqldialects.xml ├── uiDesigner.xml ├── vcs.xml └── webContexts.xml ├── README.md ├── ShoppingSystem.iml ├── out ├── artifacts │ └── web_war_exploded │ │ ├── WEB-INF │ │ ├── classes │ │ │ ├── dao │ │ │ │ ├── GoodsDAO.class │ │ │ │ ├── OrderDetailDAO.class │ │ │ │ ├── OrderIndexDAO.class │ │ │ │ ├── PeopleDAO.class │ │ │ │ └── impl │ │ │ │ │ ├── GoodsDAOImpl.class │ │ │ │ │ ├── OrderDetailDAOImpl.class │ │ │ │ │ ├── OrderIndexDAOImpl.class │ │ │ │ │ └── PeopleDAOImpl.class │ │ │ ├── entity │ │ │ │ ├── Goods.class │ │ │ │ ├── OrderDetail.class │ │ │ │ ├── OrderIndex.class │ │ │ │ └── People.class │ │ │ ├── others │ │ │ │ ├── projectinfo.md │ │ │ │ └── shoppingsystem.sql │ │ │ ├── service │ │ │ │ ├── GoodsService.class │ │ │ │ ├── OrderService.class │ │ │ │ ├── PeopleService.class │ │ │ │ └── impl │ │ │ │ │ ├── GoodsServiceImpl.class │ │ │ │ │ ├── OrderServiceImpl.class │ │ │ │ │ └── PeopleServiceImpl.class │ │ │ ├── servlet │ │ │ │ ├── CheckCodeServlet.class │ │ │ │ ├── GoodsServlet.class │ │ │ │ ├── OrderServlet.class │ │ │ │ └── PeopleServlet.class │ │ │ ├── test │ │ │ │ ├── GoodsDAOImplTest.class │ │ │ │ ├── JdbcUtilTest.class │ │ │ │ ├── OrderDetailDAOImplTest.class │ │ │ │ ├── OrderIndexDAOImplTest.class │ │ │ │ └── PeopleDAOImplTest.class │ │ │ └── util │ │ │ │ ├── CustomUtil.class │ │ │ │ └── JdbcUtil.class │ │ ├── lib │ │ │ ├── jstl.jar │ │ │ ├── mysql-connector-java-5.1.25.jar │ │ │ └── standard.jar │ │ └── web.xml │ │ ├── css │ │ ├── bootstrap.min.css │ │ └── index.css │ │ ├── index.jsp │ │ ├── js │ │ ├── bootstrap.min.js │ │ └── jquery-3.5.1.min.js │ │ ├── page │ │ ├── goods.jsp │ │ ├── login.jsp │ │ ├── loginCorrect.jsp │ │ ├── logoutCorrect.jsp │ │ ├── order.jsp │ │ ├── register.jsp │ │ ├── registerCorrect.jsp │ │ └── shopCar.jsp │ │ └── png │ │ ├── other0.png │ │ ├── other1.png │ │ ├── other2.png │ │ ├── other3.png │ │ ├── other4.png │ │ ├── other5.png │ │ ├── other6.png │ │ ├── other7.png │ │ ├── other8.png │ │ ├── other9.png │ │ ├── phone0.png │ │ ├── phone1.png │ │ ├── phone2.png │ │ ├── phone3.png │ │ ├── phone4.png │ │ ├── phone5.png │ │ ├── phone6.png │ │ ├── phone7.png │ │ └── phone8.png └── production │ └── web │ ├── dao │ ├── GoodsDAO.class │ ├── OrderDetailDAO.class │ ├── OrderIndexDAO.class │ ├── PeopleDAO.class │ └── impl │ │ ├── GoodsDAOImpl.class │ │ ├── OrderDetailDAOImpl.class │ │ ├── OrderIndexDAOImpl.class │ │ └── PeopleDAOImpl.class │ ├── entity │ ├── Goods.class │ ├── OrderDetail.class │ ├── OrderIndex.class │ └── People.class │ ├── others │ ├── projectinfo.md │ └── shoppingsystem.sql │ ├── service │ ├── GoodsService.class │ ├── OrderService.class │ ├── PeopleService.class │ └── impl │ │ ├── GoodsServiceImpl.class │ │ ├── OrderServiceImpl.class │ │ └── PeopleServiceImpl.class │ ├── servlet │ ├── CheckCodeServlet.class │ ├── GoodsServlet.class │ ├── OrderServlet.class │ └── PeopleServlet.class │ ├── test │ ├── GoodsDAOImplTest.class │ ├── JdbcUtilTest.class │ ├── OrderDetailDAOImplTest.class │ ├── OrderIndexDAOImplTest.class │ └── PeopleDAOImplTest.class │ └── util │ ├── CustomUtil.class │ └── JdbcUtil.class └── web ├── src ├── dao │ ├── GoodsDAO.java │ ├── OrderDetailDAO.java │ ├── OrderIndexDAO.java │ ├── PeopleDAO.java │ └── impl │ │ ├── GoodsDAOImpl.java │ │ ├── OrderDetailDAOImpl.java │ │ ├── OrderIndexDAOImpl.java │ │ └── PeopleDAOImpl.java ├── entity │ ├── Goods.java │ ├── OrderDetail.java │ ├── OrderIndex.java │ └── People.java ├── service │ ├── GoodsService.java │ ├── OrderService.java │ ├── PeopleService.java │ └── impl │ │ ├── GoodsServiceImpl.java │ │ ├── OrderServiceImpl.java │ │ └── PeopleServiceImpl.java ├── servlet │ ├── CheckCodeServlet.java │ ├── GoodsServlet.java │ ├── OrderServlet.java │ └── PeopleServlet.java ├── sql │ └── shoppingsystem.sql ├── test │ ├── GoodsDAOImplTest.java │ ├── JdbcUtilTest.java │ ├── OrderDetailDAOImplTest.java │ ├── OrderIndexDAOImplTest.java │ └── PeopleDAOImplTest.java └── util │ ├── CustomUtil.java │ └── JdbcUtil.java ├── web.iml └── web ├── WEB-INF ├── lib │ ├── jstl.jar │ ├── mysql-connector-java-5.1.25.jar │ └── standard.jar └── web.xml ├── css ├── bootstrap.min.css └── index.css ├── index.jsp ├── js ├── bootstrap.min.js └── jquery-3.5.1.min.js ├── page ├── goods.jsp ├── login.jsp ├── loginCorrect.jsp ├── logoutCorrect.jsp ├── order.jsp ├── register.jsp ├── registerCorrect.jsp └── shopCar.jsp └── png ├── other0.png ├── other1.png ├── other2.png ├── other3.png ├── other4.png ├── other5.png ├── other6.png ├── other7.png ├── other8.png ├── other9.png ├── phone0.png ├── phone1.png ├── phone2.png ├── phone3.png ├── phone4.png ├── phone5.png ├── phone6.png ├── phone7.png └── phone8.png /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/artifacts/web_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/web_war_exploded 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://localhost:3306/shoppingsystem 9 | $ProjectFileDir$ 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/dictionaries/19931.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | checkcode 5 | ibfk 6 | newprice 7 | oldprice 8 | shoppingsystem 9 | sumprice 10 | throwables 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/jstl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/mysql_connector_java_5_1_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/sqldialects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/webContexts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShoppingSystem 2 | 3 | 后台茶杯文件位于`ShoppingSystem/web/src/`路径下 4 | 5 | 前台web文件位于`ShoppingSystem/web/web/`路径下 6 | 7 | 数据库脚本文件位于`ShoppingSystem/web/src/sql/shoppingsystem.sql`路径下 8 | -------------------------------------------------------------------------------- /ShoppingSystem.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/GoodsDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/GoodsDAO.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/OrderDetailDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/OrderDetailDAO.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/OrderIndexDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/OrderIndexDAO.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/PeopleDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/PeopleDAO.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/GoodsDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/GoodsDAOImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/OrderDetailDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/OrderDetailDAOImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/OrderIndexDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/OrderIndexDAOImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/PeopleDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/dao/impl/PeopleDAOImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/entity/Goods.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/entity/Goods.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/entity/OrderDetail.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/entity/OrderDetail.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/entity/OrderIndex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/entity/OrderIndex.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/entity/People.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/entity/People.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/others/projectinfo.md: -------------------------------------------------------------------------------- 1 | # Session清单 2 | 1. `checkcode`:存储验证码,用于`register.jsp`与`login.jsp`显示。 3 | 2. `register_error_info`:注册失败原因,用于`register.jsp`回显。 4 | 3. `error_people`:注册失败的表单信息,用于`register.jsp`回填。 5 | 4. `login_error_info`:登录失败原因,用于`login.jsp`回显。 6 | 5. `now_people`:当前登录用户,在登录成功时创建,用于提取用户信息。 7 | 6. `now_goods`:当前浏览商品,用于表单提交后`GoodsServlet`识别商品。 8 | 7. `submit_info`:订单提交信息,用于`shopCar.jsp`回显。 9 | 8. `orderIndexList`:订单索引查询结果,用于`order.jsp`显示。 10 | 9. `orderDetailHashmap`:订单详情查询结果,用于`order.jsp`显示。 -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/others/shoppingsystem.sql: -------------------------------------------------------------------------------- 1 | -- 删除数据库 2 | DROP DATABASE IF EXISTS shoppingsystem; 3 | 4 | -- 创建数据库 5 | CREATE DATABASE shoppingsystem CHARACTER SET utf8; 6 | 7 | -- 使用数据库 8 | USE shoppingsystem; 9 | 10 | -- 删除数据表 11 | DROP TABLE IF EXISTS `order_detail`; 12 | DROP TABLE IF EXISTS `order_index`; 13 | DROP TABLE IF EXISTS `people`; 14 | DROP TABLE IF EXISTS `goods`; 15 | 16 | -- 创建数据表 17 | # 1.创建用户信息表 18 | CREATE TABLE `people` ( 19 | `id` INT NOT NULL,/*用户编号*/ 20 | `password` VARCHAR(50),/*用户密码*/ 21 | `name` VARCHAR(50),/*用户姓名*/ 22 | `email` VARCHAR(50),/*用户邮箱*/ 23 | `address` VARCHAR(100),/*用户地址*/ 24 | `status` INT,/*用户状态*/ 25 | CONSTRAINT `people_pk_id` PRIMARY KEY (`id`)/* 用户编号作为主键 */ 26 | ) ENGINE = InnoDB; 27 | 28 | # 2.创建商品信息表 29 | CREATE TABLE `goods` ( 30 | `id` INT NOT NULL,/*商品编号*/ 31 | `name` VARCHAR(50),/*商品名称*/ 32 | `image` VARCHAR(50),/*商品图片*/ 33 | `old_price` INT,/*商品原价*/ 34 | `new_price` INT,/*商品现价*/ 35 | `info_brief` VARCHAR(100),/*商品简要信息*/ 36 | `info_detailed` VARCHAR(100),/*商品详细信息*/ 37 | `info_additional` VARCHAR(100),/*商品附加信息*/ 38 | `status` INT,/*商品状态*/ 39 | CONSTRAINT `goods_pk_id` PRIMARY KEY (`id`)/*商品编号作为主键*/ 40 | ) ENGINE = InnoDB; 41 | 42 | # 3.创建订单索引表/*存储一个用户的订单索引信息*/ 43 | CREATE TABLE `order_index` ( 44 | `id` INT NOT NULL AUTO_INCREMENT,/*订单编号*/ 45 | `person_id` INT NOT NULL,/*订单的属主的编号*/ 46 | `price` INT,/*订单总价*/ 47 | `address` VARCHAR(100),/*收货地址*/ 48 | `time` DATETIME,/*创建日期*/ 49 | `status` INT,/*订单状态*/ 50 | CONSTRAINT `order_index_pk_id` PRIMARY KEY (`id`),/*订单编号作为主键*/ 51 | CONSTRAINT `order_index_ibfk_person_id` FOREIGN KEY (`person_id`) REFERENCES `people` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*用户表用户编号作为外键*/ 52 | ) ENGINE = InnoDB AUTO_INCREMENT = 100;/*支持外键以及事务处理,主键从100开始自增*/ 53 | 54 | # 4.创建订单详情表/*存储所有用户的所有订单的详细信息*/ 55 | CREATE TABLE `order_detail` ( 56 | `order_index_id` INT NOT NULL,/*所属订单的编号*/ 57 | `goods_id` INT NOT NULL,/*所含商品的编号*/ 58 | `goods_name` VARCHAR(50),/*所含商品的名称*/ 59 | `number` INT,/*每种商品的数量*/ 60 | `price` INT,/*每种商品的总价*/ 61 | CONSTRAINT `order_detail_pk_order_index_id_goods_id` PRIMARY KEY (`order_index_id`, `goods_id`),/*商品编号与所属订单编号作为联合主键 */ 62 | CONSTRAINT `order_detail_ibfk_order_index_id` FOREIGN KEY (`order_index_id`) REFERENCES `order_index` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,/*订单索引表订单编号作为外键*/ 63 | CONSTRAINT `order_detail_ibfk_goods_id` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*商品表商品编号作为外键*/ 64 | ) ENGINE = InnoDB;/*支持外键以及事务处理*/ 65 | 66 | -- 编写测试数据 67 | # 1.增加用户信息 68 | INSERT INTO `people` VALUES (2022101, '123456', '阿卡丽', '534953576@qq.com', '均衡教派', 0); 69 | INSERT INTO `people` VALUES (2022102, '123456', '琪亚娜', '534953576@qq.com', '以绪塔尔', 0); 70 | INSERT INTO `people` VALUES (2022103, '123456', '艾瑞利娅', '534953576@qq.com', '艾欧尼亚', 0); 71 | INSERT INTO `people` VALUES (2022104, '123456', '卡莎', '534953576@qq.com', '虚空之地', 0); 72 | INSERT INTO `people` VALUES (2022105, '123456', '霞', '534953576@qq.com', '瓦斯塔亚', 0); 73 | INSERT INTO `people` VALUES (2022106, '123456', '洛', '534953576@qq.com', '瓦斯塔亚', 0); 74 | 75 | # 2.增加商品数据 76 | INSERT INTO `goods` VALUES (101, 'HUAWEI P40 Pro 5G', './png/phone1.png', 6300, 5988, '享三期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 77 | INSERT INTO `goods` VALUES (102, 'HUAWEI P40 Pro+ 5G', './png/phone2.png', 8000, 7988, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 78 | INSERT INTO `goods` VALUES (103, '荣耀30', './png/phone3.png', 3500, 3298, '50倍超稳远摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 79 | INSERT INTO `goods` VALUES (104, 'HUAWEI Mate 30E Pro 5G', './png/phone4.png', 5300, 5299, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 80 | INSERT INTO `goods` VALUES (105, 'HUAWEI Mate 40 Pro+ 5G','./png/phone5.png', 9000, 8999, '享多重权益', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 81 | INSERT INTO `goods` VALUES (106, '荣耀Play4', './png/phone6.png', 2000, 1999, '6400万锐利四摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 82 | INSERT INTO `goods` VALUES (107, '华为畅想20 Plus', './png/phone7.png', 2500, 2299 ,'购机赠耳机', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 83 | INSERT INTO `goods` VALUES (108, '荣耀X10 Max', './png/phone8.png', 2100, 2099, '护眼阳光屏', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 84 | 85 | # 3.增加订单索引数据 86 | # INSERT INTO `order_index` VALUES (0, 2022101, 13976, '均衡教派', now(), 0); 87 | # INSERT INTO `order_index` VALUES (0, 2022101, 5988, '均衡教派', now(), 0); 88 | # INSERT INTO `order_index` VALUES (0, 2022101, 7988, '均衡教派', now(), 0); 89 | 90 | # 4.增加订单详情数据 91 | # INSERT INTO `order_detail` VALUES (100, 101, 'HUAWEI P40 Pro 5G', 1, 5988); 92 | # INSERT INTO `order_detail` VALUES (100, 102, 'HUAWEI P40 Pro+ 5G', 1, 7988); 93 | 94 | -- 提交事务 95 | COMMIT; -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/GoodsService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/GoodsService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/OrderService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/OrderService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/PeopleService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/PeopleService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/GoodsServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/GoodsServiceImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/OrderServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/OrderServiceImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/PeopleServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/service/impl/PeopleServiceImpl.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/CheckCodeServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/CheckCodeServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/GoodsServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/GoodsServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/OrderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/OrderServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/PeopleServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/PeopleServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/test/GoodsDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/test/GoodsDAOImplTest.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/test/JdbcUtilTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/test/JdbcUtilTest.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/test/OrderDetailDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/test/OrderDetailDAOImplTest.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/test/OrderIndexDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/test/OrderIndexDAOImplTest.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/test/PeopleDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/test/PeopleDAOImplTest.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/util/CustomUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/util/CustomUtil.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/util/JdbcUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/classes/util/JdbcUtil.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/jstl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/lib/jstl.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.25.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.25.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/standard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/WEB-INF/lib/standard.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | index.jsp 8 | 9 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/css/index.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | * { 3 | padding: 0;/*填充*/ 4 | margin: 0;/*外边距*/ 5 | } 6 | 7 | body { 8 | padding-top: 50px;/*避免文本被导航栏覆盖*/ 9 | background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);/*设置主题渐变色*/ 10 | } 11 | 12 | a { 13 | text-decoration: none;/*去掉链接的下划线*/ 14 | color: black; 15 | } 16 | 17 | a:hover{ 18 | text-decoration: none;/*去掉链接的下划线*/ 19 | } 20 | 21 | /*main*/ 22 | /** 23 | * 定义main类中的right类中的a标签中的第一个div的:hover属性 24 | * 当两个选择器之间有空格的情况下, 可以选择包括的所有子代, 而 ">"只能选择具有直接承下关系的子代 25 | */ 26 | .main .right>a>div:hover { 27 | box-shadow: 5px 5px 15px #888888;/*box-shadow: h-shadow(必需的 水平阴影的位置 允许负值) v-shadow(必需的 垂直阴影的位置 允许负值) blur(可选 模糊距离) spread(可选 阴影的大小) color(可选 阴影的颜色 在CSS颜色值寻找颜色值的完整列表) inset(可选 从外层的阴影(开始时)改变阴影内侧阴影);*/ 28 | transition: 0.5s;/*定义过渡效果*/ 29 | } 30 | 31 | .main { 32 | width: 1226px; 33 | height: 750px; 34 | margin: 0 auto;/*上下无边距, 左右居中*/ 35 | } 36 | 37 | .main .left { 38 | width: 234px; 39 | height: 614px; 40 | float: left;/*将块级元素浮动至最左侧*/ 41 | } 42 | 43 | .main .left img { 44 | width: 234px; 45 | height: 614px; 46 | } 47 | 48 | .main .middle { 49 | width: 234px; 50 | height: 300px; 51 | float: left;/*将块级元素浮动至最左侧*/ 52 | } 53 | 54 | .main .middle img { 55 | width: 234px; 56 | height: 300px; 57 | margin-bottom: 14px; 58 | } 59 | 60 | .main .right { 61 | width: 992px; 62 | height: 614px; 63 | float: left; 64 | background-color: #f5f5f5; 65 | } 66 | 67 | .main .right>a>div { 68 | width: 234px; 69 | height: 300px; 70 | float: left; 71 | background-color: #ffffff; 72 | margin-left: 14px; 73 | margin-bottom: 14px; 74 | } 75 | 76 | .main .right>a>div .images { 77 | width: 160px; 78 | height: 160px; 79 | margin: 10px auto; 80 | } 81 | 82 | .main .right>a>div .images img { 83 | width: 160px; 84 | height: 160px; 85 | } 86 | 87 | .main .right>a>div .name { 88 | margin: 5px auto; 89 | } 90 | 91 | .main .right>a>div .name h3 { 92 | font-weight: normal;/*设置手机名称字体粗细*/ 93 | font-size: 14px;/*设置手机名称字体大小*/ 94 | text-align: center;/*设计手机名称字体对其方式*/ 95 | } 96 | 97 | .main .right>a>div .explain { 98 | margin: 0 auto; 99 | } 100 | 101 | .main .right>a>div .explain p { 102 | font-size: 12px; 103 | color: #C5C5C5; 104 | text-align: center; 105 | } 106 | 107 | .main .right>a>div .price { 108 | margin: 5px auto; 109 | } 110 | 111 | .main .right>a>div .price .newprice { 112 | display: inline-block; 113 | margin: 0 0 0 60px; 114 | } 115 | 116 | .main .right>a>div .price .newprice p { 117 | font-size: 14px; 118 | color: #FF7112; 119 | font-weight: 700; 120 | } 121 | 122 | .main .right>a>div .price .nowprice { 123 | display: inline-block; 124 | margin: 0 0 0 90px; 125 | } 126 | 127 | .main .right>a>div .price .nowprice p { 128 | font-size: 14px; 129 | color: #FF7112; 130 | font-weight: 700; 131 | } 132 | 133 | .main .right>a>div .price .oldprice { 134 | display: inline-block; 135 | margin: 0 0 0 5px; 136 | } 137 | 138 | .main .right>a>div .price .oldprice p { 139 | font-size: 14px; 140 | text-decoration: line-through; 141 | color: #C5C5C5; 142 | } 143 | 144 | /*footer*/ 145 | .footer { 146 | height: 300px; 147 | background-color: #ffffff; 148 | margin-top: 50px; 149 | } 150 | 151 | .footer .center { 152 | width: 1226px; 153 | margin: 0 auto; 154 | } 155 | 156 | .footer .zuo { 157 | width: 613px; 158 | margin-top: 30px; 159 | float: left; 160 | } 161 | 162 | .footer .zuo .ph { 163 | margin-top: 30px; 164 | } 165 | 166 | .footer .zuo .ph p { 167 | font-size: 12px; 168 | color: #666666; 169 | } 170 | 171 | .footer .zuo .btn { 172 | margin-top: 30px; 173 | } 174 | 175 | .footer .zuo .btn a { 176 | display: inline-block; 177 | width: 121px; 178 | height: 38px; 179 | font-size: 16px; 180 | font-weight: 700; 181 | color: #00a4ff; 182 | border: 1px solid #00a4ff;/*定义边框颜色*/ 183 | line-height: 35px; 184 | text-align: center; 185 | } 186 | 187 | .footer .you { 188 | width: 613px; 189 | float: right; 190 | } 191 | 192 | .footer .you div { 193 | float: right; 194 | width: 200px; 195 | margin-top: 60px; 196 | } 197 | 198 | .footer .you div dl dt { 199 | font-size: 16px; 200 | color: #333333; 201 | } 202 | 203 | .footer .you div dl dd { 204 | font-size: 12px; 205 | color: #333333; 206 | } 207 | 208 | .footer .you div dl a dd:hover { 209 | color: #f09f09; 210 | } -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/goods.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.Goods" %> 3 | <%@ page import="service.GoodsService" %> 4 | <%@ page import="service.impl.GoodsServiceImpl" %> 5 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 6 | 7 | 8 | 商品详情界面 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 51 | 52 | 53 | <% 54 | GoodsService goodsService = new GoodsServiceImpl(); 55 | People now_people = (People) session.getAttribute("now_people"); 56 | Goods goods = goodsService.find(Integer.parseInt(request.getParameter("goods_id"))); 57 | session.setAttribute("now_goods", goods);//将当前浏览商品保存至session,用于表单提交后servlet识别商品 58 | 59 | String info_additional = goods.getInfo_additional(); 60 | String info_coupon = info_additional.substring(0, info_additional.indexOf('/')); 61 | String info_instalment = info_additional.substring(info_additional.indexOf('/') + 1, info_additional.lastIndexOf('/')); 62 | String info_mark = info_additional.substring(info_additional.lastIndexOf('/') + 1, info_additional.length() - 1); 63 | %> 64 | 65 | 81 | 82 | 83 |
84 |
85 |

<%=goods.getName()%>

86 |
87 |
88 |
<%=goods.getInfo_detailed()%>
89 |
90 | 91 |
92 |
93 |
商品赠券
94 |
<%=info_coupon%>
95 |
96 |
97 |
分期免息
98 |
<%=info_instalment%>
99 |
100 |
101 |
赠送积分
102 |
<%=info_mark%>
103 |
104 | 105 |
106 |
107 |
108 |

价 格

109 |

¥<%=goods.getNew_price()%>.00

110 |
111 |
112 |

数 量

113 |
114 | 121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 131 |
132 |
133 |
134 |
135 | 136 | 137 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="util.CustomUtil" %> 3 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 4 | 5 | 6 | 登陆界面 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 51 | 52 | 53 | 74 | 75 |
76 |
77 |

欢迎来到登陆界面

78 |
79 | <% 80 | String login_error_info = null; 81 | 82 | if (session.getAttribute("login_error_info") != null) { 83 | login_error_info = (String) session.getAttribute("login_error_info"); 84 | 85 | out.print(login_error_info); 86 | 87 | CustomUtil.outPosition("yellow", "login.jsp"); 88 | CustomUtil.outParameter("yellow", "login_error_info", login_error_info); 89 | } 90 | %> 91 |
92 |

请按照输入框提示输入,当左侧标签全为绿色后点击登陆

93 |
94 |
95 | 96 |
97 | 98 | 99 |
100 | 101 |
102 |
103 | 104 |
105 | 106 |
107 | 108 |
109 |
110 | 111 |
112 | 113 |
114 | 115 |
116 | 117 |
118 |
119 |
120 |
121 | 122 |
123 |
124 |
125 |
126 |









127 |




128 | 129 | 192 |
193 | 194 | 195 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/loginCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 登陆成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |

登陆成功

33 |
34 |

恭喜您, 登陆成功, 1秒后自动跳转至主界面!🚀

35 |
36 |









37 |









38 |




39 | 40 | 41 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/logoutCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 注销成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | <% 29 | if (session.getAttribute("register_error_info") != null) { 30 | session.setAttribute("register_error_info", null); 31 | } 32 | if (session.getAttribute("error_people") != null) { 33 | session.setAttribute("error_people", null); 34 | } 35 | if (session.getAttribute("login_error_info") != null) { 36 | session.setAttribute("login_error_info", null); 37 | } 38 | if (session.getAttribute("now_people") != null) { 39 | session.setAttribute("now_people", null); 40 | } 41 | if (session.getAttribute("checkcode") != null) { 42 | session.setAttribute("checkcode", null); 43 | } 44 | if (session.getAttribute("now_goods") != null) { 45 | session.setAttribute("now_goods", null); 46 | } 47 | if (session.getAttribute("submit_info") != null) { 48 | session.setAttribute("submit_info", null); 49 | } 50 | 51 | if (session.getAttribute("orderIndexList") != null) { 52 | session.setAttribute("orderIndexList", null); 53 | } 54 | if (session.getAttribute("orderDetailHashmap") != null) { 55 | session.setAttribute("orderDetailHashmap", null); 56 | } 57 | %> 58 | 59 | 60 | 61 |
62 |
63 |

注销成功

64 |
65 |

注销成功, 1秒后自动跳转至主界面!🚀

66 |
67 |









68 |









69 |




70 | 71 | 72 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/order.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.OrderIndex" %> 3 | <%@ page import="service.OrderService" %> 4 | <%@ page import="service.impl.OrderServiceImpl" %> 5 | <%@ page import="java.util.List" %> 6 | <%@ page import="util.CustomUtil" %> 7 | <%@ page import="java.util.HashMap" %> 8 | <%@ page import="entity.OrderDetail" %> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 11 | 12 | 13 | 订单界面 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 53 | 54 | 61 | 62 | 63 | <% 64 | People now_people = (People) session.getAttribute("now_people"); 65 | %> 66 | 77 | <% 78 | OrderService orderService = new OrderServiceImpl(); 79 | 80 | People people = (People) session.getAttribute("now_people"); 81 | List orderIndexList = orderService.findAllByPersonId(people.getId()); 82 | HashMap> orderDetailHashmap = new HashMap<>(); 83 | for (OrderIndex o : orderIndexList) { 84 | orderDetailHashmap.put(o.getId(), orderService.findAllByOrderIndexId(o.getId())); 85 | } 86 | 87 | CustomUtil.outPosition("yellow", "order.jsp"); 88 | CustomUtil.outParameter("yellow", "orderIndexList", String.valueOf(orderIndexList)); 89 | CustomUtil.outParameter("yellow", "orderDetailHashmap", String.valueOf(orderDetailHashmap)); 90 | 91 | session.setAttribute("orderIndexList", orderIndexList); 92 | session.setAttribute("orderDetailHashmap", orderDetailHashmap); 93 | %> 94 |
95 |
96 |
97 |
98 |

⭐订单信息⭐

99 |
100 | 101 |
102 |

103 |

104 |
105 |
106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
商品编号商品数量商品总价
${detail.getGoods_name()}${detail.getNumber()}${detail.getPrice()}
120 |
121 |
122 |
123 |









124 |









125 |









126 | 127 | 128 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/register.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="util.CustomUtil" %> 2 | <%@ page import="entity.People" %> 3 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 4 | <% 5 | CustomUtil.outPosition("yellow", "register.jsp"); 6 | CustomUtil.outParameter("yellow", "request.getContextPath()", request.getContextPath()); 7 | CustomUtil.outParameter("yellow", "request.getRequestURL()", String.valueOf(request.getRequestURL())); 8 | %> 9 | 10 | 11 | 注册界面 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 56 | 57 | 58 | 79 | 80 |
81 |
82 |

欢迎来到注册界面

83 |
84 | <% 85 | String register_error_info = null; 86 | People people = new People(0, "", "", "", "", 0); 87 | String str_id = ""; 88 | 89 | if (session.getAttribute("register_error_info") != null) { 90 | register_error_info = (String) session.getAttribute("register_error_info"); 91 | people = (People) session.getAttribute("error_people"); 92 | 93 | out.print(register_error_info); 94 | 95 | CustomUtil.outPosition("yellow", "register.jsp"); 96 | CustomUtil.outParameter("yellow", "register_error_info", register_error_info); 97 | 98 | if (people.getId() != 0) { 99 | str_id = String.valueOf(people.getId()); 100 | } 101 | } 102 | %> 103 |
104 |

请严格按照输入框提示输入, 当左侧标签全为绿色后再点击注册!

105 |
106 |
107 | 108 |
109 | 110 |
111 | 112 |
113 |
114 | 115 |
116 | 117 |
118 | 119 |
120 |
121 | 122 |
123 | 124 |
125 | 126 |
127 |
128 | 129 |
130 | 131 |
132 | 133 |
134 |
135 | 136 |
137 | 138 |
139 | 140 |
141 |
142 | 143 |
144 | 145 |
146 | 147 |
148 |
149 | 150 |
151 | 152 |
153 | 154 |
155 | 156 |
157 |
158 |
159 |
160 | 161 |
162 |
163 |
164 |









165 |
166 | 298 | 299 | 300 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/registerCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 注册成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |

注册成功

33 |
34 |
35 |

恭喜您, 注册成功, 1秒后自动跳转至登陆界面!🚀

36 |
37 |









38 |









39 |




40 | 41 | 42 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/page/shopCar.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.Goods" %> 3 | <%@ page import="service.GoodsService" %> 4 | <%@ page import="service.impl.GoodsServiceImpl" %> 5 | <%@ page import="java.util.regex.Pattern" %> 6 | <%@ page import="java.util.regex.Matcher" %> 7 | <%@ page import="util.CustomUtil" %> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 购物车界面 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 84 | 85 | 86 | 89 | <% 90 | session.setAttribute("submit_info", null); 91 | People now_people = (People) session.getAttribute("now_people"); 92 | %> 93 | 94 | 110 | 111 |
112 |
113 |
图片
114 |
商品
115 |
单价
116 |
数量
117 |
小计
118 |
操作
119 |
120 | 121 | <% 122 | GoodsService goodsService = new GoodsServiceImpl(); 123 | Cookie cookies[] = request.getCookies(); 124 | Pattern pattern = Pattern.compile("[0-9]{3}");//通过正则表达式过滤cookie 125 | 126 | if (cookies != null) { 127 | for (int i = 0; i < cookies.length; i++) { 128 | if (pattern.matcher(cookies[i].getName()).matches()) { 129 | Goods goods = goodsService.find(Integer.parseInt(cookies[i].getName())); 130 | CustomUtil.outPosition("yellow", "shopCar.jsp"); 131 | CustomUtil.outParameter("yellow", "goods", goods.toString()); 132 | if (goods.getId() != 0) { 133 | out.println( 134 | "
" + 135 | "
" + 136 | "
" + 137 | "
" + goods.getName() + "
" + 138 | "
¥" + goods.getNew_price() + "
" + 139 | "
" + cookies[i].getValue() + "
" + 140 | "
" + goods.getNew_price() * Integer.parseInt(cookies[i].getValue()) + "
" + 141 | "" + 142 | "
" 143 | ); 144 | } 145 | } 146 | } 147 | } 148 | %> 149 |
150 |
151 |
152 | 153 |
154 |
155 | 156 |
157 |
158 |









159 |
160 | 161 | 162 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other0.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other1.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other2.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other3.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other4.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other5.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other6.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other7.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other8.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/other9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/other9.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone0.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone1.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone2.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone3.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone4.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone5.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone6.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone7.png -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/png/phone8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/artifacts/web_war_exploded/png/phone8.png -------------------------------------------------------------------------------- /out/production/web/dao/GoodsDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/GoodsDAO.class -------------------------------------------------------------------------------- /out/production/web/dao/OrderDetailDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/OrderDetailDAO.class -------------------------------------------------------------------------------- /out/production/web/dao/OrderIndexDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/OrderIndexDAO.class -------------------------------------------------------------------------------- /out/production/web/dao/PeopleDAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/PeopleDAO.class -------------------------------------------------------------------------------- /out/production/web/dao/impl/GoodsDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/impl/GoodsDAOImpl.class -------------------------------------------------------------------------------- /out/production/web/dao/impl/OrderDetailDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/impl/OrderDetailDAOImpl.class -------------------------------------------------------------------------------- /out/production/web/dao/impl/OrderIndexDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/impl/OrderIndexDAOImpl.class -------------------------------------------------------------------------------- /out/production/web/dao/impl/PeopleDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/dao/impl/PeopleDAOImpl.class -------------------------------------------------------------------------------- /out/production/web/entity/Goods.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/entity/Goods.class -------------------------------------------------------------------------------- /out/production/web/entity/OrderDetail.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/entity/OrderDetail.class -------------------------------------------------------------------------------- /out/production/web/entity/OrderIndex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/entity/OrderIndex.class -------------------------------------------------------------------------------- /out/production/web/entity/People.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/entity/People.class -------------------------------------------------------------------------------- /out/production/web/others/projectinfo.md: -------------------------------------------------------------------------------- 1 | # Session清单 2 | 1. `checkcode`:存储验证码,用于`register.jsp`与`login.jsp`显示。 3 | 2. `register_error_info`:注册失败原因,用于`register.jsp`回显。 4 | 3. `error_people`:注册失败的表单信息,用于`register.jsp`回填。 5 | 4. `login_error_info`:登录失败原因,用于`login.jsp`回显。 6 | 5. `now_people`:当前登录用户,在登录成功时创建,用于提取用户信息。 7 | 6. `now_goods`:当前浏览商品,用于表单提交后`GoodsServlet`识别商品。 8 | 7. `submit_info`:订单提交信息,用于`shopCar.jsp`回显。 9 | 8. `orderIndexList`:订单索引查询结果,用于`order.jsp`显示。 10 | 9. `orderDetailHashmap`:订单详情查询结果,用于`order.jsp`显示。 -------------------------------------------------------------------------------- /out/production/web/others/shoppingsystem.sql: -------------------------------------------------------------------------------- 1 | -- 删除数据库 2 | DROP DATABASE IF EXISTS shoppingsystem; 3 | 4 | -- 创建数据库 5 | CREATE DATABASE shoppingsystem CHARACTER SET utf8; 6 | 7 | -- 使用数据库 8 | USE shoppingsystem; 9 | 10 | -- 删除数据表 11 | DROP TABLE IF EXISTS `order_detail`; 12 | DROP TABLE IF EXISTS `order_index`; 13 | DROP TABLE IF EXISTS `people`; 14 | DROP TABLE IF EXISTS `goods`; 15 | 16 | -- 创建数据表 17 | # 1.创建用户信息表 18 | CREATE TABLE `people` ( 19 | `id` INT NOT NULL,/*用户编号*/ 20 | `password` VARCHAR(50),/*用户密码*/ 21 | `name` VARCHAR(50),/*用户姓名*/ 22 | `email` VARCHAR(50),/*用户邮箱*/ 23 | `address` VARCHAR(100),/*用户地址*/ 24 | `status` INT,/*用户状态*/ 25 | CONSTRAINT `people_pk_id` PRIMARY KEY (`id`)/* 用户编号作为主键 */ 26 | ) ENGINE = InnoDB; 27 | 28 | # 2.创建商品信息表 29 | CREATE TABLE `goods` ( 30 | `id` INT NOT NULL,/*商品编号*/ 31 | `name` VARCHAR(50),/*商品名称*/ 32 | `image` VARCHAR(50),/*商品图片*/ 33 | `old_price` INT,/*商品原价*/ 34 | `new_price` INT,/*商品现价*/ 35 | `info_brief` VARCHAR(100),/*商品简要信息*/ 36 | `info_detailed` VARCHAR(100),/*商品详细信息*/ 37 | `info_additional` VARCHAR(100),/*商品附加信息*/ 38 | `status` INT,/*商品状态*/ 39 | CONSTRAINT `goods_pk_id` PRIMARY KEY (`id`)/*商品编号作为主键*/ 40 | ) ENGINE = InnoDB; 41 | 42 | # 3.创建订单索引表/*存储一个用户的订单索引信息*/ 43 | CREATE TABLE `order_index` ( 44 | `id` INT NOT NULL AUTO_INCREMENT,/*订单编号*/ 45 | `person_id` INT NOT NULL,/*订单的属主的编号*/ 46 | `price` INT,/*订单总价*/ 47 | `address` VARCHAR(100),/*收货地址*/ 48 | `time` DATETIME,/*创建日期*/ 49 | `status` INT,/*订单状态*/ 50 | CONSTRAINT `order_index_pk_id` PRIMARY KEY (`id`),/*订单编号作为主键*/ 51 | CONSTRAINT `order_index_ibfk_person_id` FOREIGN KEY (`person_id`) REFERENCES `people` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*用户表用户编号作为外键*/ 52 | ) ENGINE = InnoDB AUTO_INCREMENT = 100;/*支持外键以及事务处理,主键从100开始自增*/ 53 | 54 | # 4.创建订单详情表/*存储所有用户的所有订单的详细信息*/ 55 | CREATE TABLE `order_detail` ( 56 | `order_index_id` INT NOT NULL,/*所属订单的编号*/ 57 | `goods_id` INT NOT NULL,/*所含商品的编号*/ 58 | `goods_name` VARCHAR(50),/*所含商品的名称*/ 59 | `number` INT,/*每种商品的数量*/ 60 | `price` INT,/*每种商品的总价*/ 61 | CONSTRAINT `order_detail_pk_order_index_id_goods_id` PRIMARY KEY (`order_index_id`, `goods_id`),/*商品编号与所属订单编号作为联合主键 */ 62 | CONSTRAINT `order_detail_ibfk_order_index_id` FOREIGN KEY (`order_index_id`) REFERENCES `order_index` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,/*订单索引表订单编号作为外键*/ 63 | CONSTRAINT `order_detail_ibfk_goods_id` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*商品表商品编号作为外键*/ 64 | ) ENGINE = InnoDB;/*支持外键以及事务处理*/ 65 | 66 | -- 编写测试数据 67 | # 1.增加用户信息 68 | INSERT INTO `people` VALUES (2022101, '123456', '阿卡丽', '534953576@qq.com', '均衡教派', 0); 69 | INSERT INTO `people` VALUES (2022102, '123456', '琪亚娜', '534953576@qq.com', '以绪塔尔', 0); 70 | INSERT INTO `people` VALUES (2022103, '123456', '艾瑞利娅', '534953576@qq.com', '艾欧尼亚', 0); 71 | INSERT INTO `people` VALUES (2022104, '123456', '卡莎', '534953576@qq.com', '虚空之地', 0); 72 | INSERT INTO `people` VALUES (2022105, '123456', '霞', '534953576@qq.com', '瓦斯塔亚', 0); 73 | INSERT INTO `people` VALUES (2022106, '123456', '洛', '534953576@qq.com', '瓦斯塔亚', 0); 74 | 75 | # 2.增加商品数据 76 | INSERT INTO `goods` VALUES (101, 'HUAWEI P40 Pro 5G', './png/phone1.png', 6300, 5988, '享三期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 77 | INSERT INTO `goods` VALUES (102, 'HUAWEI P40 Pro+ 5G', './png/phone2.png', 8000, 7988, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 78 | INSERT INTO `goods` VALUES (103, '荣耀30', './png/phone3.png', 3500, 3298, '50倍超稳远摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 79 | INSERT INTO `goods` VALUES (104, 'HUAWEI Mate 30E Pro 5G', './png/phone4.png', 5300, 5299, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 80 | INSERT INTO `goods` VALUES (105, 'HUAWEI Mate 40 Pro+ 5G','./png/phone5.png', 9000, 8999, '享多重权益', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 81 | INSERT INTO `goods` VALUES (106, '荣耀Play4', './png/phone6.png', 2000, 1999, '6400万锐利四摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 82 | INSERT INTO `goods` VALUES (107, '华为畅想20 Plus', './png/phone7.png', 2500, 2299 ,'购机赠耳机', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 83 | INSERT INTO `goods` VALUES (108, '荣耀X10 Max', './png/phone8.png', 2100, 2099, '护眼阳光屏', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 84 | 85 | # 3.增加订单索引数据 86 | # INSERT INTO `order_index` VALUES (0, 2022101, 13976, '均衡教派', now(), 0); 87 | # INSERT INTO `order_index` VALUES (0, 2022101, 5988, '均衡教派', now(), 0); 88 | # INSERT INTO `order_index` VALUES (0, 2022101, 7988, '均衡教派', now(), 0); 89 | 90 | # 4.增加订单详情数据 91 | # INSERT INTO `order_detail` VALUES (100, 101, 'HUAWEI P40 Pro 5G', 1, 5988); 92 | # INSERT INTO `order_detail` VALUES (100, 102, 'HUAWEI P40 Pro+ 5G', 1, 7988); 93 | 94 | -- 提交事务 95 | COMMIT; -------------------------------------------------------------------------------- /out/production/web/service/GoodsService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/GoodsService.class -------------------------------------------------------------------------------- /out/production/web/service/OrderService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/OrderService.class -------------------------------------------------------------------------------- /out/production/web/service/PeopleService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/PeopleService.class -------------------------------------------------------------------------------- /out/production/web/service/impl/GoodsServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/impl/GoodsServiceImpl.class -------------------------------------------------------------------------------- /out/production/web/service/impl/OrderServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/impl/OrderServiceImpl.class -------------------------------------------------------------------------------- /out/production/web/service/impl/PeopleServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/service/impl/PeopleServiceImpl.class -------------------------------------------------------------------------------- /out/production/web/servlet/CheckCodeServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/servlet/CheckCodeServlet.class -------------------------------------------------------------------------------- /out/production/web/servlet/GoodsServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/servlet/GoodsServlet.class -------------------------------------------------------------------------------- /out/production/web/servlet/OrderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/servlet/OrderServlet.class -------------------------------------------------------------------------------- /out/production/web/servlet/PeopleServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/servlet/PeopleServlet.class -------------------------------------------------------------------------------- /out/production/web/test/GoodsDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/test/GoodsDAOImplTest.class -------------------------------------------------------------------------------- /out/production/web/test/JdbcUtilTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/test/JdbcUtilTest.class -------------------------------------------------------------------------------- /out/production/web/test/OrderDetailDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/test/OrderDetailDAOImplTest.class -------------------------------------------------------------------------------- /out/production/web/test/OrderIndexDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/test/OrderIndexDAOImplTest.class -------------------------------------------------------------------------------- /out/production/web/test/PeopleDAOImplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/test/PeopleDAOImplTest.class -------------------------------------------------------------------------------- /out/production/web/util/CustomUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/util/CustomUtil.class -------------------------------------------------------------------------------- /out/production/web/util/JdbcUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/out/production/web/util/JdbcUtil.class -------------------------------------------------------------------------------- /web/src/dao/GoodsDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import entity.Goods; 4 | 5 | public interface GoodsDAO { 6 | 7 | /** 8 | * 根据商品编号查询商品 9 | * @return 查询到的商品实体 10 | */ 11 | public abstract Goods findById(int id); 12 | } -------------------------------------------------------------------------------- /web/src/dao/OrderDetailDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import entity.OrderDetail; 4 | 5 | import java.util.List; 6 | 7 | public interface OrderDetailDAO { 8 | 9 | /** 10 | * 插入订单详情信息 11 | * @return 插入行数 12 | */ 13 | public abstract int doInsert(int order_index_id, int goods_id, String goods_name, int number, int price); 14 | 15 | /** 16 | * 根据订单编号和商品编号修改订单详情信息中的数量与价格 17 | * @return 修改行数 18 | */ 19 | public abstract int doUpdate(int order_index_id, int goods_id, int number, int price); 20 | 21 | /** 22 | * 根据订单编号查询订单详情信息 23 | * @return 该订单的全部订单详情实体的数组 24 | */ 25 | public abstract List findAllById(int order_index_id); 26 | } 27 | -------------------------------------------------------------------------------- /web/src/dao/OrderIndexDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import entity.OrderIndex; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | public interface OrderIndexDAO { 9 | 10 | /** 11 | * 插入订单索引数据 12 | * 订单编号自动生成 13 | * @return 插入数据生成的主键值 14 | */ 15 | public abstract int doInsert(int person_id, int price, String address, Date date, int status); 16 | 17 | public abstract int doUpdate(int id, int person_id, int price, String address, Date date, int status); 18 | 19 | /** 20 | * 根据订单编号查找订单 21 | * @return 订单索引实体 22 | */ 23 | public abstract OrderIndex findById(int id); 24 | 25 | /** 26 | * 根据用户编号查找订单 27 | * @return 该用户的全部订单索引实体的数组 28 | */ 29 | public abstract List findAllById(int person_id); 30 | } 31 | -------------------------------------------------------------------------------- /web/src/dao/PeopleDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import entity.People; 4 | 5 | public interface PeopleDAO { 6 | /** 7 | * 插入用户数据 8 | * @return 插入行数 9 | */ 10 | public abstract int doInsert(int id, String password, String name, String email, String address, int status); 11 | 12 | public abstract int doDelete(int id, String password); 13 | 14 | public abstract int doUpdate(int id, String password, String name, String email, String address, int status); 15 | 16 | /** 17 | * 根据用户编号和密码查询用户数据 18 | * @return 查询到的用户实体 19 | */ 20 | public abstract People findByLogin(int id, String password); 21 | 22 | /** 23 | * 根据用户编号查询用户数据 24 | * @return 查询到的用户实体 25 | */ 26 | public abstract People findById(int id); 27 | } 28 | -------------------------------------------------------------------------------- /web/src/dao/impl/GoodsDAOImpl.java: -------------------------------------------------------------------------------- 1 | package dao.impl; 2 | 3 | import dao.GoodsDAO; 4 | import entity.Goods; 5 | import util.CustomUtil; 6 | import util.JdbcUtil; 7 | 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | 13 | public class GoodsDAOImpl implements GoodsDAO { 14 | 15 | private Connection connection; 16 | private PreparedStatement preparedStatement; 17 | private ResultSet resultSet; 18 | 19 | @Override 20 | public Goods findById(int id) { 21 | Goods goods = new Goods(); 22 | String sql = "select * from `goods` where `id` = '" + id + "';"; 23 | 24 | connection = JdbcUtil.getConnection(); 25 | try { 26 | preparedStatement = connection.prepareStatement(sql); 27 | resultSet = preparedStatement.executeQuery(); 28 | if (resultSet.next()) { 29 | goods.setId(resultSet.getInt(1)); 30 | goods.setName(resultSet.getString(2)); 31 | goods.setImage(resultSet.getString(3)); 32 | goods.setOld_price(resultSet.getInt(4)); 33 | goods.setNew_price(resultSet.getInt(5)); 34 | goods.setInfo_brief(resultSet.getString(6)); 35 | goods.setInfo_detailed(resultSet.getString(7)); 36 | goods.setInfo_additional(resultSet.getString(8)); 37 | goods.setStatus(resultSet.getInt(9)); 38 | } 39 | } catch (SQLException throwables) { 40 | throwables.printStackTrace(); 41 | } finally { 42 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 43 | } 44 | CustomUtil.outPosition("blue", "GoodsDAOImpl.findGoods()"); 45 | CustomUtil.outParameter("blue", "sql", sql); 46 | CustomUtil.outParameter("blue", "goods", goods.toString()); 47 | 48 | return goods; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /web/src/dao/impl/OrderDetailDAOImpl.java: -------------------------------------------------------------------------------- 1 | package dao.impl; 2 | 3 | import dao.OrderDetailDAO; 4 | import entity.OrderDetail; 5 | import util.CustomUtil; 6 | import util.JdbcUtil; 7 | 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class OrderDetailDAOImpl implements OrderDetailDAO { 16 | 17 | private Connection connection; 18 | private PreparedStatement preparedStatement; 19 | private ResultSet resultSet; 20 | 21 | @Override 22 | public int doInsert(int order_index_id, int goods_id, String goods_name, int number, int price) { 23 | int result = 0; 24 | String sql = "insert into `order_detail` VALUES (" + 25 | order_index_id + 26 | ", " + goods_id + 27 | ", '" + goods_name + 28 | "', " + number + 29 | ", " + price + 30 | ");"; 31 | 32 | connection = JdbcUtil.getConnection(); 33 | try { 34 | preparedStatement = connection.prepareStatement(sql); 35 | result = preparedStatement.executeUpdate(); 36 | } catch (SQLException throwables) { 37 | throwables.printStackTrace(); 38 | } finally { 39 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 40 | } 41 | CustomUtil.outPosition("blue", "OrderDetailDAOImpl.insertOrderDetail()"); 42 | CustomUtil.outParameter("blue", "sql", sql); 43 | CustomUtil.outParameter("blue", "result", String.valueOf(result)); 44 | 45 | return result; 46 | } 47 | 48 | @Override 49 | public int doUpdate(int order_index_id, int goods_id, int number, int price) { 50 | int result = 0; 51 | String sql = "update `order_detail`" + 52 | " set number = " + number + 53 | ", price = " + price + 54 | " where order_index_id = " + order_index_id + 55 | " and goods_id = " + goods_id + 56 | ";"; 57 | 58 | connection = JdbcUtil.getConnection(); 59 | try { 60 | preparedStatement = connection.prepareStatement(sql); 61 | result = preparedStatement.executeUpdate(); 62 | } catch (SQLException throwables) { 63 | throwables.printStackTrace(); 64 | } finally { 65 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 66 | } 67 | CustomUtil.outPosition("blue", "OrderDetailDAOImpl.updateOrderDetail()"); 68 | CustomUtil.outParameter("blue", "sql", sql); 69 | CustomUtil.outParameter("blue", "result", String.valueOf(result)); 70 | 71 | return result; 72 | } 73 | 74 | @Override 75 | public List findAllById(int order_index_id) { 76 | List orderDetailList = new ArrayList<>(); 77 | String sql = "select * from order_detail where order_index_id = " + order_index_id + ";"; 78 | 79 | connection = JdbcUtil.getConnection(); 80 | try { 81 | preparedStatement = connection.prepareStatement(sql); 82 | resultSet = preparedStatement.executeQuery(); 83 | while (resultSet.next()) { 84 | OrderDetail orderDetail = new OrderDetail(); 85 | orderDetail.setOrder_index_id(resultSet.getInt(1)); 86 | orderDetail.setGoods_id(resultSet.getInt(2)); 87 | orderDetail.setGoods_name(resultSet.getString(3)); 88 | orderDetail.setNumber(resultSet.getInt(4)); 89 | orderDetail.setPrice(resultSet.getInt(5)); 90 | orderDetailList.add(orderDetail); 91 | } 92 | } catch (SQLException throwables) { 93 | throwables.printStackTrace(); 94 | } finally { 95 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 96 | } 97 | CustomUtil.outPosition("blue", "OrderDetailDAOImpl.findAllOrderDetail()"); 98 | CustomUtil.outParameter("blue", "sql", sql); 99 | CustomUtil.outParameter("blue", "orderDetailList.size()", String.valueOf(orderDetailList.size())); 100 | 101 | return orderDetailList; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /web/src/dao/impl/OrderIndexDAOImpl.java: -------------------------------------------------------------------------------- 1 | package dao.impl; 2 | 3 | import dao.OrderIndexDAO; 4 | import entity.OrderIndex; 5 | import util.CustomUtil; 6 | import util.JdbcUtil; 7 | 8 | import java.sql.*; 9 | import java.util.ArrayList; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | public class OrderIndexDAOImpl implements OrderIndexDAO { 14 | 15 | private Connection connection; 16 | private PreparedStatement preparedStatement; 17 | private ResultSet resultSet; 18 | 19 | @Override 20 | public int doInsert(int person_id, int price, String address, Date date, int status) { 21 | int result = 0; 22 | String sql = "INSERT INTO `order_index` VALUES (" + 23 | "0" + 24 | ", " + person_id + 25 | ", " + price + 26 | ", '" + address + 27 | "', '" + new java.sql.Timestamp(date.getTime()) + 28 | "', " + status + 29 | ");"; 30 | 31 | connection = JdbcUtil.getConnection(); 32 | try { 33 | preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);//获取返回的id主键 34 | preparedStatement.executeUpdate(); 35 | resultSet = preparedStatement.getGeneratedKeys(); 36 | if (resultSet.next()) { 37 | result = resultSet.getInt(1); 38 | } 39 | } catch (SQLException throwables) { 40 | throwables.printStackTrace(); 41 | } finally { 42 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 43 | } 44 | CustomUtil.outPosition("blue", "OrderIndexDAOImpl.insertOrder()"); 45 | CustomUtil.outParameter("blue", "sql", sql); 46 | CustomUtil.outParameter("blue", "result", String.valueOf(result)); 47 | 48 | return result; 49 | } 50 | 51 | @Override 52 | public int doUpdate(int id, int person_id, int price, String address, Date date, int status) { 53 | return 0; 54 | } 55 | 56 | @Override 57 | public OrderIndex findById(int id) { 58 | OrderIndex orderIndex = new OrderIndex(); 59 | String sql = "select * from `order_index` where `id` = " + id + ";"; 60 | 61 | connection = JdbcUtil.getConnection(); 62 | try { 63 | preparedStatement = connection.prepareStatement(sql); 64 | resultSet = preparedStatement.executeQuery(); 65 | if (resultSet.next()) { 66 | orderIndex.setId(resultSet.getInt(1)); 67 | orderIndex.setPerson_id(resultSet.getInt(2)); 68 | orderIndex.setPrice(resultSet.getInt(3)); 69 | orderIndex.setAddress(resultSet.getString(4)); 70 | orderIndex.setDate(resultSet.getTimestamp(5)); 71 | orderIndex.setStatus((resultSet.getInt(6))); 72 | } 73 | } catch (SQLException throwables) { 74 | throwables.printStackTrace(); 75 | } finally { 76 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 77 | } 78 | CustomUtil.outPosition("blue", "OrderIndexDAOImpl.findOrderIndex()"); 79 | CustomUtil.outParameter("blue", "sql", sql); 80 | CustomUtil.outParameter("blue", "orderIndex", orderIndex.toString()); 81 | 82 | return orderIndex; 83 | } 84 | 85 | @Override 86 | public List findAllById(int person_id) { 87 | List orderIndexList = new ArrayList<>(); 88 | String sql = "select * from order_index where person_id = " + person_id + ";"; 89 | 90 | connection = JdbcUtil.getConnection(); 91 | try { 92 | preparedStatement = connection.prepareStatement(sql); 93 | resultSet = preparedStatement.executeQuery(); 94 | while (resultSet.next()) { 95 | OrderIndex orderIndex = new OrderIndex(); 96 | orderIndex.setId(resultSet.getInt(1)); 97 | orderIndex.setPerson_id(resultSet.getInt(2)); 98 | orderIndex.setPrice(resultSet.getInt(3)); 99 | orderIndex.setAddress(resultSet.getString(4)); 100 | orderIndex.setDate(resultSet.getTimestamp(5)); 101 | orderIndex.setStatus((resultSet.getInt(6))); 102 | orderIndexList.add(orderIndex); 103 | } 104 | } catch (SQLException throwables) { 105 | throwables.printStackTrace(); 106 | } finally { 107 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 108 | } 109 | CustomUtil.outPosition("blue", "OrderIndexDAOImpl.findAllOrderIndex()"); 110 | CustomUtil.outParameter("blue", "sql", sql); 111 | CustomUtil.outParameter("blue", "orderIndexList.size()", String.valueOf(orderIndexList.size())); 112 | 113 | return orderIndexList; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /web/src/dao/impl/PeopleDAOImpl.java: -------------------------------------------------------------------------------- 1 | package dao.impl; 2 | 3 | import dao.PeopleDAO; 4 | import entity.People; 5 | import util.CustomUtil; 6 | import util.JdbcUtil; 7 | 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | 13 | public class PeopleDAOImpl implements PeopleDAO { 14 | 15 | private Connection connection; 16 | private PreparedStatement preparedStatement; 17 | private ResultSet resultSet; 18 | 19 | @Override 20 | public int doInsert(int id, String password, String name, String email, String address, int status) { 21 | int result = 0; 22 | String sql = "INSERT INTO `people` VALUES (" + 23 | id + 24 | ", '" + password + 25 | "', '" + name + 26 | "', '" + email + 27 | "', '" + address + 28 | "', '" + status + 29 | "');"; 30 | 31 | connection = JdbcUtil.getConnection(); 32 | try { 33 | preparedStatement = connection.prepareStatement(sql); 34 | result = preparedStatement.executeUpdate(); 35 | } catch (SQLException throwables) { 36 | throwables.printStackTrace(); 37 | } finally { 38 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 39 | } 40 | CustomUtil.outPosition("blue", "PeopleDAOImpl.doInsert()"); 41 | CustomUtil.outParameter("blue", "sql", sql); 42 | CustomUtil.outParameter("blue", "result", String.valueOf(result)); 43 | 44 | return result; 45 | } 46 | 47 | @Override 48 | public int doDelete(int id, String password) { 49 | return 0; 50 | } 51 | 52 | @Override 53 | public int doUpdate(int id, String password, String name, String email, String address, int status) { 54 | return 0; 55 | } 56 | 57 | @Override 58 | public People findByLogin(int id, String password) { 59 | People people = new People(); 60 | String sql = "select * from `people` where `id` = '" + id + "' and password = '" + password + "';"; 61 | 62 | connection = JdbcUtil.getConnection(); 63 | try { 64 | preparedStatement = connection.prepareStatement(sql); 65 | resultSet = preparedStatement.executeQuery(); 66 | if (resultSet.next()) { 67 | people.setId(resultSet.getInt(1)); 68 | people.setPassword(resultSet.getString(2)); 69 | people.setName(resultSet.getString(3)); 70 | people.setEmail(resultSet.getString(4)); 71 | people.setAddress(resultSet.getString(5)); 72 | people.setStatus(resultSet.getInt(6)); 73 | } 74 | } catch (SQLException throwables) { 75 | throwables.printStackTrace(); 76 | } finally { 77 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 78 | } 79 | CustomUtil.outPosition("blue", "PeopleDAOImpl.findByLogin()"); 80 | CustomUtil.outParameter("blue", "sql", sql); 81 | CustomUtil.outParameter("blue", "people", people.toString()); 82 | 83 | return people; 84 | } 85 | 86 | public People findById(int id) { 87 | People people = new People(); 88 | String sql = "select * from `people` where `id` = '" + id + "';"; 89 | 90 | CustomUtil.outPosition("blue", "PeopleDaoImpl.findById()"); 91 | CustomUtil.outParameter("blue", "id", String.valueOf(id)); 92 | 93 | connection = JdbcUtil.getConnection(); 94 | try { 95 | preparedStatement = connection.prepareStatement(sql); 96 | resultSet = preparedStatement.executeQuery(); 97 | if (resultSet.next()) { 98 | people.setId(resultSet.getInt(1)); 99 | people.setPassword(resultSet.getString(2)); 100 | people.setName(resultSet.getString(3)); 101 | people.setEmail(resultSet.getString(4)); 102 | people.setAddress(resultSet.getString(5)); 103 | people.setStatus(resultSet.getInt(6)); 104 | } 105 | } catch (SQLException throwables) { 106 | throwables.printStackTrace(); 107 | } finally { 108 | JdbcUtil.closeAll(connection, preparedStatement, resultSet); 109 | } 110 | 111 | CustomUtil.outPosition("blue", "PeopleDAOImpl.findById()"); 112 | CustomUtil.outParameter("blue", "sql", sql); 113 | CustomUtil.outParameter("blue", "people", people.toString()); 114 | 115 | return people; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /web/src/entity/Goods.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Goods { 4 | 5 | private int id;//商品编号 6 | private String name;//商品名称 7 | private String image;//商品图片 8 | private int old_price;//商品原价 9 | private int new_price;//商品现价 10 | private String info_brief;//商品简要信息 11 | private String info_detailed;//商品详细信息 12 | private String info_additional;//商品附加信息 13 | private int status;//商品状态 14 | 15 | public Goods() { 16 | super(); 17 | } 18 | 19 | public Goods(int id, String name, String image, int old_price, int new_price, String info_brief, String info_detailed, String info_additional, int status) { 20 | this.id = id; 21 | this.name = name; 22 | this.image = image; 23 | this.old_price = old_price; 24 | this.new_price = new_price; 25 | this.info_brief = info_brief; 26 | this.info_detailed = info_detailed; 27 | this.info_additional = info_additional; 28 | this.status = status; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Goods{" + 34 | "id=" + id + 35 | ", name='" + name + '\'' + 36 | ", image='" + image + '\'' + 37 | ", old_price=" + old_price + 38 | ", new_price=" + new_price + 39 | ", info_brief='" + info_brief + '\'' + 40 | ", info_detailed='" + info_detailed + '\'' + 41 | ", info_additional='" + info_additional + '\'' + 42 | ", status=" + status + 43 | '}'; 44 | } 45 | 46 | public int getId() { 47 | return id; 48 | } 49 | 50 | public void setId(int id) { 51 | this.id = id; 52 | } 53 | 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public String getImage() { 63 | return image; 64 | } 65 | 66 | public void setImage(String image) { 67 | this.image = image; 68 | } 69 | 70 | public int getOld_price() { 71 | return old_price; 72 | } 73 | 74 | public void setOld_price(int old_price) { 75 | this.old_price = old_price; 76 | } 77 | 78 | public int getNew_price() { 79 | return new_price; 80 | } 81 | 82 | public void setNew_price(int new_price) { 83 | this.new_price = new_price; 84 | } 85 | 86 | public String getInfo_brief() { 87 | return info_brief; 88 | } 89 | 90 | public void setInfo_brief(String info_brief) { 91 | this.info_brief = info_brief; 92 | } 93 | 94 | public String getInfo_detailed() { 95 | return info_detailed; 96 | } 97 | 98 | public void setInfo_detailed(String info_detailed) { 99 | this.info_detailed = info_detailed; 100 | } 101 | 102 | public String getInfo_additional() { 103 | return info_additional; 104 | } 105 | 106 | public void setInfo_additional(String info_additional) { 107 | this.info_additional = info_additional; 108 | } 109 | 110 | public int getStatus() { 111 | return status; 112 | } 113 | 114 | public void setStatus(int status) { 115 | this.status = status; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /web/src/entity/OrderDetail.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class OrderDetail { 4 | 5 | private int order_index_id;//所属订单的编号 6 | private int goods_id;//商品的编号 7 | private String goods_name;//商品的名称 8 | private int number;//每种商品的数量 9 | private int price;//每种商品的总价 10 | 11 | public OrderDetail() { 12 | super(); 13 | } 14 | 15 | public OrderDetail(int order_index_id, int goods_id, String goods_name, int number, int price) { 16 | this.order_index_id = order_index_id; 17 | this.goods_id = goods_id; 18 | this.goods_name = goods_name; 19 | this.number = number; 20 | this.price = price; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "OrderDetail{" + 26 | "order_index_id=" + order_index_id + 27 | ", goods_id=" + goods_id + 28 | ", goods_name='" + goods_name + '\'' + 29 | ", number=" + number + 30 | ", price=" + price + 31 | '}'; 32 | } 33 | 34 | public int getOrder_index_id() { 35 | return order_index_id; 36 | } 37 | 38 | public void setOrder_index_id(int order_index_id) { 39 | this.order_index_id = order_index_id; 40 | } 41 | 42 | public int getGoods_id() { 43 | return goods_id; 44 | } 45 | 46 | public void setGoods_id(int goods_id) { 47 | this.goods_id = goods_id; 48 | } 49 | 50 | public String getGoods_name() { 51 | return goods_name; 52 | } 53 | 54 | public void setGoods_name(String goods_name) { 55 | this.goods_name = goods_name; 56 | } 57 | 58 | public int getNumber() { 59 | return number; 60 | } 61 | 62 | public void setNumber(int number) { 63 | this.number = number; 64 | } 65 | 66 | public int getPrice() { 67 | return price; 68 | } 69 | 70 | public void setPrice(int price) { 71 | this.price = price; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /web/src/entity/OrderIndex.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import java.util.Date; 4 | 5 | public class OrderIndex { 6 | 7 | private int id;//订单编号 8 | private int person_id;//订单的属主的编号 9 | private int price;//订单总价 10 | private String address;//收获地址 11 | private Date date;//创建日期 12 | private int status;//订单状态 13 | 14 | public OrderIndex() { 15 | super(); 16 | } 17 | 18 | public OrderIndex(int id, int person_id, int price, String address, Date date, int status) { 19 | this.id = id; 20 | this.person_id = person_id; 21 | this.price = price; 22 | this.address = address; 23 | this.date = date; 24 | this.status = status; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "OrderIndex{" + 30 | "id=" + id + 31 | ", person_id=" + person_id + 32 | ", price=" + price + 33 | ", address='" + address + '\'' + 34 | ", date=" + date + 35 | ", status=" + status + 36 | '}'; 37 | } 38 | 39 | public int getId() { 40 | return id; 41 | } 42 | 43 | public void setId(int id) { 44 | this.id = id; 45 | } 46 | 47 | public int getPerson_id() { 48 | return person_id; 49 | } 50 | 51 | public void setPerson_id(int person_id) { 52 | this.person_id = person_id; 53 | } 54 | 55 | public int getPrice() { 56 | return price; 57 | } 58 | 59 | public void setPrice(int price) { 60 | this.price = price; 61 | } 62 | 63 | public String getAddress() { 64 | return address; 65 | } 66 | 67 | public void setAddress(String address) { 68 | this.address = address; 69 | } 70 | 71 | public Date getDate() { 72 | return date; 73 | } 74 | 75 | public void setDate(Date date) { 76 | this.date = date; 77 | } 78 | 79 | public int getStatus() { 80 | return status; 81 | } 82 | 83 | public void setStatus(int status) { 84 | this.status = status; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /web/src/entity/People.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class People { 4 | 5 | private int id;//用户编号 6 | private String password;//用户密码 7 | private String name;//用户姓名 8 | private String email;//用户邮箱 9 | private String address;//用户地址 10 | private int status;//用户状态 11 | 12 | public People() { 13 | super(); 14 | } 15 | 16 | public People(int id, String password, String name, String email, String address, int status) { 17 | this.id = id; 18 | this.password = password; 19 | this.name = name; 20 | this.email = email; 21 | this.address = address; 22 | this.status = status; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "People{" + 28 | "id=" + id + 29 | ", password='" + password + '\'' + 30 | ", name='" + name + '\'' + 31 | ", email='" + email + '\'' + 32 | ", address='" + address + '\'' + 33 | ", status=" + status + 34 | '}'; 35 | } 36 | 37 | public int getId() { 38 | return id; 39 | } 40 | 41 | public void setId(int id) { 42 | this.id = id; 43 | } 44 | 45 | public String getPassword() { 46 | return password; 47 | } 48 | 49 | public void setPassword(String password) { 50 | this.password = password; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public String getEmail() { 62 | return email; 63 | } 64 | 65 | public void setEmail(String email) { 66 | this.email = email; 67 | } 68 | 69 | public String getAddress() { 70 | return address; 71 | } 72 | 73 | public void setAddress(String address) { 74 | this.address = address; 75 | } 76 | 77 | public int getStatus() { 78 | return status; 79 | } 80 | 81 | public void setStatus(int status) { 82 | this.status = status; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /web/src/service/GoodsService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import entity.Goods; 4 | 5 | public interface GoodsService { 6 | 7 | /** 8 | * 根据id查找商品 9 | * @return 查询成功返回目标实体,失败返回{0, null, null, 0, 0, null, null, null, 0} 10 | */ 11 | public abstract Goods find(int id); 12 | } 13 | -------------------------------------------------------------------------------- /web/src/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import entity.OrderDetail; 4 | import entity.OrderIndex; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderService { 9 | 10 | /** 11 | * 插入订单索引信息 12 | * @return 13 | */ 14 | public abstract int addOrderIndex(OrderIndex orderIndex); 15 | 16 | /** 17 | * 插入订单详情信息 18 | * @return 19 | */ 20 | public abstract boolean addOrderDetail(OrderDetail orderDetail); 21 | 22 | /** 23 | * 查找用户的所有订单 24 | * @return 25 | */ 26 | public abstract List findAllByPersonId(int person_id); 27 | 28 | /** 29 | * 查找订单的所有信息 30 | * @return 31 | */ 32 | public abstract List findAllByOrderIndexId(int order_index_id); 33 | } 34 | -------------------------------------------------------------------------------- /web/src/service/PeopleService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import entity.People; 4 | 5 | public interface PeopleService { 6 | 7 | /** 8 | * 用户注册 9 | * @return 0:注册成功,1:重复注册,2:其他原因 10 | */ 11 | public abstract int register(People people); 12 | 13 | /** 14 | * 用户登录 15 | * @return true:注册成功,false:注册失败 16 | */ 17 | public abstract boolean login(People people); 18 | 19 | /** 20 | * 根据id查找用户 21 | * @return 查询成功返回目标实体,失败返回{0, null, null, null, null, 0} 22 | */ 23 | public abstract People find(int id); 24 | 25 | public abstract boolean alter(People people); 26 | } 27 | -------------------------------------------------------------------------------- /web/src/service/impl/GoodsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service.impl; 2 | 3 | import dao.GoodsDAO; 4 | import dao.impl.GoodsDAOImpl; 5 | import entity.Goods; 6 | import service.GoodsService; 7 | 8 | public class GoodsServiceImpl implements GoodsService { 9 | 10 | private GoodsDAO goodsDAO = new GoodsDAOImpl(); 11 | 12 | @Override 13 | public Goods find(int id) { 14 | return goodsDAO.findById(id); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /web/src/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service.impl; 2 | 3 | import dao.OrderDetailDAO; 4 | import dao.OrderIndexDAO; 5 | import dao.impl.OrderDetailDAOImpl; 6 | import dao.impl.OrderIndexDAOImpl; 7 | import entity.OrderDetail; 8 | import entity.OrderIndex; 9 | import service.OrderService; 10 | 11 | import java.util.List; 12 | 13 | public class OrderServiceImpl implements OrderService { 14 | 15 | OrderIndexDAO orderIndexDAO = new OrderIndexDAOImpl(); 16 | OrderDetailDAO orderDetailDAO = new OrderDetailDAOImpl(); 17 | 18 | @Override 19 | public int addOrderIndex(OrderIndex orderIndex) { 20 | return orderIndexDAO.doInsert(orderIndex.getPerson_id(), orderIndex.getPrice(), 21 | orderIndex.getAddress(), orderIndex.getDate(), orderIndex.getStatus()); 22 | } 23 | 24 | @Override 25 | public boolean addOrderDetail(OrderDetail orderDetail) { 26 | if (orderDetailDAO.doInsert(orderDetail.getOrder_index_id(), orderDetail.getGoods_id(), 27 | orderDetail.getGoods_name(), orderDetail.getNumber(), orderDetail.getPrice()) == 1) 28 | return true; 29 | return false; 30 | } 31 | 32 | @Override 33 | public List findAllByPersonId(int person_id) { 34 | return orderIndexDAO.findAllById(person_id); 35 | } 36 | 37 | @Override 38 | public List findAllByOrderIndexId(int order_index_id) { 39 | return orderDetailDAO.findAllById(order_index_id); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /web/src/service/impl/PeopleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service.impl; 2 | 3 | import dao.PeopleDAO; 4 | import dao.impl.PeopleDAOImpl; 5 | import entity.People; 6 | import service.PeopleService; 7 | import util.CustomUtil; 8 | 9 | public class PeopleServiceImpl implements PeopleService { 10 | 11 | private PeopleDAO peopleDAO = new PeopleDAOImpl();//不实例化会导致空指针异常 12 | 13 | @Override 14 | public int register(People people) { 15 | CustomUtil.outPosition("red", "PeopleServiceImpl.register()"); 16 | CustomUtil.outParameter("red", "people", people.toString()); 17 | 18 | if (peopleDAO.findById(people.getId()).getId() == 0) { 19 | if (peopleDAO.doInsert( 20 | people.getId(), people.getPassword(), people.getName(), 21 | people.getEmail(), people.getAddress(), people.getStatus()) == 1) { 22 | return 0; 23 | } else { 24 | return 2; 25 | } 26 | } 27 | return 1; 28 | } 29 | 30 | @Override 31 | public boolean login(People people) { 32 | if (peopleDAO.findByLogin(people.getId(), people.getPassword()).getId() != 0) { 33 | return true; 34 | } 35 | return false; 36 | } 37 | 38 | @Override 39 | public People find(int id) { 40 | return peopleDAO.findById(id); 41 | } 42 | 43 | @Override 44 | public boolean alter(People people) { 45 | return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /web/src/servlet/CheckCodeServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import util.CustomUtil; 4 | 5 | import javax.imageio.ImageIO; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.ServletOutputStream; 8 | import javax.servlet.annotation.WebServlet; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import javax.servlet.http.HttpSession; 13 | import java.awt.*; 14 | import java.awt.image.BufferedImage; 15 | import java.io.ByteArrayOutputStream; 16 | import java.io.IOException; 17 | 18 | @WebServlet(name = "CheckCodeServlet", urlPatterns = "/CheckCodeServlet") 19 | public class CheckCodeServlet extends HttpServlet { 20 | 21 | private static final long serialVersionUID = 1L; 22 | private static int width=70; 23 | private static int height=25; 24 | 25 | @Override 26 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 27 | /** 28 | * request是客户端浏览器发出的请求被封装形成的一个HttpServletRequest公共接口类对象 29 | * session对象存储特定用户会话所需的属性及配置信息,这样当用户在应用程序的Web页之间跳转时,存储在session对象中的变量将不会丢失,而是在整个用户会话中一直存在下去 30 | * getSession()与getSession(true)一样,获取request对象关联的session对象,如果没有session,则返回一个新的session 31 | */ 32 | HttpSession session=request.getSession(); 33 | response.setContentType("image/jpeg");//设置生成的文档类型为jpg 34 | ServletOutputStream servletOutputStream = response.getOutputStream(); 35 | 36 | /*设置浏览器不要缓存此图片*/ 37 | response.setHeader("Pragma", "No-cache"); 38 | response.setHeader("Cache-Control", "no-cache"); 39 | response.setDateHeader("Expires", 0); 40 | 41 | /** 42 | * 创建内存图片并获得其图形上下文 43 | * Image是一个抽象类,BufferedImage是其实现类,是一个带缓冲区图像类,主要作用是将一幅图片加载到内存中 44 | * BufferedImage生成的图片在内存里有一个图像缓冲区,利用这个缓冲区我们可以很方便地操作这个图片 45 | */ 46 | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 47 | Graphics graphics = image.getGraphics(); 48 | 49 | char[] rands = generCode();//产生随机的验证码 50 | drawRands(graphics, rands);//产生图像 51 | graphics.dispose();//结束图像的绘制过程,完成图像 52 | 53 | /*将图像输出到客户端*/ 54 | ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream(); 55 | ImageIO.write(image, "jpeg", byteArrayOutputStream); 56 | byte[] buf = byteArrayOutputStream.toByteArray(); 57 | response.setContentLength(buf.length); 58 | servletOutputStream.write(buf); 59 | byteArrayOutputStream.close(); 60 | servletOutputStream.close(); 61 | 62 | session.setAttribute("checkcode", new String(rands));//将当前的验证码写入到session中 63 | } 64 | 65 | private char[] generCode() { 66 | /*验证码的字符表*/ 67 | String chars = "0123456789"; 68 | char[] rands = new char[5]; 69 | for (int i = 0; i < 5; i++) { 70 | int rand = (int) (Math.random()*10); 71 | rands[i] = chars.charAt(rand); 72 | } 73 | rands = new char[]{49, 49, 49, 49, 49}; 74 | return rands; 75 | } 76 | 77 | private void drawRands(Graphics g, char[] rands) { 78 | g.setColor(Color.WHITE); 79 | g.setFont(new Font(null, Font.ITALIC|Font.BOLD, 18)); 80 | 81 | /*在不同高度上输出验证码的每个字符*/ 82 | g.drawString("" + rands[0], 0, 18); 83 | g.drawString("" + rands[1], 14, 18); 84 | g.drawString("" + rands[2], 28, 18); 85 | g.drawString("" + rands[3], 42, 18); 86 | g.drawString("" + rands[4], 56, 18); 87 | CustomUtil.outPosition("green", "CheckCode.drawRands()"); 88 | CustomUtil.outParameter("green", "rands", String.valueOf(rands)); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /web/src/servlet/GoodsServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import entity.Goods; 4 | import util.CustomUtil; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.*; 9 | import java.io.IOException; 10 | 11 | @WebServlet(name = "GoodsServlet", urlPatterns = "/GoodsServlet/*") 12 | public class GoodsServlet extends HttpServlet { 13 | 14 | @Override 15 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 16 | this.doPost(request, response); 17 | } 18 | 19 | @Override 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | /*适配汉字*/ 22 | request.setCharacterEncoding("utf-8"); 23 | response.setCharacterEncoding("utf-8"); 24 | 25 | String path = "/page/404.jsp"; 26 | 27 | String target = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/") + 1); 28 | if (target != null) { 29 | if ("add".equals(target)) { 30 | path = this.add(request, response); 31 | } else if ("delete".equals(target)) { 32 | path = this.delete(request, response); 33 | } 34 | } 35 | response.sendRedirect(request.getContextPath() + path); 36 | } 37 | 38 | public String add(HttpServletRequest request, HttpServletResponse response) { 39 | HttpSession session = request.getSession();//从当前request中获取或创建一个session 40 | Goods goods = (Goods) session.getAttribute("now_goods"); 41 | int number = Integer.parseInt(request.getParameter("number")); 42 | 43 | CustomUtil.outPosition("green", "GoodsServlet.add()"); 44 | CustomUtil.outParameter("green", "request.getContextPath()", request.getContextPath()); 45 | 46 | /*cookie实现购物车,cookie格式为:Cookie(id, number)*/ 47 | Cookie cookie = new Cookie(String.valueOf(goods.getId()), String.valueOf(number)); 48 | Cookie cookies[] = request.getCookies(); 49 | 50 | int is_exist = 0; 51 | if (cookies != null) { 52 | for (int i = 0; i < cookies.length; i++) { 53 | if (cookies[i].getName().equals(String.valueOf(goods.getId()))) { 54 | /*此商品已经存在*/ 55 | int previous_number = Integer.parseInt(cookies[i].getValue()); 56 | number = number + previous_number; 57 | cookies[i].setValue(String.valueOf(number)); 58 | cookies[i].setMaxAge(60*60); 59 | cookies[i].setPath(request.getContextPath()); 60 | response.addCookie(cookies[i]); 61 | is_exist = 1; 62 | } 63 | } 64 | if (is_exist == 0) { 65 | cookie.setMaxAge(60*60);//设置cookie过期时间为60min 66 | cookie.setPath(request.getContextPath()); 67 | response.addCookie(cookie);//在响应头部添加cookie 68 | } 69 | } 70 | 71 | return "/page/shopCar.jsp"; 72 | } 73 | 74 | public String delete(HttpServletRequest request, HttpServletResponse response) { 75 | CustomUtil.outPosition("green", "GoodsServlet.delete()"); 76 | CustomUtil.outParameter("green", "goods_id", request.getParameter("goods_id")); 77 | 78 | Cookie cookies[] = request.getCookies(); 79 | String goods_id = request.getParameter("goods_id"); 80 | 81 | if (cookies != null) { 82 | for (int i = 0; i < cookies.length; i++) { 83 | if (cookies[i].getName().equals(goods_id)) { 84 | cookies[i].setMaxAge(0); 85 | CustomUtil.outParameter("green", "cookies[i].getPath()", cookies[i].getPath()); 86 | cookies[i].setPath(request.getContextPath()); 87 | response.addCookie(cookies[i]); 88 | } 89 | } 90 | } 91 | return "/page/shopCar.jsp"; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /web/src/servlet/OrderServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import dao.OrderDetailDAO; 4 | import dao.OrderIndexDAO; 5 | import dao.impl.OrderDetailDAOImpl; 6 | import dao.impl.OrderIndexDAOImpl; 7 | import entity.Goods; 8 | import entity.OrderDetail; 9 | import entity.OrderIndex; 10 | import entity.People; 11 | import service.GoodsService; 12 | import service.OrderService; 13 | import service.impl.GoodsServiceImpl; 14 | import service.impl.OrderServiceImpl; 15 | import util.CustomUtil; 16 | 17 | import javax.servlet.ServletException; 18 | import javax.servlet.annotation.WebServlet; 19 | import javax.servlet.http.*; 20 | import java.io.IOException; 21 | import java.util.ArrayList; 22 | import java.util.Date; 23 | import java.util.List; 24 | import java.util.regex.Pattern; 25 | 26 | @WebServlet(name = "OrderServlet", urlPatterns = "/OrderServlet/*") 27 | public class OrderServlet extends HttpServlet { 28 | 29 | @Override 30 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | this.doPost(request, response); 32 | } 33 | 34 | @Override 35 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 36 | /*适配汉字*/ 37 | request.setCharacterEncoding("utf-8"); 38 | response.setCharacterEncoding("utf-8"); 39 | 40 | String path = "/page/404.jsp"; 41 | 42 | String target = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/") + 1); 43 | if (target != null) { 44 | if ("submit".equals(target)) { 45 | path = this.submit(request, response); 46 | } 47 | } 48 | response.sendRedirect(request.getContextPath() + path); 49 | } 50 | 51 | public String submit(HttpServletRequest request, HttpServletResponse response) { 52 | HttpSession session = request.getSession();//从当前request中获取或创建一个session 53 | GoodsService goodsService = new GoodsServiceImpl(); 54 | OrderService orderService = new OrderServiceImpl(); 55 | 56 | People people = (People) session.getAttribute("now_people"); 57 | OrderIndex orderIndex = new OrderIndex(0, people.getId(), 0, people.getAddress(), new Date(), 0); 58 | List orderDetailList = new ArrayList<>(); 59 | 60 | CustomUtil.outPosition("green", "OrderServlet.submit()"); 61 | CustomUtil.outParameter("green", "people", people.toString()); 62 | 63 | Cookie cookies[] = request.getCookies(); 64 | Pattern pattern = Pattern.compile("[0-9]{3}");//通过正则表达式过滤cookie 65 | 66 | int sum = 0;//订单总价 67 | if (cookies != null) { 68 | for (int i = 0; i < cookies.length; i++) { 69 | if (pattern.matcher(cookies[i].getName()).matches()) { 70 | Goods goods = goodsService.find(Integer.parseInt(cookies[i].getName())); 71 | if (goods.getId() != 0) { 72 | /*通过cookie实例化订单详情信息*/ 73 | OrderDetail orderDetail = new OrderDetail(); 74 | orderDetail.setGoods_id(goods.getId()); 75 | orderDetail.setGoods_name(goods.getName()); 76 | orderDetail.setNumber(Integer.parseInt(cookies[i].getValue())); 77 | orderDetail.setPrice(goods.getNew_price() * orderDetail.getNumber()); 78 | orderDetailList.add(orderDetail); 79 | sum += orderDetail.getPrice(); 80 | /*清空cookie*/ 81 | cookies[i].setMaxAge(0); 82 | cookies[i].setPath(request.getContextPath()); 83 | response.addCookie(cookies[i]); 84 | } 85 | } 86 | } 87 | } 88 | if (sum != 0) { 89 | /*购物车不为空*/ 90 | orderIndex.setPrice(sum); 91 | int order_index_id = orderService.addOrderIndex(orderIndex); 92 | for (OrderDetail o : orderDetailList) { 93 | o.setOrder_index_id(order_index_id); 94 | orderService.addOrderDetail(o); 95 | } 96 | session.setAttribute("submit_info", "alert(\"订单提交成功!\");"); 97 | } else { 98 | session.setAttribute("submit_info", "alert(\"购物车为空!\");"); 99 | } 100 | 101 | return "/page/shopCar.jsp"; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /web/src/servlet/PeopleServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import entity.People; 4 | import service.PeopleService; 5 | import service.impl.PeopleServiceImpl; 6 | import util.CustomUtil; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.io.IOException; 15 | 16 | @WebServlet(name = "PeopleServlet", urlPatterns = "/PeopleServlet/*") 17 | public class PeopleServlet extends HttpServlet { 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | this.doPost(request, response); 22 | } 23 | 24 | @Override 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 | /*适配汉字*/ 27 | request.setCharacterEncoding("utf-8"); 28 | response.setCharacterEncoding("utf-8"); 29 | 30 | String path = "/page/404.jsp"; 31 | 32 | CustomUtil.outPosition("green", "PeopleServlet.doPost()"); 33 | CustomUtil.outParameter("green", "request.getRequestURI()", request.getRequestURI()); 34 | CustomUtil.outParameter("green", "request.getServletPath()", request.getServletPath()); 35 | CustomUtil.outParameter("green", "request.getRequestURL()", String.valueOf(request.getRequestURL())); 36 | 37 | /*取出路径"/web_war_exploded/page/PeopleServlet/..."中的最右侧字符串*/ 38 | String target = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/") + 1); 39 | if (target != null) { 40 | if ("register".equals(target)) { 41 | path = this.register(request); 42 | } else if ("login".equals(target)) { 43 | path = this.login(request); 44 | } else if ("logout".equals(target)) { 45 | path = this.logout(request); 46 | } 47 | } 48 | request.getRequestDispatcher(path).forward(request, response); 49 | } 50 | 51 | /** 52 | * 1.接收客户端提交到服务端的表单数据 53 | * 2.校验表单数据的合法性,如果校验失败跳回到register.jsp,并回显错误信息 54 | * 3.如果校验通过,调用service层向数据库中注册用户,若注册成功跳转至loginCorrect.jsp 55 | * @return 跳转路径 56 | */ 57 | public String register(HttpServletRequest request) { 58 | PeopleService peopleService = new PeopleServiceImpl(); 59 | HttpSession session = request.getSession();//从当前request中获取或创建一个session 60 | String checkcode = (String) session.getAttribute("checkcode");//从session中取出验证码 61 | 62 | /*通过name属性取得input标签中的值*/ 63 | String id = request.getParameter("id"); 64 | String password_once = request.getParameter("password_once"); 65 | String password_twice = request.getParameter("password_twice"); 66 | String name = request.getParameter("name"); 67 | String email = request.getParameter("email"); 68 | String address = request.getParameter("address"); 69 | String code = request.getParameter("code"); 70 | 71 | People people = new People(0, password_once, name, email, address, 0); 72 | if (id != "") { 73 | people.setId(Integer.parseInt(id)); 74 | } 75 | 76 | /*在控制台输出当前输入内容*/ 77 | CustomUtil.outPosition("green", "PeopleServlet.register()"); 78 | CustomUtil.outParameter("green", "people", people.toString()); 79 | 80 | /** 81 | * 对输入信息逐一校验,并按照错误程度排序,只显示优先级最高的提示信息 82 | * 1.有输入框为空(js已经处理,正常不会显示) 83 | * 2.两次密码输入不一致(js已经处理,正常不会显示) 84 | * 3.验证码填写错误 85 | * 4.重复注册等原因导致后台数据库插入语句执行失败 86 | */ 87 | String register_error_info = null;//注册错误信息 88 | int tag = 0; 89 | if (id == "" || password_once == "" || password_twice == "" || name == "" || email == "" || address == "" || code == "") { 90 | register_error_info = "

有未填写的注册信息!

"; 91 | tag = 2; 92 | } else if (!password_once.equals(password_twice)) { 93 | register_error_info = "

两次输入密码不一致!

"; 94 | tag = 1; 95 | } else if (!code.equals(checkcode)) { 96 | register_error_info = "

注册验证码填写有误!

"; 97 | tag = 1; 98 | } else { 99 | switch (peopleService.register(people)) { 100 | case (2): 101 | register_error_info = "

注册失败!

"; 102 | tag = 1; 103 | break; 104 | case (1): 105 | register_error_info = "

对不起, 此账号已被注册!

"; 106 | tag = 1; 107 | break; 108 | case (0): 109 | } 110 | } 111 | 112 | /*通过tag判断是否注册成功*/ 113 | if (tag == 0) { 114 | session.setAttribute("register_error_info", null);//session置空 115 | session.setAttribute("error_people", null);//session置空 116 | return "/page/registerCorrect.jsp";//跳至注册成功界面 117 | } 118 | else { 119 | /*在控制台输出注册失败原因*/ 120 | CustomUtil.outPosition("green", "PeopleServlet.register()"); 121 | CustomUtil.outParameter("green", "register_error_info", register_error_info); 122 | 123 | session.setAttribute("register_error_info", register_error_info);//将失败原因存进session 124 | session.setAttribute("error_people", people);//将注册信息存进session 125 | return "/page/register.jsp";//对应完整路径为:http://localhost:8080/web_war_exploded/PeopleServlet/../page/register.jsp 126 | } 127 | } 128 | 129 | public String login(HttpServletRequest request) { 130 | PeopleService peopleService = new PeopleServiceImpl(); 131 | HttpSession session = request.getSession();//从当前request中获取或创建一个session 132 | String checkcode = (String) session.getAttribute("checkcode");//从session中取出验证码 133 | 134 | /*通过name属性取得input标签中的值*/ 135 | String code = request.getParameter("code"); 136 | People people = new People(Integer.parseInt(request.getParameter("id")), request.getParameter("password"), 137 | null, null, null, 0); 138 | 139 | /*在控制台输出当前输入内容*/ 140 | CustomUtil.outPosition("green", "PeopleServlet.login()"); 141 | CustomUtil.outParameter("green", "people", people.toString()); 142 | 143 | /** 144 | * 对输入信息逐一校验, 并按照错误程度排序, 只显示优先级最高的提示信息 145 | * 1.验证码填写错误 146 | * 2.其他原因后台数据库插入语句执行失败 147 | */ 148 | String login_error_info = null; 149 | int tag = 0; 150 | if (!code.equals(checkcode)) { 151 | login_error_info = "

登陆验证码填写错误!

"; 152 | tag = 1; 153 | } 154 | if (peopleService.login(people) == false) { 155 | login_error_info = "

信息填写有误!

"; 156 | tag = 1; 157 | } 158 | 159 | /*通过tag判断是否登录成功*/ 160 | if (tag == 0) { 161 | session.setAttribute("login_error_info", null);//session置空 162 | session.setAttribute("now_people", peopleService.find(people.getId()));//将当前登录用户信息存入session 163 | 164 | return "/page/loginCorrect.jsp";//跳至登录成功界面 165 | } 166 | else { 167 | /*在控制台输出注册失败原因*/ 168 | CustomUtil.outPosition("green", "PeopleServlet.login()"); 169 | CustomUtil.outParameter("green", "login_error_info", login_error_info); 170 | 171 | session.setAttribute("login_error_info", login_error_info);//将失败原因存进session 172 | return "/page/login.jsp"; 173 | } 174 | } 175 | 176 | public String logout(HttpServletRequest request) { 177 | return "/page/logoutCorrect.jsp"; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /web/src/sql/shoppingsystem.sql: -------------------------------------------------------------------------------- 1 | -- 删除数据库 2 | DROP DATABASE IF EXISTS shoppingsystem; 3 | 4 | -- 创建数据库 5 | CREATE DATABASE shoppingsystem CHARACTER SET utf8; 6 | 7 | -- 使用数据库 8 | USE shoppingsystem; 9 | 10 | -- 删除数据表 11 | DROP TABLE IF EXISTS `order_detail`; 12 | DROP TABLE IF EXISTS `order_index`; 13 | DROP TABLE IF EXISTS `people`; 14 | DROP TABLE IF EXISTS `goods`; 15 | 16 | -- 创建数据表 17 | # 1.创建用户信息表 18 | CREATE TABLE `people` ( 19 | `id` INT NOT NULL,/*用户编号*/ 20 | `password` VARCHAR(50),/*用户密码*/ 21 | `name` VARCHAR(50),/*用户姓名*/ 22 | `email` VARCHAR(50),/*用户邮箱*/ 23 | `address` VARCHAR(100),/*用户地址*/ 24 | `status` INT,/*用户状态*/ 25 | CONSTRAINT `people_pk_id` PRIMARY KEY (`id`)/* 用户编号作为主键 */ 26 | ) ENGINE = InnoDB; 27 | 28 | # 2.创建商品信息表 29 | CREATE TABLE `goods` ( 30 | `id` INT NOT NULL,/*商品编号*/ 31 | `name` VARCHAR(50),/*商品名称*/ 32 | `image` VARCHAR(50),/*商品图片*/ 33 | `old_price` INT,/*商品原价*/ 34 | `new_price` INT,/*商品现价*/ 35 | `info_brief` VARCHAR(100),/*商品简要信息*/ 36 | `info_detailed` VARCHAR(100),/*商品详细信息*/ 37 | `info_additional` VARCHAR(100),/*商品附加信息*/ 38 | `status` INT,/*商品状态*/ 39 | CONSTRAINT `goods_pk_id` PRIMARY KEY (`id`)/*商品编号作为主键*/ 40 | ) ENGINE = InnoDB; 41 | 42 | # 3.创建订单索引表/*存储一个用户的订单索引信息*/ 43 | CREATE TABLE `order_index` ( 44 | `id` INT NOT NULL AUTO_INCREMENT,/*订单编号*/ 45 | `person_id` INT NOT NULL,/*订单的属主的编号*/ 46 | `price` INT,/*订单总价*/ 47 | `address` VARCHAR(100),/*收货地址*/ 48 | `time` DATETIME,/*创建日期*/ 49 | `status` INT,/*订单状态*/ 50 | CONSTRAINT `order_index_pk_id` PRIMARY KEY (`id`),/*订单编号作为主键*/ 51 | CONSTRAINT `order_index_ibfk_person_id` FOREIGN KEY (`person_id`) REFERENCES `people` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*用户表用户编号作为外键*/ 52 | ) ENGINE = InnoDB AUTO_INCREMENT = 100;/*支持外键以及事务处理,主键从100开始自增*/ 53 | 54 | # 4.创建订单详情表/*存储所有用户的所有订单的详细信息*/ 55 | CREATE TABLE `order_detail` ( 56 | `order_index_id` INT NOT NULL,/*所属订单的编号*/ 57 | `goods_id` INT NOT NULL,/*所含商品的编号*/ 58 | `goods_name` VARCHAR(50),/*所含商品的名称*/ 59 | `number` INT,/*每种商品的数量*/ 60 | `price` INT,/*每种商品的总价*/ 61 | CONSTRAINT `order_detail_pk_order_index_id_goods_id` PRIMARY KEY (`order_index_id`, `goods_id`),/*商品编号与所属订单编号作为联合主键 */ 62 | CONSTRAINT `order_detail_ibfk_order_index_id` FOREIGN KEY (`order_index_id`) REFERENCES `order_index` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,/*订单索引表订单编号作为外键*/ 63 | CONSTRAINT `order_detail_ibfk_goods_id` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*商品表商品编号作为外键*/ 64 | ) ENGINE = InnoDB;/*支持外键以及事务处理*/ 65 | 66 | -- 编写测试数据 67 | # 1.增加用户信息 68 | INSERT INTO `people` VALUES (2022101, '123456', '阿卡丽', '534953576@qq.com', '均衡教派', 0); 69 | INSERT INTO `people` VALUES (2022102, '123456', '琪亚娜', '534953576@qq.com', '以绪塔尔', 0); 70 | INSERT INTO `people` VALUES (2022103, '123456', '艾瑞利娅', '534953576@qq.com', '艾欧尼亚', 0); 71 | INSERT INTO `people` VALUES (2022104, '123456', '卡莎', '534953576@qq.com', '虚空之地', 0); 72 | INSERT INTO `people` VALUES (2022105, '123456', '霞', '534953576@qq.com', '瓦斯塔亚', 0); 73 | INSERT INTO `people` VALUES (2022106, '123456', '洛', '534953576@qq.com', '瓦斯塔亚', 0); 74 | 75 | # 2.增加商品数据 76 | INSERT INTO `goods` VALUES (101, 'HUAWEI P40 Pro 5G', './png/phone1.png', 6300, 5988, '享三期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 77 | INSERT INTO `goods` VALUES (102, 'HUAWEI P40 Pro+ 5G', './png/phone2.png', 8000, 7988, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 78 | INSERT INTO `goods` VALUES (103, '荣耀30', './png/phone3.png', 3500, 3298, '50倍超稳远摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 79 | INSERT INTO `goods` VALUES (104, 'HUAWEI Mate 30E Pro 5G', './png/phone4.png', 5300, 5299, '享六期免息', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 80 | INSERT INTO `goods` VALUES (105, 'HUAWEI Mate 40 Pro+ 5G','./png/phone5.png', 9000, 8999, '享多重权益', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 81 | INSERT INTO `goods` VALUES (106, '荣耀Play4', './png/phone6.png', 2000, 1999, '6400万锐利四摄', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 82 | INSERT INTO `goods` VALUES (107, '华为畅想20 Plus', './png/phone7.png', 2500, 2299 ,'购机赠耳机', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 83 | INSERT INTO `goods` VALUES (108, '荣耀X10 Max', './png/phone8.png', 2100, 2099, '护眼阳光屏', '麒麟99 5G SoC芯片 5000万超感知徕卡四摄 50倍数字变焦 全网通5G手机', '支付后赠花加330元鲜花满减券/银联、花呗、掌上生活、工行分期/支付可享免息购买即赠商城积分, 积分可抵现', 0); 84 | 85 | # 3.增加订单索引数据 86 | # INSERT INTO `order_index` VALUES (0, 2022101, 13976, '均衡教派', now(), 0); 87 | # INSERT INTO `order_index` VALUES (0, 2022101, 5988, '均衡教派', now(), 0); 88 | # INSERT INTO `order_index` VALUES (0, 2022101, 7988, '均衡教派', now(), 0); 89 | 90 | # 4.增加订单详情数据 91 | # INSERT INTO `order_detail` VALUES (100, 101, 'HUAWEI P40 Pro 5G', 1, 5988); 92 | # INSERT INTO `order_detail` VALUES (100, 102, 'HUAWEI P40 Pro+ 5G', 1, 7988); 93 | 94 | -- 提交事务 95 | COMMIT; -------------------------------------------------------------------------------- /web/src/test/GoodsDAOImplTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import dao.GoodsDAO; 4 | import dao.impl.GoodsDAOImpl; 5 | import entity.Goods; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class GoodsDAOImplTest { 9 | 10 | @Test 11 | void findById() { 12 | GoodsDAO goodsDAO = new GoodsDAOImpl(); 13 | Goods goods = goodsDAO.findById(101); 14 | System.out.println(goods.toString()); 15 | } 16 | } -------------------------------------------------------------------------------- /web/src/test/JdbcUtilTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import util.JdbcUtil; 4 | 5 | import java.sql.Connection; 6 | 7 | public class JdbcUtilTest { 8 | 9 | public static void main(String[] args) { 10 | Connection connection = null; 11 | connection = JdbcUtil.getConnection(); 12 | System.out.println(connection); 13 | if (connection != null) { 14 | JdbcUtil.closeAll(connection, null, null); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /web/src/test/OrderDetailDAOImplTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import dao.OrderDetailDAO; 4 | import dao.impl.OrderDetailDAOImpl; 5 | import entity.OrderDetail; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.util.List; 9 | 10 | class OrderDetailDAOImplTest { 11 | 12 | @Test 13 | void doInsert() { 14 | OrderDetailDAO orderDetailDAO = new OrderDetailDAOImpl(); 15 | int result = orderDetailDAO.doInsert(103, 105, "HUAWEI Mate 40 Pro+ 5G",1, 8999); 16 | System.out.println(result); 17 | } 18 | 19 | @Test 20 | void doUpdate() { 21 | OrderDetailDAO orderDetailDAO = new OrderDetailDAOImpl(); 22 | int result = orderDetailDAO.doUpdate(103, 105, 2, 17998); 23 | System.out.println(result); 24 | } 25 | 26 | @Test 27 | void findAllById() { 28 | OrderDetailDAO orderDetailDAO = new OrderDetailDAOImpl(); 29 | List orderDetailList = orderDetailDAO.findAllById(103); 30 | for (OrderDetail curse : orderDetailList) { 31 | System.out.println(curse.toString()); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /web/src/test/OrderIndexDAOImplTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import dao.OrderIndexDAO; 4 | import dao.impl.OrderIndexDAOImpl; 5 | import entity.OrderIndex; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | class OrderIndexDAOImplTest { 12 | 13 | @Test 14 | void doInsert() { 15 | OrderIndexDAO orderIndexDAO = new OrderIndexDAOImpl(); 16 | int result = orderIndexDAO.doInsert( 17 | 2022101, 18 | 8999, 19 | "诺克萨斯", 20 | new Date(), 21 | 0); 22 | System.out.println(result); 23 | } 24 | 25 | @Test 26 | void doUpdate() { 27 | } 28 | 29 | @Test 30 | void findById() { 31 | OrderIndexDAO orderIndexDAO = new OrderIndexDAOImpl(); 32 | OrderIndex orderIndex = orderIndexDAO.findById(103); 33 | System.out.println(orderIndex.toString()); 34 | } 35 | 36 | @Test 37 | void findAllById() { 38 | OrderIndexDAO orderIndexDAO = new OrderIndexDAOImpl(); 39 | List orderIndexList = orderIndexDAO.findAllById(2022107); 40 | for (OrderIndex curse : orderIndexList) { 41 | System.out.println(curse.toString()); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /web/src/test/PeopleDAOImplTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import dao.PeopleDAO; 4 | import dao.impl.PeopleDAOImpl; 5 | import entity.People; 6 | import org.junit.jupiter.api.Test; 7 | import util.CustomUtil; 8 | 9 | class PeopleDAOImplTest { 10 | 11 | @Test 12 | void doInsert() { 13 | PeopleDAO peopleDAO = new PeopleDAOImpl(); 14 | int result = peopleDAO.doInsert( 15 | 2022107, 16 | "123456", 17 | "斯维因", 18 | "534953576@qq.com", 19 | "诺克萨斯", 20 | 0); 21 | System.out.println(result); 22 | } 23 | 24 | @Test 25 | void doDelete() { 26 | } 27 | 28 | @Test 29 | void doUpdate() { 30 | } 31 | 32 | @Test 33 | void findByLogin() { 34 | PeopleDAO peopleDAO = new PeopleDAOImpl(); 35 | People people = peopleDAO.findByLogin(2022107, "123456"); 36 | System.out.println(people.toString()); 37 | } 38 | 39 | @Test 40 | void findById() { 41 | PeopleDAO peopleDAO = new PeopleDAOImpl(); 42 | People people = peopleDAO.findById(2022107); 43 | System.out.println(people.toString()); 44 | 45 | if (peopleDAO.findById(2022109).getId() == 0) { 46 | CustomUtil.outParameter("red", "test", "search failed"); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /web/src/util/CustomUtil.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | public class CustomUtil { 4 | public static void outPosition(String color, String position) { 5 | if (color.equals("red")) 6 | System.out.println("\n\033[1;31m" + position + ":" + "\033[0m"); 7 | else if (color.equals("green")) 8 | System.out.println("\n\033[1;32m" + position + ":" + "\033[0m"); 9 | else if (color.equals("yellow")) 10 | System.out.println("\n\033[1;33m" + position + ":" + "\033[0m"); 11 | else 12 | System.out.println("\n\033[1;34m" + position + ":" + "\033[0m"); 13 | } 14 | 15 | public static void outParameter(String color, String parameterName, String parameterValue) { 16 | if (color.equals("red")) 17 | System.out.println(" \033[1;31m" + parameterName + ": " + parameterValue + "\033[0m"); 18 | else if (color.equals("green")) 19 | System.out.println(" \033[1;32m" + parameterName + ": " + parameterValue + "\033[0m"); 20 | else if (color.equals("yellow")) 21 | System.out.println(" \033[1;33m" + parameterName + ": " + parameterValue + "\033[0m"); 22 | else 23 | System.out.println(" \033[1;34m" + parameterName + ": " + parameterValue + "\033[0m"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /web/src/util/JdbcUtil.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.sql.*; 4 | 5 | public class JdbcUtil { 6 | private static final String driver = "com.mysql.jdbc.Driver"; 7 | private static final String url = 8 | "jdbc:mysql://localhost:3306/shoppingsystem?characterEncoding=utf-8";//连接字符串 9 | private static final String user = "root"; 10 | private static final String password = "123"; 11 | 12 | private static Connection connection; 13 | 14 | /** 15 | * 建立连接 16 | * @return 返回获得的连接 17 | */ 18 | public static Connection getConnection() { 19 | try { 20 | Class.forName(driver);//通过反射机制加载驱动 21 | } catch (ClassNotFoundException e) { 22 | e.printStackTrace(); 23 | } 24 | try { 25 | connection = DriverManager.getConnection(url, user, password);//获得连接 26 | } catch (SQLException throwables) { 27 | throwables.printStackTrace(); 28 | } 29 | 30 | return connection; 31 | } 32 | 33 | /** 34 | * 关闭连接 35 | */ 36 | public static void closeAll(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet) { 37 | if (resultSet != null) { 38 | try { 39 | resultSet.close(); 40 | } catch (SQLException throwables) { 41 | throwables.printStackTrace(); 42 | } 43 | } 44 | if (preparedStatement != null) { 45 | try { 46 | preparedStatement.close(); 47 | } catch (SQLException throwables) { 48 | throwables.printStackTrace(); 49 | } 50 | } 51 | if (connection != null) { 52 | try { 53 | connection.close(); 54 | } catch (SQLException throwables) { 55 | throwables.printStackTrace(); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /web/web.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /web/web/WEB-INF/lib/jstl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/WEB-INF/lib/jstl.jar -------------------------------------------------------------------------------- /web/web/WEB-INF/lib/mysql-connector-java-5.1.25.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/WEB-INF/lib/mysql-connector-java-5.1.25.jar -------------------------------------------------------------------------------- /web/web/WEB-INF/lib/standard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/WEB-INF/lib/standard.jar -------------------------------------------------------------------------------- /web/web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | index.jsp 8 | 9 | -------------------------------------------------------------------------------- /web/web/css/index.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | * { 3 | padding: 0;/*填充*/ 4 | margin: 0;/*外边距*/ 5 | } 6 | 7 | body { 8 | padding-top: 50px;/*避免文本被导航栏覆盖*/ 9 | background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);/*设置主题渐变色*/ 10 | } 11 | 12 | a { 13 | text-decoration: none;/*去掉链接的下划线*/ 14 | color: black; 15 | } 16 | 17 | a:hover{ 18 | text-decoration: none;/*去掉链接的下划线*/ 19 | } 20 | 21 | /*main*/ 22 | /** 23 | * 定义main类中的right类中的a标签中的第一个div的:hover属性 24 | * 当两个选择器之间有空格的情况下, 可以选择包括的所有子代, 而 ">"只能选择具有直接承下关系的子代 25 | */ 26 | .main .right>a>div:hover { 27 | box-shadow: 5px 5px 15px #888888;/*box-shadow: h-shadow(必需的 水平阴影的位置 允许负值) v-shadow(必需的 垂直阴影的位置 允许负值) blur(可选 模糊距离) spread(可选 阴影的大小) color(可选 阴影的颜色 在CSS颜色值寻找颜色值的完整列表) inset(可选 从外层的阴影(开始时)改变阴影内侧阴影);*/ 28 | transition: 0.5s;/*定义过渡效果*/ 29 | } 30 | 31 | .main { 32 | width: 1226px; 33 | height: 750px; 34 | margin: 0 auto;/*上下无边距, 左右居中*/ 35 | } 36 | 37 | .main .left { 38 | width: 234px; 39 | height: 614px; 40 | float: left;/*将块级元素浮动至最左侧*/ 41 | } 42 | 43 | .main .left img { 44 | width: 234px; 45 | height: 614px; 46 | } 47 | 48 | .main .middle { 49 | width: 234px; 50 | height: 300px; 51 | float: left;/*将块级元素浮动至最左侧*/ 52 | } 53 | 54 | .main .middle img { 55 | width: 234px; 56 | height: 300px; 57 | margin-bottom: 14px; 58 | } 59 | 60 | .main .right { 61 | width: 992px; 62 | height: 614px; 63 | float: left; 64 | background-color: #f5f5f5; 65 | } 66 | 67 | .main .right>a>div { 68 | width: 234px; 69 | height: 300px; 70 | float: left; 71 | background-color: #ffffff; 72 | margin-left: 14px; 73 | margin-bottom: 14px; 74 | } 75 | 76 | .main .right>a>div .images { 77 | width: 160px; 78 | height: 160px; 79 | margin: 10px auto; 80 | } 81 | 82 | .main .right>a>div .images img { 83 | width: 160px; 84 | height: 160px; 85 | } 86 | 87 | .main .right>a>div .name { 88 | margin: 5px auto; 89 | } 90 | 91 | .main .right>a>div .name h3 { 92 | font-weight: normal;/*设置手机名称字体粗细*/ 93 | font-size: 14px;/*设置手机名称字体大小*/ 94 | text-align: center;/*设计手机名称字体对其方式*/ 95 | } 96 | 97 | .main .right>a>div .explain { 98 | margin: 0 auto; 99 | } 100 | 101 | .main .right>a>div .explain p { 102 | font-size: 12px; 103 | color: #C5C5C5; 104 | text-align: center; 105 | } 106 | 107 | .main .right>a>div .price { 108 | margin: 5px auto; 109 | } 110 | 111 | .main .right>a>div .price .newprice { 112 | display: inline-block; 113 | margin: 0 0 0 60px; 114 | } 115 | 116 | .main .right>a>div .price .newprice p { 117 | font-size: 14px; 118 | color: #FF7112; 119 | font-weight: 700; 120 | } 121 | 122 | .main .right>a>div .price .nowprice { 123 | display: inline-block; 124 | margin: 0 0 0 90px; 125 | } 126 | 127 | .main .right>a>div .price .nowprice p { 128 | font-size: 14px; 129 | color: #FF7112; 130 | font-weight: 700; 131 | } 132 | 133 | .main .right>a>div .price .oldprice { 134 | display: inline-block; 135 | margin: 0 0 0 5px; 136 | } 137 | 138 | .main .right>a>div .price .oldprice p { 139 | font-size: 14px; 140 | text-decoration: line-through; 141 | color: #C5C5C5; 142 | } 143 | 144 | /*footer*/ 145 | .footer { 146 | height: 300px; 147 | background-color: #ffffff; 148 | margin-top: 50px; 149 | } 150 | 151 | .footer .center { 152 | width: 1226px; 153 | margin: 0 auto; 154 | } 155 | 156 | .footer .zuo { 157 | width: 613px; 158 | margin-top: 30px; 159 | float: left; 160 | } 161 | 162 | .footer .zuo .ph { 163 | margin-top: 30px; 164 | } 165 | 166 | .footer .zuo .ph p { 167 | font-size: 12px; 168 | color: #666666; 169 | } 170 | 171 | .footer .zuo .btn { 172 | margin-top: 30px; 173 | } 174 | 175 | .footer .zuo .btn a { 176 | display: inline-block; 177 | width: 121px; 178 | height: 38px; 179 | font-size: 16px; 180 | font-weight: 700; 181 | color: #00a4ff; 182 | border: 1px solid #00a4ff;/*定义边框颜色*/ 183 | line-height: 35px; 184 | text-align: center; 185 | } 186 | 187 | .footer .you { 188 | width: 613px; 189 | float: right; 190 | } 191 | 192 | .footer .you div { 193 | float: right; 194 | width: 200px; 195 | margin-top: 60px; 196 | } 197 | 198 | .footer .you div dl dt { 199 | font-size: 16px; 200 | color: #333333; 201 | } 202 | 203 | .footer .you div dl dd { 204 | font-size: 12px; 205 | color: #333333; 206 | } 207 | 208 | .footer .you div dl a dd:hover { 209 | color: #f09f09; 210 | } -------------------------------------------------------------------------------- /web/web/page/goods.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.Goods" %> 3 | <%@ page import="service.GoodsService" %> 4 | <%@ page import="service.impl.GoodsServiceImpl" %> 5 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 6 | 7 | 8 | 商品详情界面 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 51 | 52 | 53 | <% 54 | GoodsService goodsService = new GoodsServiceImpl(); 55 | People now_people = (People) session.getAttribute("now_people"); 56 | Goods goods = goodsService.find(Integer.parseInt(request.getParameter("goods_id"))); 57 | session.setAttribute("now_goods", goods);//将当前浏览商品保存至session,用于表单提交后servlet识别商品 58 | 59 | String info_additional = goods.getInfo_additional(); 60 | String info_coupon = info_additional.substring(0, info_additional.indexOf('/')); 61 | String info_instalment = info_additional.substring(info_additional.indexOf('/') + 1, info_additional.lastIndexOf('/')); 62 | String info_mark = info_additional.substring(info_additional.lastIndexOf('/') + 1, info_additional.length() - 1); 63 | %> 64 | 65 | 81 | 82 | 83 |
84 |
85 |

<%=goods.getName()%>

86 |
87 |
88 |
<%=goods.getInfo_detailed()%>
89 |
90 | 91 |
92 |
93 |
商品赠券
94 |
<%=info_coupon%>
95 |
96 |
97 |
分期免息
98 |
<%=info_instalment%>
99 |
100 |
101 |
赠送积分
102 |
<%=info_mark%>
103 |
104 | 105 |
106 |
107 |
108 |

价 格

109 |

¥<%=goods.getNew_price()%>.00

110 |
111 |
112 |

数 量

113 |
114 | 121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 131 |
132 |
133 |
134 |
135 | 136 | 137 | -------------------------------------------------------------------------------- /web/web/page/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="util.CustomUtil" %> 3 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 4 | 5 | 6 | 登陆界面 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 51 | 52 | 53 | 74 | 75 |
76 |
77 |

欢迎来到登陆界面

78 |
79 | <% 80 | String login_error_info = null; 81 | 82 | if (session.getAttribute("login_error_info") != null) { 83 | login_error_info = (String) session.getAttribute("login_error_info"); 84 | 85 | out.print(login_error_info); 86 | 87 | CustomUtil.outPosition("yellow", "login.jsp"); 88 | CustomUtil.outParameter("yellow", "login_error_info", login_error_info); 89 | } 90 | %> 91 |
92 |

请按照输入框提示输入,当左侧标签全为绿色后点击登陆

93 |
94 |
95 | 96 |
97 | 98 | 99 |
100 | 101 |
102 |
103 | 104 |
105 | 106 |
107 | 108 |
109 |
110 | 111 |
112 | 113 |
114 | 115 |
116 | 117 |
118 |
119 |
120 |
121 | 122 |
123 |
124 |
125 |
126 |









127 |




128 | 129 | 192 |
193 | 194 | 195 | -------------------------------------------------------------------------------- /web/web/page/loginCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 登陆成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |

登陆成功

33 |
34 |

恭喜您, 登陆成功, 1秒后自动跳转至主界面!🚀

35 |
36 |









37 |









38 |




39 | 40 | 41 | -------------------------------------------------------------------------------- /web/web/page/logoutCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 注销成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | <% 29 | /** 30 | * 注销功能实现清空session中的全部属性: 31 | * 1.checkcode:存储验证码,用于register.jsp与login.jsp显示 32 | * 2.register_error_info:注册失败原因,用于register.jsp回显 33 | * 3.error_people:注册失败的表单信息,用于register.jsp回填 34 | * 4.login_error_info:登录失败原因,用于login.jsp回显 35 | * 5.now_people:当前登录用户,在登录成功时创建,用于提取用户信息 36 | * 6.now_goods:当前浏览商品,用于表单提交后GoodsServlet识别商品 37 | * 7.submit_info:订单提交信息,用于shopCar.jsp回显 38 | * 8.orderIndexList:订单索引查询结果,用于order.jsp显示 39 | * 9.orderDetailHashmap:订单详情查询结果,用于order.jsp显示 40 | */ 41 | if (session.getAttribute("register_error_info") != null) { 42 | session.setAttribute("register_error_info", null); 43 | } 44 | if (session.getAttribute("error_people") != null) { 45 | session.setAttribute("error_people", null); 46 | } 47 | if (session.getAttribute("login_error_info") != null) { 48 | session.setAttribute("login_error_info", null); 49 | } 50 | if (session.getAttribute("now_people") != null) { 51 | session.setAttribute("now_people", null); 52 | } 53 | if (session.getAttribute("checkcode") != null) { 54 | session.setAttribute("checkcode", null); 55 | } 56 | if (session.getAttribute("now_goods") != null) { 57 | session.setAttribute("now_goods", null); 58 | } 59 | if (session.getAttribute("submit_info") != null) { 60 | session.setAttribute("submit_info", null); 61 | } 62 | 63 | if (session.getAttribute("orderIndexList") != null) { 64 | session.setAttribute("orderIndexList", null); 65 | } 66 | if (session.getAttribute("orderDetailHashmap") != null) { 67 | session.setAttribute("orderDetailHashmap", null); 68 | } 69 | %> 70 | 71 | 72 | 73 |
74 |
75 |

注销成功

76 |
77 |

注销成功, 1秒后自动跳转至主界面!🚀

78 |
79 |









80 |









81 |




82 | 83 | 84 | -------------------------------------------------------------------------------- /web/web/page/order.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.OrderIndex" %> 3 | <%@ page import="service.OrderService" %> 4 | <%@ page import="service.impl.OrderServiceImpl" %> 5 | <%@ page import="java.util.List" %> 6 | <%@ page import="util.CustomUtil" %> 7 | <%@ page import="java.util.HashMap" %> 8 | <%@ page import="entity.OrderDetail" %> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 11 | 12 | 13 | 订单界面 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 53 | 54 | 61 | 62 | 63 | <% 64 | People now_people = (People) session.getAttribute("now_people"); 65 | %> 66 | 77 | <% 78 | OrderService orderService = new OrderServiceImpl(); 79 | 80 | People people = (People) session.getAttribute("now_people"); 81 | List orderIndexList = orderService.findAllByPersonId(people.getId()); 82 | HashMap> orderDetailHashmap = new HashMap<>(); 83 | for (OrderIndex o : orderIndexList) { 84 | orderDetailHashmap.put(o.getId(), orderService.findAllByOrderIndexId(o.getId())); 85 | } 86 | 87 | CustomUtil.outPosition("yellow", "order.jsp"); 88 | CustomUtil.outParameter("yellow", "orderIndexList", String.valueOf(orderIndexList)); 89 | CustomUtil.outParameter("yellow", "orderDetailHashmap", String.valueOf(orderDetailHashmap)); 90 | 91 | session.setAttribute("orderIndexList", orderIndexList); 92 | session.setAttribute("orderDetailHashmap", orderDetailHashmap); 93 | %> 94 |
95 |
96 |
97 |
98 |

⭐订单信息⭐

99 |
100 | 101 |
102 |

103 |

104 |
105 |
106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
商品编号商品数量商品总价
${detail.getGoods_name()}${detail.getNumber()}${detail.getPrice()}
120 |
121 |
122 |
123 |









124 |









125 |









126 | 127 | 128 | -------------------------------------------------------------------------------- /web/web/page/register.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="util.CustomUtil" %> 2 | <%@ page import="entity.People" %> 3 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 4 | <% 5 | CustomUtil.outPosition("yellow", "register.jsp"); 6 | CustomUtil.outParameter("yellow", "request.getContextPath()", request.getContextPath()); 7 | CustomUtil.outParameter("yellow", "request.getRequestURL()", String.valueOf(request.getRequestURL())); 8 | %> 9 | 10 | 11 | 注册界面 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 56 | 57 | 58 | 79 | 80 |
81 |
82 |

欢迎来到注册界面

83 |
84 | <% 85 | String register_error_info = null; 86 | People people = new People(0, "", "", "", "", 0); 87 | String str_id = ""; 88 | 89 | if (session.getAttribute("register_error_info") != null) { 90 | register_error_info = (String) session.getAttribute("register_error_info"); 91 | people = (People) session.getAttribute("error_people"); 92 | 93 | out.print(register_error_info); 94 | 95 | CustomUtil.outPosition("yellow", "register.jsp"); 96 | CustomUtil.outParameter("yellow", "register_error_info", register_error_info); 97 | 98 | if (people.getId() != 0) { 99 | str_id = String.valueOf(people.getId()); 100 | } 101 | } 102 | %> 103 |
104 |

请严格按照输入框提示输入, 当左侧标签全为绿色后再点击注册!

105 |
106 |
107 | 108 |
109 | 110 |
111 | 112 |
113 |
114 | 115 |
116 | 117 |
118 | 119 |
120 |
121 | 122 |
123 | 124 |
125 | 126 |
127 |
128 | 129 |
130 | 131 |
132 | 133 |
134 |
135 | 136 |
137 | 138 |
139 | 140 |
141 |
142 | 143 |
144 | 145 |
146 | 147 |
148 |
149 | 150 |
151 | 152 |
153 | 154 |
155 | 156 |
157 |
158 |
159 |
160 | 161 |
162 |
163 |
164 |









165 |
166 | 298 | 299 | 300 | -------------------------------------------------------------------------------- /web/web/page/registerCorrect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 注册成功界面 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |

注册成功

33 |
34 |
35 |

恭喜您, 注册成功, 1秒后自动跳转至登陆界面!🚀

36 |
37 |









38 |









39 |




40 | 41 | 42 | -------------------------------------------------------------------------------- /web/web/page/shopCar.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="entity.People" %> 2 | <%@ page import="entity.Goods" %> 3 | <%@ page import="service.GoodsService" %> 4 | <%@ page import="service.impl.GoodsServiceImpl" %> 5 | <%@ page import="java.util.regex.Pattern" %> 6 | <%@ page import="java.util.regex.Matcher" %> 7 | <%@ page import="util.CustomUtil" %> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 购物车界面 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 84 | 85 | 86 | 89 | <% 90 | session.setAttribute("submit_info", null); 91 | People now_people = (People) session.getAttribute("now_people"); 92 | %> 93 | 94 | 110 | 111 |
112 |
113 |
图片
114 |
商品
115 |
单价
116 |
数量
117 |
小计
118 |
操作
119 |
120 | 121 | <% 122 | GoodsService goodsService = new GoodsServiceImpl(); 123 | Cookie cookies[] = request.getCookies(); 124 | Pattern pattern = Pattern.compile("[0-9]{3}");//通过正则表达式过滤cookie 125 | 126 | if (cookies != null) { 127 | for (int i = 0; i < cookies.length; i++) { 128 | if (pattern.matcher(cookies[i].getName()).matches()) { 129 | Goods goods = goodsService.find(Integer.parseInt(cookies[i].getName())); 130 | CustomUtil.outPosition("yellow", "shopCar.jsp"); 131 | CustomUtil.outParameter("yellow", "goods", goods.toString()); 132 | if (goods.getId() != 0) { 133 | out.println( 134 | "
" + 135 | "
" + 136 | "
" + 137 | "
" + goods.getName() + "
" + 138 | "
¥" + goods.getNew_price() + "
" + 139 | "
" + cookies[i].getValue() + "
" + 140 | "
" + goods.getNew_price() * Integer.parseInt(cookies[i].getValue()) + "
" + 141 | "" + 142 | "
" 143 | ); 144 | } 145 | } 146 | } 147 | } 148 | %> 149 |
150 |
151 |
152 | 153 |
154 |
155 | 156 |
157 |
158 |









159 |
160 | 161 | 162 | -------------------------------------------------------------------------------- /web/web/png/other0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other0.png -------------------------------------------------------------------------------- /web/web/png/other1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other1.png -------------------------------------------------------------------------------- /web/web/png/other2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other2.png -------------------------------------------------------------------------------- /web/web/png/other3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other3.png -------------------------------------------------------------------------------- /web/web/png/other4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other4.png -------------------------------------------------------------------------------- /web/web/png/other5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other5.png -------------------------------------------------------------------------------- /web/web/png/other6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other6.png -------------------------------------------------------------------------------- /web/web/png/other7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other7.png -------------------------------------------------------------------------------- /web/web/png/other8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other8.png -------------------------------------------------------------------------------- /web/web/png/other9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/other9.png -------------------------------------------------------------------------------- /web/web/png/phone0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone0.png -------------------------------------------------------------------------------- /web/web/png/phone1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone1.png -------------------------------------------------------------------------------- /web/web/png/phone2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone2.png -------------------------------------------------------------------------------- /web/web/png/phone3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone3.png -------------------------------------------------------------------------------- /web/web/png/phone4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone4.png -------------------------------------------------------------------------------- /web/web/png/phone5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone5.png -------------------------------------------------------------------------------- /web/web/png/phone6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone6.png -------------------------------------------------------------------------------- /web/web/png/phone7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone7.png -------------------------------------------------------------------------------- /web/web/png/phone8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atreus1125/ShoppingSystem/cdcc982a0ce0479ec1d044a15c702aec48e6fac0/web/web/png/phone8.png --------------------------------------------------------------------------------