├── WebContent ├── META-INF │ └── MANIFEST.MF ├── img │ ├── gwc.gif │ ├── zfb.png │ ├── duigou.png │ ├── icon-1.png │ ├── icon-2.png │ ├── icon-3.png │ ├── icon-4.png │ ├── icon-5.png │ ├── icon-6.png │ ├── icon-7.png │ ├── icon-8.png │ ├── icon-9.png │ ├── lb_01.jpg │ ├── lb_02.jpg │ ├── lb_03.jpg │ ├── lb_04.jpg │ ├── lb_05.jpg │ ├── logo.png │ ├── gerenzx.png │ ├── icon-10.png │ ├── icon-11.png │ ├── icon-12.png │ ├── icon-13.png │ ├── icon-14.png │ ├── icon-15.png │ ├── icon-16.png │ ├── shoucang.png │ ├── personIndex.jpg │ ├── seckilling.png │ └── books │ │ ├── c6cf2402-c04a-426d-a339-8ea029bd5689.jpg │ │ ├── f6ed178e-b3bf-49c0-a30e-1692330ffa75.jpg │ │ └── src=http___www.5jjc.net_tu5jJDEwLmFsaWNkbi5jb20vdGZzY29tL2kxLzI1OTk0NDA2NTAvVEIxRVNrcGRqZ3lfdUpqU1pMZVhYYVBsRlhhXyEhJDM.jpg&refer=http___www.5jjc.jpg ├── WEB-INF │ ├── lib │ │ ├── jstl-1.2.jar │ │ ├── javax.servlet.jar │ │ ├── commons-io-2.2.jar │ │ ├── commons-beanutils-1.8.3.jar │ │ ├── commons-logging-1.1.1.jar │ │ ├── commons-fileupload-1.2.2.jar │ │ └── mysql-connector-java-8.0.16.jar │ └── web.xml ├── css │ ├── fonts │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── header.css │ └── normalize.css ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── web │ └── WEB-INF │ │ └── web.xml ├── test.jsp ├── js │ └── util.js ├── message.jsp ├── person │ ├── personIndex.jsp │ ├── navigation.jsp │ ├── personOrder.jsp │ ├── personPassword.jsp │ └── personInformation.jsp ├── admin │ ├── message.jsp │ ├── managerIndex.jsp │ ├── manager.jsp │ ├── categorysList.jsp │ ├── managerUsers.jsp │ ├── addCategory.jsp │ ├── sales.jsp │ ├── editCategory.jsp │ ├── managerHeader.jsp │ ├── managerPassword.jsp │ ├── managerOrder.jsp │ ├── addAdmin.jsp │ ├── managerInformation.jsp │ ├── addBook.jsp │ ├── editBook.jsp │ ├── booksList.jsp │ ├── navigation.jsp │ └── managerLogin.jsp ├── redirect.jsp ├── index.jsp ├── personalCenter.jsp ├── footer.jsp ├── order.jsp ├── favorite.jsp ├── showBook.jsp ├── buyNow.jsp ├── showCart.jsp ├── fraheader.jsp ├── particulars.jsp ├── header1.jsp └── header.jsp ├── config └── jdbcConfig.properties ├── .gitignore ├── src └── cn │ └── xh │ ├── dao │ ├── OrdetrDao.java │ ├── ClientDao.java │ ├── ManagerDao.java │ └── impl │ │ ├── OrderDaoImpl.java │ │ └── ManagerDaoImpl.java │ ├── service │ ├── OrderService.java │ ├── ManagerService.java │ ├── ClientService.java │ └── impl │ │ ├── OrderServiceImpl.java │ │ ├── ClientServiceImpl.java │ │ └── ManagerServiceImpl.java │ ├── web │ ├── formbean │ │ ├── CartItem.java │ │ └── Cart.java │ └── controller │ │ ├── OrderServlet.java │ │ └── ClientServlet.java │ ├── domain │ ├── Favorite.java │ ├── Category.java │ ├── Administrator.java │ ├── Orderitem.java │ ├── User.java │ ├── Order.java │ └── Book.java │ └── util │ └── JDBCUtil.java └── README.md /WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /WebContent/img/gwc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/gwc.gif -------------------------------------------------------------------------------- /WebContent/img/zfb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/zfb.png -------------------------------------------------------------------------------- /WebContent/img/duigou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/duigou.png -------------------------------------------------------------------------------- /WebContent/img/icon-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-1.png -------------------------------------------------------------------------------- /WebContent/img/icon-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-2.png -------------------------------------------------------------------------------- /WebContent/img/icon-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-3.png -------------------------------------------------------------------------------- /WebContent/img/icon-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-4.png -------------------------------------------------------------------------------- /WebContent/img/icon-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-5.png -------------------------------------------------------------------------------- /WebContent/img/icon-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-6.png -------------------------------------------------------------------------------- /WebContent/img/icon-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-7.png -------------------------------------------------------------------------------- /WebContent/img/icon-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-8.png -------------------------------------------------------------------------------- /WebContent/img/icon-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-9.png -------------------------------------------------------------------------------- /WebContent/img/lb_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/lb_01.jpg -------------------------------------------------------------------------------- /WebContent/img/lb_02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/lb_02.jpg -------------------------------------------------------------------------------- /WebContent/img/lb_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/lb_03.jpg -------------------------------------------------------------------------------- /WebContent/img/lb_04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/lb_04.jpg -------------------------------------------------------------------------------- /WebContent/img/lb_05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/lb_05.jpg -------------------------------------------------------------------------------- /WebContent/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/logo.png -------------------------------------------------------------------------------- /WebContent/img/gerenzx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/gerenzx.png -------------------------------------------------------------------------------- /WebContent/img/icon-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-10.png -------------------------------------------------------------------------------- /WebContent/img/icon-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-11.png -------------------------------------------------------------------------------- /WebContent/img/icon-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-12.png -------------------------------------------------------------------------------- /WebContent/img/icon-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-13.png -------------------------------------------------------------------------------- /WebContent/img/icon-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-14.png -------------------------------------------------------------------------------- /WebContent/img/icon-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-15.png -------------------------------------------------------------------------------- /WebContent/img/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/icon-16.png -------------------------------------------------------------------------------- /WebContent/img/shoucang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/shoucang.png -------------------------------------------------------------------------------- /WebContent/img/personIndex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/personIndex.jpg -------------------------------------------------------------------------------- /WebContent/img/seckilling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/seckilling.png -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/jstl-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/jstl-1.2.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/javax.servlet.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/javax.servlet.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/commons-io-2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/commons-io-2.2.jar -------------------------------------------------------------------------------- /WebContent/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /WebContent/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /WebContent/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /WebContent/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/commons-logging-1.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar -------------------------------------------------------------------------------- /WebContent/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /WebContent/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /WebContent/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar -------------------------------------------------------------------------------- /WebContent/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/mysql-connector-java-8.0.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/WEB-INF/lib/mysql-connector-java-8.0.16.jar -------------------------------------------------------------------------------- /config/jdbcConfig.properties: -------------------------------------------------------------------------------- 1 | driverManager=com.mysql.cj.jdbc.Driver 2 | url=jdbc:mysql://localhost:3306/xinhua_library?useSSL=false&serverTimezone=UTC 3 | user=root 4 | password=root -------------------------------------------------------------------------------- /WebContent/img/books/c6cf2402-c04a-426d-a339-8ea029bd5689.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/books/c6cf2402-c04a-426d-a339-8ea029bd5689.jpg -------------------------------------------------------------------------------- /WebContent/img/books/f6ed178e-b3bf-49c0-a30e-1692330ffa75.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/books/f6ed178e-b3bf-49c0-a30e-1692330ffa75.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | /classes 3 | /.idea 4 | build/ 5 | picture/ 6 | webLibrary.iml 7 | doc/ 8 | .settings 9 | .classpath 10 | .project 11 | xinhua-Library.iml 12 | out 13 | *.iml -------------------------------------------------------------------------------- /WebContent/css/header.css: -------------------------------------------------------------------------------- 1 | #logo { 2 | float: left; 3 | height: 115px; 4 | width: 1536px; 5 | background-image: url("../img/personIndex.jpg"); 6 | } 7 | 8 | #daohang { 9 | clear: both; 10 | height: 52px; 11 | } -------------------------------------------------------------------------------- /WebContent/web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /WebContent/img/books/src=http___www.5jjc.net_tu5jJDEwLmFsaWNkbi5jb20vdGZzY29tL2kxLzI1OTk0NDA2NTAvVEIxRVNrcGRqZ3lfdUpqU1pMZVhYYVBsRlhhXyEhJDM.jpg&refer=http___www.5jjc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloCoder-HaC/Javaweb_bookstore/HEAD/WebContent/img/books/src=http___www.5jjc.net_tu5jJDEwLmFsaWNkbi5jb20vdGZzY29tL2kxLzI1OTk0NDA2NTAvVEIxRVNrcGRqZ3lfdUpqU1pMZVhYYVBsRlhhXyEhJDM.jpg&refer=http___www.5jjc.jpg -------------------------------------------------------------------------------- /WebContent/test.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /WebContent/js/util.js: -------------------------------------------------------------------------------- 1 | function getXhr() { 2 | var xmlHttp; 3 | try { 4 | // Firefox, Opera 8.0+, Safari 5 | xmlHttp = new XMLHttpRequest(); 6 | } catch (e) { 7 | // Internet Explorer 8 | try { 9 | xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 10 | } catch (e) { 11 | try { 12 | xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 13 | } catch (e) { 14 | alert("您的浏览器不支持ajax!"); 15 | return null; 16 | } 17 | } 18 | } 19 | return xmlHttp; 20 | } 21 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | xinhua_library 4 | 5 | 6 | redirect.jsp 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/cn/xh/dao/OrdetrDao.java: -------------------------------------------------------------------------------- 1 | package cn.xh.dao; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.domain.Order; 6 | 7 | public interface OrdetrDao { 8 | 9 | /** 10 | * 保存订单的基本信息 还要保存订单关联的订单项信息 11 | * 12 | * @param o 13 | */ 14 | void save(Order o); 15 | 16 | /** 17 | * 根据订单号查找订单 18 | * 19 | * @param ordernum 20 | * @return 订单的基本信息 21 | */ 22 | Order findOrderByNum(String ordernum); 23 | 24 | /** 25 | * 根据客户的id查询订单,按照日期排序排列 26 | * 27 | * @param id 28 | * @return 29 | */ 30 | List findOrdersByUser(String userId); 31 | 32 | List findOrders(); 33 | 34 | void faHuo(String ordernum); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /WebContent/message.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 跳转 8 | 9 | 10 |     ${message} 11 | 3秒后跳转到主页面,若没有跳转请点击这里 12 | <% 13 | response.setHeader("refresh", "3;URL=/client/ClientServlet?op=category"); 14 | %> 15 | 16 | -------------------------------------------------------------------------------- /WebContent/person/personIndex.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | 个人中心首页 13 | 14 | 15 |
16 | 个人中心 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/cn/xh/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service; 2 | 3 | import java.util.List; 4 | 5 | import com.sun.org.apache.xpath.internal.operations.Or; 6 | 7 | import cn.xh.domain.Order; 8 | import cn.xh.domain.Orderitem; 9 | import cn.xh.domain.User; 10 | 11 | public interface OrderService { 12 | /** 13 | * 生成订单 14 | * 15 | * @param o 16 | */ 17 | void genOrder(Order o); 18 | 19 | /** 20 | * 根据订单号查询订单 21 | * 22 | * @param ordernum 23 | * @return 24 | */ 25 | Order findOrderByNum(String ordernum); 26 | 27 | /** 28 | * 查询客户的订单 29 | * 30 | * @param user 31 | * @return 32 | */ 33 | List findUserOrders(User user); 34 | 35 | List findOrders(); 36 | 37 | void faHuo(String ordernum); 38 | } 39 | -------------------------------------------------------------------------------- /src/cn/xh/web/formbean/CartItem.java: -------------------------------------------------------------------------------- 1 | package cn.xh.web.formbean; 2 | 3 | import java.io.Serializable; 4 | 5 | import cn.xh.domain.Book; 6 | 7 | //购物项 8 | public class CartItem implements Serializable { 9 | private Book book; 10 | private int quantity;// 本项数量 11 | private float money;// 本项小计 12 | 13 | public CartItem(Book book) { 14 | this.book = book; 15 | } 16 | 17 | public int getQuantity() { 18 | return quantity; 19 | } 20 | 21 | public void setQuantity(int quantity) { 22 | this.quantity = quantity; 23 | } 24 | 25 | public double getMoney() { 26 | return book.getBook_price() * quantity; 27 | } 28 | 29 | public void setMoney(float money) { 30 | this.money = money; 31 | } 32 | 33 | public Book getBook() { 34 | return book; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /WebContent/admin/message.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | 跳转 13 | 14 | 15 |     ${message} 16 | 3秒后跳转到主页面,若没有跳转请点击这里 18 | <% 19 | response.setHeader("refresh", "3;URL=/admin/manager.jsp"); 20 | %> 21 | 22 | -------------------------------------------------------------------------------- /WebContent/redirect.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 新华书店图书销售管理系统 14 | 15 | 16 | 17 | <% 18 | response.sendRedirect(request.getContextPath()+"/client/ClientServlet?op=category"); 19 | %> 20 | 21 | -------------------------------------------------------------------------------- /WebContent/admin/managerIndex.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | 新华书店管理后台 13 | 14 | 15 | 16 | 17 | 18 |
19 | 后台 20 |
21 | 22 | -------------------------------------------------------------------------------- /src/cn/xh/dao/ClientDao.java: -------------------------------------------------------------------------------- 1 | package cn.xh.dao; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.domain.Book; 6 | import cn.xh.domain.Favorite; 7 | import cn.xh.domain.User; 8 | 9 | public interface ClientDao { 10 | 11 | User login(String username, String password); 12 | 13 | boolean register(User user); 14 | 15 | List getCategoryBook(String cid); 16 | 17 | List rwsk(); 18 | 19 | List sets(); 20 | 21 | List jjjr(); 22 | 23 | List kxjs(); 24 | 25 | List jyks(); 26 | 27 | void personInformation(User user); 28 | 29 | void personPassword(User user); 30 | 31 | List search(String search); 32 | 33 | Book findBookById(String book_id); 34 | 35 | void addfavorite(String string, String user_id, String book_id); 36 | 37 | List findFavoriteByUserId(User user); 38 | 39 | boolean findFavorite(String user_id, String book_id); 40 | 41 | void delFavorite(String book_id); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /WebContent/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 新华书店图书销售管理系统 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /WebContent/admin/manager.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | 管理系统后台 13 | 14 | 15 | 17 | 18 | 20 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /WebContent/personalCenter.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | 个人中心 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/cn/xh/dao/ManagerDao.java: -------------------------------------------------------------------------------- 1 | package cn.xh.dao; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.domain.Administrator; 6 | import cn.xh.domain.Book; 7 | import cn.xh.domain.Category; 8 | import cn.xh.domain.User; 9 | 10 | public interface ManagerDao { 11 | 12 | Administrator login(String username, String password); 13 | 14 | void managerInformation(Administrator admin); 15 | 16 | void managerPassword(Administrator admin); 17 | 18 | List findAllCategory(); 19 | 20 | Category findCategoryById(String categoryid); 21 | 22 | void addBook(Book book); 23 | 24 | void addCategory(Category category); 25 | 26 | List getCategoryBook(String cid); 27 | 28 | 29 | Book findBookById(String book_id); 30 | 31 | void delBook(String book_id); 32 | 33 | void editBook(String book_id, String book_name, String book_author, String book_press, String book_desc, 34 | double book_price, String book_kunumber); 35 | 36 | void editCategory(Category category); 37 | 38 | void delCategory(String category_id); 39 | 40 | List findUsers(); 41 | 42 | void addAdmin(Administrator admin); 43 | 44 | List sales(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Favorite.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | //收藏夹 6 | public class Favorite implements Serializable { 7 | private String favorite_id;// 收藏项id 8 | private User user;// 用户信息 9 | private Book book;// 书籍信息 10 | 11 | public Favorite() { 12 | super(); 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | public Favorite(String favorite_id, User user, Book book) { 17 | super(); 18 | this.favorite_id = favorite_id; 19 | this.user = user; 20 | this.book = book; 21 | } 22 | 23 | public String getFavorite_id() { 24 | return favorite_id; 25 | } 26 | 27 | public void setFavorite_id(String favorite_id) { 28 | this.favorite_id = favorite_id; 29 | } 30 | 31 | public User getUser() { 32 | return user; 33 | } 34 | 35 | public void setUser(User user) { 36 | this.user = user; 37 | } 38 | 39 | public Book getBook() { 40 | return book; 41 | } 42 | 43 | public void setBook(Book book) { 44 | this.book = book; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Favorite [favorite_id=" + favorite_id + ", user=" + user + ", book=" + book + "]"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /WebContent/footer.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 17 |
18 |
19 | <%----%> 30 |
    31 | 32 |
  • 本项目仅作个人毕设开源使用,如有疑问,可以联系:HeloCoder
  • 33 |
34 |
35 |
36 | Copyright © 2018-2021 新华书店 版权所有
37 |
-------------------------------------------------------------------------------- /src/cn/xh/service/ManagerService.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.domain.Administrator; 6 | import cn.xh.domain.Book; 7 | import cn.xh.domain.Category; 8 | import cn.xh.domain.User; 9 | 10 | public interface ManagerService { 11 | 12 | Administrator login(String username, String password); 13 | 14 | void managerInformation(String username, String name, String sex, String tel); 15 | 16 | void managerPassword(String username, String password); 17 | 18 | List findAllCategory(); 19 | 20 | Category findCategoryById(String categoryid); 21 | 22 | void addBook(Book book); 23 | 24 | void addCategory(Category category); 25 | 26 | List getCategoryBook(String cid); 27 | 28 | Book findBookById(String book_id); 29 | 30 | void delBook(String book_id); 31 | 32 | void editBook(String book_id, String book_name, String book_author, String book_press, String book_desc, 33 | double book_price, String book_kunumber); 34 | 35 | void editCategory(Category category); 36 | 37 | void delCategory(String category_id); 38 | 39 | List findUsers(); 40 | 41 | void addAdmin(Administrator admin); 42 | 43 | List sales(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/cn/xh/service/ClientService.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.domain.Book; 6 | import cn.xh.domain.Favorite; 7 | import cn.xh.domain.User; 8 | 9 | public interface ClientService { 10 | 11 | public User login(String username, String password); 12 | 13 | public boolean register(String username, String password, String name, String sex, String tel, String address); 14 | 15 | public List getCategoryBook(String cid); 16 | 17 | public List rwsk(); 18 | 19 | public List sets(); 20 | 21 | public List jjjr(); 22 | 23 | public List kxjs(); 24 | 25 | public List jyks(); 26 | 27 | public void personInformation(String username, String name, String sex, String tel, String address); 28 | 29 | public void personPassword(String password, String username); 30 | 31 | public List search(String search); 32 | 33 | public Book findBookById(String book_id); 34 | 35 | public void addfavorite(String user_id, String book_id); 36 | 37 | public List findFavoriteByUserId(User user); 38 | 39 | public boolean findFavorite(String user_id, String book_id); 40 | 41 | public void delFavorite(String book_id); 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/cn/xh/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import cn.xh.dao.OrdetrDao; 6 | import cn.xh.dao.impl.OrderDaoImpl; 7 | import cn.xh.domain.Order; 8 | import cn.xh.domain.Orderitem; 9 | import cn.xh.domain.User; 10 | import cn.xh.service.OrderService; 11 | 12 | public class OrderServiceImpl implements OrderService { 13 | private OrdetrDao dao = new OrderDaoImpl(); 14 | 15 | @Override 16 | public void genOrder(Order o) { 17 | if (o.getUser() == null) { 18 | throw new IllegalArgumentException("订单所属的客户信息没有"); 19 | } 20 | if (o.getItems() == null || o.getItems().size() == 0) { 21 | throw new IllegalArgumentException("订单中没有订单项"); 22 | } 23 | dao.save(o); 24 | } 25 | 26 | @Override 27 | public Order findOrderByNum(String ordernum) { 28 | return dao.findOrderByNum(ordernum); 29 | } 30 | 31 | @Override 32 | public List findUserOrders(User user) { 33 | return dao.findOrdersByUser(user.getId()); 34 | } 35 | 36 | @Override 37 | public List findOrders() { 38 | // TODO Auto-generated method stub 39 | return dao.findOrders(); 40 | } 41 | 42 | @Override 43 | public void faHuo(String ordernum) { 44 | // TODO Auto-generated method stub 45 | dao.faHuo(ordernum); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/cn/xh/util/JDBCUtil.java: -------------------------------------------------------------------------------- 1 | package cn.xh.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.sql.Statement; 8 | import java.util.ResourceBundle; 9 | 10 | public class JDBCUtil { 11 | static Connection conn = null; 12 | 13 | static { 14 | // 初始化porperties文件 15 | ResourceBundle bundle = ResourceBundle.getBundle("jdbcConfig"); 16 | String dirver = bundle.getString("driverManager"); 17 | String url = bundle.getString("url"); 18 | String user = bundle.getString("user"); 19 | String password = bundle.getString("password"); 20 | // 注册驱动 21 | try { 22 | Class.forName(dirver); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | 27 | try { 28 | conn = DriverManager.getConnection(url, user, password); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | 34 | public static Connection getConnection() { 35 | return conn; 36 | } 37 | 38 | public static void release(ResultSet set, Statement stmt, Connection connection) throws SQLException { 39 | if (set != null) { 40 | set.close(); 41 | } 42 | if (stmt != null) { 43 | stmt.close(); 44 | } 45 | if (connection != null) { 46 | connection.close(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Category.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | /* 6 | * 图书种类 7 | */ 8 | public class Category implements Serializable { 9 | 10 | private String category_id;// 图书种类id 11 | private String category_name;// 图书种类名称 12 | private String category_desc;// 图书种类描述 13 | 14 | public Category() { 15 | super(); 16 | } 17 | 18 | public Category(String category_id, String category_name, String category_desc) { 19 | super(); 20 | this.category_id = category_id; 21 | this.category_name = category_name; 22 | this.category_desc = category_desc; 23 | } 24 | 25 | public String getCategory_id() { 26 | return category_id; 27 | } 28 | 29 | public void setCategory_id(String category_id) { 30 | this.category_id = category_id; 31 | } 32 | 33 | public String getCategory_name() { 34 | return category_name; 35 | } 36 | 37 | public void setCategory_name(String category_name) { 38 | this.category_name = category_name; 39 | } 40 | 41 | public String getCategory_desc() { 42 | return category_desc; 43 | } 44 | 45 | public void setCategory_desc(String category_desc) { 46 | this.category_desc = category_desc; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "Category [category_id=" + category_id + ", category_name=" + category_name + ", category_desc=" 52 | + category_desc + "]"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WebContent/person/navigation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 导航条 13 | 14 | 15 |
16 |

17 |   修改个人资料 21 |

22 |

23 |   修改密码 27 | 28 |

29 |

30 |   我的订单 34 |

35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /WebContent/order.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 支付 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 |
订单编号:${order.ordernum}创建时间:${order.time}
34 |
35 | 36 |
37 |




38 |
39 | ${order.money} 41 |
42 |
43 | 44 | -------------------------------------------------------------------------------- /src/cn/xh/web/formbean/Cart.java: -------------------------------------------------------------------------------- 1 | package cn.xh.web.formbean; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import cn.xh.domain.Book; 8 | 9 | //购物车 10 | public class Cart implements Serializable { 11 | // CartItem是购物项 12 | private Map itmes = new HashMap(); 13 | private int totalQuantity;// 总数量 14 | private float totalMoney;// 总金额 15 | 16 | public int getTotalQuantity() { 17 | totalQuantity = 0; 18 | for (Map.Entry me : itmes.entrySet()) { 19 | totalQuantity += me.getValue().getQuantity(); 20 | } 21 | return totalQuantity; 22 | } 23 | 24 | public void setTotalQuantity(int totalQuantity) { 25 | this.totalQuantity = totalQuantity; 26 | } 27 | 28 | public double getTotalMoney() { 29 | totalMoney = 0; 30 | for (Map.Entry me : itmes.entrySet()) { 31 | totalMoney += me.getValue().getMoney(); 32 | } 33 | return totalMoney; 34 | } 35 | 36 | public void setTotalMoney(float totalMoney) { 37 | this.totalMoney = totalMoney; 38 | } 39 | 40 | public Map getItmes() { 41 | return itmes; 42 | } 43 | 44 | // 向购物车中添加一本书 45 | public void addBook(Book book) { 46 | if (itmes.containsKey(book.getBook_id())) { 47 | // 有对应的购物项 48 | CartItem item = itmes.get(book.getBook_id()); 49 | item.setQuantity(item.getQuantity() + 1); 50 | } else { 51 | CartItem item = new CartItem(book); 52 | item.setQuantity(1); 53 | itmes.put(book.getBook_id(), item); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Administrator.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Administrator implements Serializable { 6 | 7 | private String username; 8 | private String password; 9 | private String name; 10 | private String sex; 11 | private String tel; 12 | 13 | public Administrator() { 14 | super(); 15 | } 16 | 17 | public Administrator(String username, String password, String name, String sex, String tel) { 18 | super(); 19 | this.username = username; 20 | this.password = password; 21 | this.name = name; 22 | this.sex = sex; 23 | this.tel = tel; 24 | } 25 | 26 | public String getUsername() { 27 | return username; 28 | } 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | public String getPassword() { 35 | return password; 36 | } 37 | 38 | public void setPassword(String password) { 39 | this.password = password; 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | 50 | public String getSex() { 51 | return sex; 52 | } 53 | 54 | public void setSex(String sex) { 55 | this.sex = sex; 56 | } 57 | 58 | public String getTel() { 59 | return tel; 60 | } 61 | 62 | public void setTel(String tel) { 63 | this.tel = tel; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "Administrator [username=" + username + ", password=" + password + ", name=" + name + ", sex=" + sex 69 | + ", tel=" + tel + "]"; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Orderitem.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | //订单项 6 | public class Orderitem implements Serializable { 7 | private String id;// 订单项id 8 | private int quantity;// 订单项得数量 9 | private double price;// 订单项小计 10 | private Book book;// 书籍信息 11 | private String ordernum; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public int getQuantity() { 22 | return quantity; 23 | } 24 | 25 | public void setQuantity(int quantity) { 26 | this.quantity = quantity; 27 | } 28 | 29 | public double getPrice() { 30 | return price; 31 | } 32 | 33 | public void setPrice(double price) { 34 | this.price = price; 35 | } 36 | 37 | public Book getBook() { 38 | return book; 39 | } 40 | 41 | public void setBook(Book book) { 42 | this.book = book; 43 | } 44 | 45 | public String getOrdernum() { 46 | return ordernum; 47 | } 48 | 49 | public void setOrdernum(String ordernum) { 50 | this.ordernum = ordernum; 51 | } 52 | 53 | public Orderitem(String id, int quantity, double price, Book book, String ordernum) { 54 | super(); 55 | this.id = id; 56 | this.quantity = quantity; 57 | this.price = price; 58 | this.book = book; 59 | this.ordernum = ordernum; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "Orderitem [id=" + id + ", quantity=" + quantity + ", price=" + price + ", book=" + book + ", ordernum=" 65 | + ordernum + "]"; 66 | } 67 | 68 | public Orderitem() { 69 | super(); 70 | // TODO Auto-generated constructor stub 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /WebContent/admin/categorysList.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 书籍分类维护 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 37 | 38 |
序号分类名称分类描述操作
${vs.index+1}${s.category_name}${s.category_desc}编辑      33 | 删除 36 |
39 | 40 | -------------------------------------------------------------------------------- /WebContent/admin/managerUsers.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 用户管理 14 | 15 | 16 | 17 | 18 | 19 |
20 |

用户管理

21 |
22 |
24 | 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 |
序号用户ID用户名密码姓名性别电话号码地址操作
${vs.index+1}${u.id}${u.username}${u.password}${u.name}${u.sex}${u.tel}${u.address}编辑
51 | 52 | -------------------------------------------------------------------------------- /WebContent/person/personOrder.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 个人订单 14 | 15 | 16 | 17 | 18 | 19 |
20 |

我的订单

21 |
22 |
24 | 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 |
序号订单编号创建时间商品数量支付金额订单状态操作
${vs.index+1}${os.ordernum}${os.time}${os.quantity}${os.money}等待发货已发货删除
52 | 53 | -------------------------------------------------------------------------------- /WebContent/admin/addCategory.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 添加书籍信息 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

添加书籍分类

22 |
23 |
25 |
28 |
29 | 32 |
33 |
34 | 35 | 37 |
38 |
39 | 41 | 44 |
45 | 46 | -------------------------------------------------------------------------------- /src/cn/xh/domain/User.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | /* 6 | * 用户实体类 7 | */ 8 | public class User implements Serializable { 9 | 10 | private String id;// id 11 | private String username; // 用户名 12 | private String password; // 密码 13 | private String name; // 姓名 14 | private String sex; // 性别 15 | private String tel; // 电话 16 | private String address; // 地址 17 | 18 | public User() { 19 | super(); 20 | } 21 | 22 | public User(String id, String username, String password, String name, String sex, String tel, String address) { 23 | super(); 24 | this.id = id; 25 | this.username = username; 26 | this.password = password; 27 | this.name = name; 28 | this.sex = sex; 29 | this.tel = tel; 30 | this.address = address; 31 | } 32 | 33 | public String getUsername() { 34 | return username; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.username = username; 39 | } 40 | 41 | public String getPassword() { 42 | return password; 43 | } 44 | 45 | public void setPassword(String password) { 46 | this.password = password; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getSex() { 58 | return sex; 59 | } 60 | 61 | public void setSex(String sex) { 62 | this.sex = sex; 63 | } 64 | 65 | public String getTel() { 66 | return tel; 67 | } 68 | 69 | public void setTel(String tel) { 70 | this.tel = tel; 71 | } 72 | 73 | public String getAddress() { 74 | return address; 75 | } 76 | 77 | public void setAddress(String address) { 78 | this.address = address; 79 | } 80 | 81 | public String getId() { 82 | return id; 83 | } 84 | 85 | public void setId(String id) { 86 | this.id = id; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "User [id=" + id + ", username=" + username + ", password=" + password + ", name=" + name + ", sex=" 92 | + sex + ", tel=" + tel + ", address=" + address + "]"; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /WebContent/admin/sales.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 14 | 15 | 书籍销售情况 16 | 17 | 18 | 19 | 20 |
21 |

书籍销售情况

22 |
23 |
25 |
26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
书籍编号书籍图片书籍名称书籍类型书籍作者书籍出版社销量
${vs.index+1} 42 | 《${s.book_name}》${s.category.category_name}${s.book_author}${s.book_press}${s.book_xiaonumber}
51 |
52 | 53 | -------------------------------------------------------------------------------- /WebContent/admin/editCategory.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 编辑分类信息 14 | 15 | 16 | 17 | 18 | 19 |
20 |

编辑书籍分类信息

21 |
22 |
24 |
25 |
27 |
28 | 31 |
32 |
33 | 36 |
37 |
38 | 41 |
42 |
43 | 45 | 47 |
48 |
49 | 50 | -------------------------------------------------------------------------------- /WebContent/admin/managerHeader.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 管理系统后台 8 | <% 9 | String path = request.getContextPath(); 10 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 11 | ; 12 | %> 13 | 14 | 15 | 16 | 17 | 18 | 19 | 51 | 52 | -------------------------------------------------------------------------------- /WebContent/admin/managerPassword.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 修改管理员密码 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

修改登录密码

22 |
23 |
25 |
26 |
28 |
29 | 32 |
33 |
34 | 37 |
38 |
39 | 42 |
43 |
44 | 46 | 49 |
50 |
51 | 52 | -------------------------------------------------------------------------------- /WebContent/person/personPassword.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 修改密码 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

修改密码

22 |
23 |
25 |
26 |
28 |
29 | 32 |
33 |
34 | 37 |
38 |
39 | 43 |
44 |
45 | 47 | 50 |
51 |
52 | 53 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Order.java: -------------------------------------------------------------------------------- 1 | package cn.xh.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | //订单 8 | public class Order implements Serializable { 9 | private String ordernum;// 订单号 10 | private int quantity;// 购物项数量 11 | private double money;// 总金额 12 | private String time;// 订单创建时间 13 | private int status;// 订单状态:0未付款,1已付款,2未发货,3已发货 14 | private User user;// 客户 15 | 16 | private List items = new ArrayList();// 订单项 17 | 18 | public String getOrdernum() { 19 | return ordernum; 20 | } 21 | 22 | public void setOrdernum(String ordernum) { 23 | this.ordernum = ordernum; 24 | } 25 | 26 | public int getQuantity() { 27 | return quantity; 28 | } 29 | 30 | public void setQuantity(int quantity) { 31 | this.quantity = quantity; 32 | } 33 | 34 | public double getMoney() { 35 | return money; 36 | } 37 | 38 | public void setMoney(double money) { 39 | this.money = money; 40 | } 41 | 42 | public String getTime() { 43 | return time; 44 | } 45 | 46 | public void setTime(String time) { 47 | this.time = time; 48 | } 49 | 50 | public User getUser() { 51 | return user; 52 | } 53 | 54 | public void setUser(User user) { 55 | this.user = user; 56 | } 57 | 58 | public List getItems() { 59 | return items; 60 | } 61 | 62 | public void setItems(List items) { 63 | this.items = items; 64 | } 65 | 66 | public int getStatus() { 67 | return status; 68 | } 69 | 70 | public void setStatus(int status) { 71 | this.status = status; 72 | } 73 | 74 | public Order() { 75 | super(); 76 | // TODO Auto-generated constructor stub 77 | } 78 | 79 | public Order(String ordernum, int quantity, double money, String time, int status, User user, 80 | List items) { 81 | super(); 82 | this.ordernum = ordernum; 83 | this.quantity = quantity; 84 | this.money = money; 85 | this.time = time; 86 | this.status = status; 87 | this.user = user; 88 | this.items = items; 89 | } 90 | 91 | @Override 92 | public String toString() { 93 | return "Order [ordernum=" + ordernum + ", quantity=" + quantity + ", money=" + money + ", time=" + time 94 | + ", status=" + status + ", user=" + user + ", items=" + items + "]"; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /WebContent/admin/managerOrder.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 订单管理 14 | 15 | 16 | 17 | 18 | 19 | 26 |
27 |

订单管理

28 |
29 |
31 | 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 |
序号订单编号创建时间客户账号商品数量支付金额订单状态操作
${vs.index+1}${os.ordernum}${os.time}${os.user.username}${os.quantity}${os.money}未发货发货已发货删除
62 | 63 | -------------------------------------------------------------------------------- /src/cn/xh/service/impl/ClientServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service.impl; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import cn.xh.dao.ClientDao; 7 | import cn.xh.dao.impl.ClientDaoImpl; 8 | import cn.xh.domain.Book; 9 | import cn.xh.domain.Favorite; 10 | import cn.xh.domain.User; 11 | import cn.xh.service.ClientService; 12 | 13 | public class ClientServiceImpl implements ClientService { 14 | 15 | private ClientDao dao = new ClientDaoImpl(); 16 | 17 | @Override 18 | public User login(String username, String password) { 19 | return dao.login(username, password); 20 | } 21 | 22 | @Override 23 | public boolean register(String username, String password, String name, String sex, String tel, String address) { 24 | User user = new User(UUID.randomUUID().toString(), username, password, name, sex, tel, address); 25 | return dao.register(user); 26 | } 27 | 28 | @Override 29 | public List getCategoryBook(String cid) { 30 | return dao.getCategoryBook(cid); 31 | } 32 | 33 | @Override 34 | public List rwsk() { 35 | return dao.rwsk(); 36 | } 37 | 38 | @Override 39 | public List sets() { 40 | return dao.sets(); 41 | } 42 | 43 | @Override 44 | public List jjjr() { 45 | return dao.jjjr(); 46 | } 47 | 48 | @Override 49 | public List kxjs() { 50 | return dao.kxjs(); 51 | } 52 | 53 | @Override 54 | public List jyks() { 55 | return dao.jyks(); 56 | } 57 | 58 | @Override 59 | public void personInformation(String username, String name, String sex, String tel, String address) { 60 | User user = new User(null, username, null, name, sex, tel, address); 61 | dao.personInformation(user); 62 | } 63 | 64 | @Override 65 | public void personPassword(String password, String username) { 66 | User user = new User(null, username, password, null, null, null, null); 67 | dao.personPassword(user); 68 | } 69 | 70 | @Override 71 | public List search(String search) { 72 | return dao.search(search); 73 | } 74 | 75 | @Override 76 | public Book findBookById(String book_id) { 77 | return dao.findBookById(book_id); 78 | } 79 | 80 | @Override 81 | public void addfavorite(String user_id, String book_id) { 82 | dao.addfavorite(UUID.randomUUID().toString(), user_id, book_id); 83 | } 84 | 85 | @Override 86 | public List findFavoriteByUserId(User user) { 87 | return dao.findFavoriteByUserId(user); 88 | } 89 | 90 | @Override 91 | public boolean findFavorite(String user_id, String book_id) { 92 | return dao.findFavorite(user_id, book_id); 93 | } 94 | 95 | @Override 96 | public void delFavorite(String book_id) { 97 | dao.delFavorite(book_id); 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /WebContent/favorite.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 收藏夹 14 | 15 | 16 | 17 | 18 | 19 | 29 | 30 | 31 |
32 | 33 |

34 | 空空如也!快去把喜欢的宝贝添加进收藏夹吧!!! 返回主页 36 |

37 |
38 |
39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
序号书籍图片书籍名称书籍类型书籍作者书籍出版社书籍单价操作
${vs.index+1} 57 | 《${f.book.book_name}》${f.book.category.category_name}${f.book.book_author}${f.book.book_press}¥${f.book.book_price}删除
67 |
68 | 69 | -------------------------------------------------------------------------------- /WebContent/admin/addAdmin.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 添加工作人员 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

添加工作人员

22 |
23 |
25 |
26 |
29 |
30 | 34 |
35 |
36 | 40 |
41 |
42 | 45 |
46 | 47 | 男 48 |         女 50 |
51 | 54 |
55 |
56 | 58 | 61 |
62 |
63 | 64 | -------------------------------------------------------------------------------- /src/cn/xh/service/impl/ManagerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.xh.service.impl; 2 | 3 | import cn.xh.dao.ManagerDao; 4 | import cn.xh.dao.impl.ManagerDaoImpl; 5 | import cn.xh.domain.Administrator; 6 | import cn.xh.domain.Book; 7 | import cn.xh.domain.Category; 8 | import cn.xh.domain.User; 9 | import cn.xh.service.ManagerService; 10 | 11 | import java.util.List; 12 | import java.util.UUID; 13 | 14 | public class ManagerServiceImpl implements ManagerService { 15 | private ManagerDao dao = new ManagerDaoImpl(); 16 | 17 | @Override 18 | public Administrator login(String username, String password) { 19 | return dao.login(username, password); 20 | } 21 | 22 | @Override 23 | public void managerInformation(String username, String name, String sex, String tel) { 24 | Administrator admin = new Administrator(username, null, name, sex, tel); 25 | dao.managerInformation(admin); 26 | } 27 | 28 | @Override 29 | public void managerPassword(String username, String password) { 30 | Administrator admin = new Administrator(username, password, null, null, null); 31 | dao.managerPassword(admin); 32 | } 33 | 34 | @Override 35 | public List findAllCategory() { 36 | return dao.findAllCategory(); 37 | } 38 | 39 | @Override 40 | public Category findCategoryById(String categoryid) { 41 | return dao.findCategoryById(categoryid); 42 | } 43 | 44 | @Override 45 | public void addBook(Book book) { 46 | book.setBook_id(UUID.randomUUID().toString()); 47 | dao.addBook(book); 48 | 49 | } 50 | 51 | @Override 52 | public void addCategory(Category category) { 53 | category.setCategory_id(UUID.randomUUID().toString()); 54 | dao.addCategory(category); 55 | } 56 | 57 | @Override 58 | public List getCategoryBook(String cid) { 59 | return dao.getCategoryBook(cid); 60 | } 61 | 62 | 63 | 64 | @Override 65 | public Book findBookById(String book_id) { 66 | return dao.findBookById(book_id); 67 | } 68 | 69 | @Override 70 | public void delBook(String book_id) { 71 | dao.delBook(book_id); 72 | } 73 | 74 | @Override 75 | public void editBook(String book_id, String book_name, String book_author, String book_press, String book_desc, 76 | double book_price, String book_kunumber) { 77 | dao.editBook(book_id, book_name, book_author, book_press, book_desc, book_price, book_kunumber); 78 | } 79 | 80 | @Override 81 | public void editCategory(Category category) { 82 | dao.editCategory(category); 83 | } 84 | 85 | @Override 86 | public void delCategory(String category_id) { 87 | dao.delCategory(category_id); 88 | } 89 | 90 | @Override 91 | public List findUsers() { 92 | return dao.findUsers(); 93 | } 94 | 95 | @Override 96 | public void addAdmin(Administrator admin) { 97 | dao.addAdmin(admin); 98 | } 99 | 100 | @Override 101 | public List sales() { 102 | return dao.sales(); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /WebContent/admin/managerInformation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 14 | 15 | 管理员个人信息修改 16 | 17 | 18 | 19 | 20 |
21 |

修改个人信息

22 |
23 |
25 |
26 |
29 |
30 | 34 |
35 |
36 | 39 |
40 | 41 | 42 | 男 44 |         女 46 | 47 | 48 | 男 50 |         女 52 |
53 |
54 | 57 |
58 |
59 | 61 | 64 |
65 |
66 | 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaWeb图书销售管理系统/网上书店 2 | 3 | Javaweb_bookstore,一个基于servlet+jsp+bootstrap 的MVC图书销售管理系统。 4 | 5 | - 可以直接运行 6 | - 可以用做大作业、毕业设计 7 | - 有完整的代码注释 8 | 9 | ## 1、开发环境: 10 | Tomcat版本:v8.5 11 | MySQL版本:v8.0 12 | JDK:1.8.0_171 13 | 14 | (后端没有用到任何框架,都是servlet,比较简单,前端是JSP+bootstrap) 15 | 16 | ## 2、功能模块 17 | 18 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175643885.png) 19 | 20 | ## 3、本地开发 21 | 22 | ### 1、导入sql 23 | 24 | 找到sql文件,导入到数据库,并且在下一步导入代码后,修改数据库的用户名和密码。 25 | 26 | ### 2、使用IDEA导入代码 27 | 28 | 第一步先导入项目,使用eclipse的方式导入,如果不是,那么接下来会复杂,还需要设置src和resources目录。 29 | 30 | #### 2.1、清除原来的eclipse信息 31 | 32 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210507225206166.png) 33 | 34 | #### 2.2、导入包 35 | 36 | 如果你不是通过eclipse导入的方式导入项目,这里需要把这些jar手动右击 添加到 library 即可: 37 | 38 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210507225623540.png) 39 | 40 | #### 2.3、设置Modules的web.xml文件 41 | 42 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210507230128552.png) 43 | 44 | 这里主注意两个地方: 45 | 46 | - 上方,设置Path的目录,`web.xml`文件要正确 47 | - 下方,设置Web Resource Dictory 是正确的WebRoot 路径,也就是WebContent。 48 | 49 | `web.xml` 可以配置首页地址,具体请看文件,修改你需要的首页,第一个是没有自动加载数据的,第二个是加载数据的。 50 | 51 | #### 2.4、生成Artifact包 52 | 53 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210507230032298.png) 54 | 55 | #### 2.5、配置Tomcat 56 | 57 | 我这里Tomcat8.0版本有乱码,可以设置一下为`-Dfile.encoding=UTF-8` 58 | 59 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210507230334986.png) 60 | 61 | Deployment 不要设置Application context! 62 | 63 | 64 | 65 | ### 3、eclipse 66 | 67 | 项目带有eclipse 标识,基本上按照以上配置即可。 68 | 69 | 但是不要使用默认的 context 路径 70 | 71 | ## 4、功能页面 72 | 73 | ### 用户端: 74 | 75 | 首页: 76 | 77 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175143151.png) 78 | 79 | 商品详情: 80 | 81 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175249476.png) 82 | 83 | 购物车: 84 | 85 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175226003.png) 86 | 87 | ### 管理员端: 88 | 89 | 功能见左侧导航栏: 90 | 91 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175911434.png) 92 | 93 | ![](https://cdn.jsdelivr.net/gh/DogerRain/image@main/Home/image-20210509175835182.png) 94 | 95 | 96 | 97 | 98 | 99 | 用户账号密码:HaC / 123 100 | 101 | 102 | 103 | 管理员账号密码:admin / 123 104 | 105 | ## 5、A&Q 106 | 107 | 1、项目是从其他地方copy过来的二开的,刚拿到这个项目的时候,一堆bug,经过了一系列的重构,功能也比之前多了。 108 | 109 | 但是`立即购买`的这个模块就没有做了(先通过加入购物车再立即购买就可以了)。。。。,大家可以自己完善一下功能,比如说: 110 | 111 | - 用户查看订单 112 | - 立即购买跳转 113 | - 区分是否收藏过 114 | 115 | 116 | 117 | 2、关于图片的路径 118 | 119 | 说实话我现在也搞不懂,大家可以参考`addBook()`的代码实现,什么相对路径、绝对路径,我暂时还不明白,大家可以去看看如何自定义设置自己的图片路径。 120 | 121 | 122 | 123 | ## 6、声明|费用 124 | 125 | 本项目存在文件缺少,且不再提供免费使用,有偿出售39块钱,酌情购买,需要请联系wx: HaC200 126 | 127 | 更多毕设参考: 128 | 129 | [毕设项目 | HelloCoder (baimuxym.cn)](https://learnjava.baimuxym.cn/pages/JavaWeb图书销售管理系统-网上书店/) -------------------------------------------------------------------------------- /WebContent/person/personInformation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 个人资料 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

个人资料修改

22 |
23 |
25 |
26 |
28 |
29 | 33 |
34 |
35 | 38 |
39 | 40 | 41 | 男 42 |          43 | 女 44 | 45 | 46 | 男 47 |          48 | 女 49 | 50 |
51 |
52 | 55 |
56 |
57 | 60 |
61 |
62 | 64 | 67 |
68 |
69 | 70 | -------------------------------------------------------------------------------- /WebContent/admin/addBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 添加书籍信息 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

添加书籍信息

22 |
23 |
25 |
28 |
29 | 32 |
33 |
34 | 37 |
38 |
39 | 42 |
43 |
44 | 51 |
52 |
53 | 55 |
56 |
57 | 58 | 60 |
61 |
62 | 65 |
66 |
67 | 70 |
71 |
72 | 74 | 77 |
78 | 79 | -------------------------------------------------------------------------------- /WebContent/css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */ 2 | html { 3 | font-family: sans-serif; 4 | -ms-text-size-adjust: 100%; 5 | -webkit-text-size-adjust: 100% 6 | } 7 | 8 | body { 9 | margin: 0 10 | } 11 | 12 | article, aside, details, figcaption, figure, footer, header, hgroup, 13 | main, menu, nav, section, summary { 14 | display: block 15 | } 16 | 17 | audio, canvas, progress, video { 18 | display: inline-block; 19 | vertical-align: baseline 20 | } 21 | 22 | audio:not ([controls] ){ 23 | display: none; 24 | height: 0 25 | } 26 | 27 | [hidden], template { 28 | display: none 29 | } 30 | 31 | a { 32 | background-color: transparent 33 | } 34 | 35 | a:active, a:hover { 36 | outline: 0 37 | } 38 | 39 | abbr[title] { 40 | border-bottom: 1px dotted 41 | } 42 | 43 | b, strong { 44 | font-weight: bold 45 | } 46 | 47 | dfn { 48 | font-style: italic 49 | } 50 | 51 | h1 { 52 | font-size: 2em; 53 | margin: 0.67em 0 54 | } 55 | 56 | mark { 57 | background: #ff0; 58 | color: #000 59 | } 60 | 61 | small { 62 | font-size: 80% 63 | } 64 | 65 | sub, sup { 66 | font-size: 75%; 67 | line-height: 0; 68 | position: relative; 69 | vertical-align: baseline 70 | } 71 | 72 | sup { 73 | top: -0.5em 74 | } 75 | 76 | sub { 77 | bottom: -0.25em 78 | } 79 | 80 | img { 81 | border: 0 82 | } 83 | 84 | svg:not (:root ){ 85 | overflow: hidden 86 | } 87 | 88 | figure { 89 | margin: 1em 40px 90 | } 91 | 92 | hr { 93 | -moz-box-sizing: content-box; 94 | -webkit-box-sizing: content-box; 95 | box-sizing: content-box; 96 | height: 0 97 | } 98 | 99 | pre { 100 | overflow: auto 101 | } 102 | 103 | code, kbd, pre, samp { 104 | font-family: monospace, monospace; 105 | font-size: 1em 106 | } 107 | 108 | button, input, optgroup, select, textarea { 109 | color: inherit; 110 | font: inherit; 111 | margin: 0 112 | } 113 | 114 | button { 115 | overflow: visible 116 | } 117 | 118 | button, select { 119 | text-transform: none 120 | } 121 | 122 | button, html input[type="button"], input[type="reset"], input[type="submit"] 123 | { 124 | -webkit-appearance: button; 125 | cursor: pointer 126 | } 127 | 128 | button[disabled], html input[disabled] { 129 | cursor: default 130 | } 131 | 132 | button::-moz-focus-inner, input::-moz-focus-inner { 133 | border: 0; 134 | padding: 0 135 | } 136 | 137 | input { 138 | line-height: normal 139 | } 140 | 141 | input[type="checkbox"], input[type="radio"] { 142 | -webkit-box-sizing: border-box; 143 | -moz-box-sizing: border-box; 144 | box-sizing: border-box; 145 | padding: 0 146 | } 147 | 148 | input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button 149 | { 150 | height: auto 151 | } 152 | 153 | input[type="search"] { 154 | -webkit-appearance: textfield; 155 | -moz-box-sizing: content-box; 156 | -webkit-box-sizing: content-box; 157 | box-sizing: content-box 158 | } 159 | 160 | input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration 161 | { 162 | -webkit-appearance: none 163 | } 164 | 165 | fieldset { 166 | border: 1px solid #c0c0c0; 167 | margin: 0 2px; 168 | padding: 0.35em 0.625em 0.75em 169 | } 170 | 171 | legend { 172 | border: 0; 173 | padding: 0 174 | } 175 | 176 | textarea { 177 | overflow: auto 178 | } 179 | 180 | optgroup { 181 | font-weight: bold 182 | } 183 | 184 | table { 185 | border-collapse: collapse; 186 | border-spacing: 0 187 | } 188 | 189 | td, th { 190 | padding: 0 191 | } -------------------------------------------------------------------------------- /WebContent/admin/editBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 编辑书籍信息 14 | 15 | 16 | 17 | 18 | 19 |
20 |

编辑书籍信息

21 |
22 |
24 | 25 |
26 |
28 |
29 | 31 |
32 |
33 | 36 |
37 |
38 | 41 |
42 |
43 | 46 |
47 |
48 | 55 |
56 |
57 | 61 |
62 |
63 | 64 | 66 |
67 |
68 | 71 |
72 |
73 | 76 |
77 |
78 | 80 | 82 |
83 |
84 | 85 | -------------------------------------------------------------------------------- /WebContent/showBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | 8 | 新华书店图书销售管理系统 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 12 | ; 13 | %> 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 87 | 88 | 89 |
书籍编号书籍图片书籍名称书籍类型书籍作者书籍出版社书籍价格销量操作
${vs.index+1} 78 | 《${s.book_name}》${s.category.category_name}${s.book_author}${s.book_press}¥${s.book_price}${s.book_xiaonumber}详情
90 | 91 | 92 | -------------------------------------------------------------------------------- /WebContent/admin/booksList.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 书籍信息维护 14 | 15 | 16 | 17 | 18 | 19 | 20 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 85 | 86 |
书籍编号书籍图片书籍名称书籍类型书籍作者书籍出版社书籍价格销量操作
${vs.index+1} 72 | 《${s.book_name}》${s.category.category_name}${s.book_author}${s.book_press}¥${s.book_price}${s.book_xiaonumber}编辑      81 | 删除 84 |
87 |
88 | 89 | -------------------------------------------------------------------------------- /WebContent/admin/navigation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | <% 7 | String path = request.getContextPath(); 8 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 9 | ; 10 | %> 11 | 12 | Insert title here 13 | 14 | 15 |
16 | 17 |
18 | 95 | 96 | -------------------------------------------------------------------------------- /src/cn/xh/domain/Book.java: -------------------------------------------------------------------------------- 1 | 2 | package cn.xh.domain; 3 | 4 | import java.io.Serializable; 5 | 6 | /** 7 | * 图书实体类 8 | */ 9 | public class Book implements Serializable { 10 | private String book_id; // 图书ID 11 | 12 | 13 | 14 | private String book_name; // 图书名称 15 | private String book_author; // 图书作者 16 | private String book_press; // 出版社 17 | private Category category; // 图书类别 18 | private String filename; // 图片文件名 19 | private String path; // 路径 20 | private String book_desc; // 描述 21 | private double book_price; // 图书价格 22 | private int book_kunumber; // 库存数量 23 | private int book_xiaonumber; // 销售数量 24 | 25 | /** 26 | * 默认构造函数 27 | */ 28 | public Book() { 29 | super(); 30 | // TODO Auto-generated constructor stub 31 | } 32 | 33 | public String getBook_name() { 34 | return book_name; 35 | } 36 | 37 | public void setBook_name(String book_name) { 38 | this.book_name = book_name; 39 | } 40 | 41 | public String getBook_id() { 42 | return book_id; 43 | } 44 | 45 | public void setBook_id(String book_id) { 46 | this.book_id = book_id; 47 | } 48 | 49 | public String getBook_author() { 50 | return book_author; 51 | } 52 | 53 | public void setBook_author(String book_author) { 54 | this.book_author = book_author; 55 | } 56 | 57 | public String getBook_press() { 58 | return book_press; 59 | } 60 | 61 | public void setBook_press(String book_press) { 62 | this.book_press = book_press; 63 | } 64 | 65 | public Category getCategory() { 66 | return category; 67 | } 68 | 69 | public void setCategory(Category category) { 70 | this.category = category; 71 | } 72 | 73 | public String getFilename() { 74 | return filename; 75 | } 76 | 77 | public void setFilename(String filename) { 78 | this.filename = filename; 79 | } 80 | 81 | public String getPath() { 82 | return path; 83 | } 84 | 85 | public void setPath(String path) { 86 | this.path = path; 87 | } 88 | 89 | public String getBook_desc() { 90 | return book_desc; 91 | } 92 | 93 | public void setBook_desc(String book_desc) { 94 | this.book_desc = book_desc; 95 | } 96 | 97 | public double getBook_price() { 98 | return book_price; 99 | } 100 | 101 | public void setBook_price(double book_price) { 102 | this.book_price = book_price; 103 | } 104 | 105 | public int getBook_kunumber() { 106 | return book_kunumber; 107 | } 108 | 109 | public void setBook_kunumber(int book_kunumber) { 110 | this.book_kunumber = book_kunumber; 111 | } 112 | 113 | public int getBook_xiaonumber() { 114 | return book_xiaonumber; 115 | } 116 | 117 | public void setBook_xiaonumber(int book_xiaonumber) { 118 | this.book_xiaonumber = book_xiaonumber; 119 | } 120 | 121 | /** 122 | * 全参数构造函数 123 | * 124 | * @param book_id 图书ID 125 | * @param book_name 图书名称 126 | * @param book_author 图书作者 127 | * @param book_press 出版社 128 | * @param category 图书类别 129 | * @param filename 图片文件名 130 | * @param path 路径 131 | * @param book_desc 描述 132 | * @param book_price 图书价格 133 | * @param book_kunumber 库存数量 134 | * @param book_xiaonumber 销售数量 135 | */ 136 | public Book(String book_id, String book_name, String book_author, String book_press, Category category, 137 | String filename, String path, String book_desc, double book_price, int book_kunumber, int book_xiaonumber) { 138 | super(); 139 | this.book_id = book_id; 140 | this.book_name = book_name; 141 | this.book_author = book_author; 142 | this.book_press = book_press; 143 | this.category = category; 144 | this.filename = filename; 145 | this.path = path; 146 | this.book_desc = book_desc; 147 | this.book_price = book_price; 148 | this.book_kunumber = book_kunumber; 149 | this.book_xiaonumber = book_xiaonumber; 150 | } 151 | 152 | // Getters and Setters 方法 153 | // ... 154 | 155 | /** 156 | * 重写toString方法 157 | * 158 | * @return 图书对象的字符串表示 159 | */ 160 | @Override 161 | public String toString() { 162 | return "Book [book_id=" + book_id + ", book_name=" + book_name + ", book_author=" + book_author 163 | + ", book_press=" + book_press + ", category=" + category + ", filename=" + filename + ", path=" + path 164 | + ", book_desc=" + book_desc + ", book_price=" + book_price + ", book_kunumber=" + book_kunumber 165 | + ", book_xiaonumber=" + book_xiaonumber + "]"; 166 | } 167 | 168 | } -------------------------------------------------------------------------------- /WebContent/buyNow.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="cn.xh.domain.Book" %> 2 | <%@ page import="cn.xh.web.formbean.Cart" %> 3 | <%@ page language="java" contentType="text/html; charset=UTF-8" 4 | pageEncoding="UTF-8"%> 5 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 6 | 7 | 8 | 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 12 | ; 13 | 14 | Cart cart = (Cart) session.getAttribute("buyNowBook"); 15 | 16 | %> 17 | 18 | 下单 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 71 | 72 | 73 | 结算功能有bug,不做了 74 |
序号书籍图片书籍名称书籍类型书籍作者书籍出版社书籍单价购买数量小计操作
${vs.index+1} 44 | ${c.value.book.book_name}${c.value.book.category.category_name}${c.value.book.book_author}${c.value.book.book_press}¥${c.value.book.book_price}¥${c.value.money}删除
总数量:${sessionScope.cart.totalQuantity}     合计: 64 | ¥${sessionScope.cart.totalMoney} 66 |
75 | 76 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /WebContent/showCart.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 购物车 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 |

24 | 空空如也!快去把喜欢的宝贝添加进购物车吧!!! 返回主页 25 |

26 |
27 |
28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 74 | 75 | 76 |
序号书籍图片书籍名称书籍类型书籍作者书籍出版社书籍单价购买数量小计操作
${vs.index+1} 48 | 《${c.value.book.book_name}》${c.value.book.category.category_name}${c.value.book.book_author}${c.value.book.book_press}¥${c.value.book.book_price}¥${c.value.money}删除
总数量:${sessionScope.cart.totalQuantity}     合计: 67 | ¥${sessionScope.cart.totalMoney} 69 |
77 | 78 |
79 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/cn/xh/web/controller/OrderServlet.java: -------------------------------------------------------------------------------- 1 | package cn.xh.web.controller; 2 | 3 | import java.io.IOException; 4 | import java.text.DateFormat; 5 | import java.text.SimpleDateFormat; 6 | import java.util.ArrayList; 7 | import java.util.Date; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import javax.servlet.http.HttpSession; 17 | 18 | import cn.xh.domain.Order; 19 | import cn.xh.domain.Orderitem; 20 | import cn.xh.domain.User; 21 | import cn.xh.service.OrderService; 22 | import cn.xh.service.impl.OrderServiceImpl; 23 | import cn.xh.web.formbean.Cart; 24 | import cn.xh.web.formbean.CartItem; 25 | 26 | @WebServlet("/order/OrderServlet") 27 | public class OrderServlet extends HttpServlet { 28 | private OrderService service = new OrderServiceImpl(); 29 | 30 | @Override 31 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 32 | req.setCharacterEncoding("UTF-8"); 33 | resp.setContentType("text/html;charset=UTF-8"); 34 | String op = req.getParameter("op");// 得到传过来的请求 35 | // 生成订单 36 | if (op.equals("genOrder")) { 37 | genOrder(req, resp); 38 | } 39 | // 查看订单 40 | if (op.equals("findAllOrders")) { 41 | findAllOrders(req, resp); 42 | } 43 | // 管理员查看订单 44 | if (op.equals("findOrders")) { 45 | findOrders(req, resp); 46 | } 47 | // 发货 48 | if (op.equals("faHuo")) { 49 | faHuo(req, resp); 50 | } 51 | } 52 | 53 | private void faHuo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 54 | String ordernum = req.getParameter("ordernum"); 55 | service.faHuo(ordernum); 56 | List orders = service.findOrders(); 57 | HttpSession session = req.getSession(); 58 | session.setAttribute("orders", orders); 59 | System.out.println(orders); 60 | resp.sendRedirect(req.getContextPath() + "/admin/managerOrder.jsp"); 61 | } 62 | 63 | private void findOrders(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 64 | List orders = service.findOrders(); 65 | HttpSession session = req.getSession(); 66 | session.setAttribute("orders", orders); 67 | req.getRequestDispatcher("/admin/managerOrder.jsp").forward(req, resp); 68 | } 69 | 70 | private void findAllOrders(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 71 | HttpSession session = req.getSession(); 72 | User user = (User) session.getAttribute("user"); 73 | List orders = service.findUserOrders(user); 74 | req.setAttribute("orders", orders); 75 | req.getRequestDispatcher("/person/personOrder.jsp").forward(req, resp); 76 | } 77 | 78 | private void genOrder(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { 79 | // 取出购物车信息 80 | // 取出购物项信息 81 | HttpSession session = req.getSession(); 82 | Cart cart = (Cart) session.getAttribute("cart"); 83 | User user = (User) session.getAttribute("user"); 84 | if (cart == null) { 85 | resp.getWriter().write("会话已经结束!!"); 86 | return; 87 | } 88 | Order order = new Order(); 89 | order.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 90 | String ordernum = genOrdernum(); 91 | order.setOrdernum(ordernum); 92 | order.setQuantity(cart.getTotalQuantity()); 93 | order.setMoney(cart.getTotalMoney()); 94 | order.setUser(user); 95 | // 订单项 96 | List oItems = new ArrayList(); 97 | for (Map.Entry me : cart.getItmes().entrySet()) { 98 | CartItem cItem = me.getValue(); 99 | Orderitem oItem = new Orderitem(); 100 | oItem.setId(genOrdernum()); 101 | oItem.setBook(cItem.getBook()); 102 | oItem.setPrice(cItem.getMoney()); 103 | oItem.setQuantity(cItem.getQuantity()); 104 | oItem.setOrdernum(ordernum); 105 | oItems.add(oItem); 106 | } 107 | // 建立订单项和订单的关系 108 | order.setItems(oItems); 109 | service.genOrder(order); 110 | req.setAttribute("order", order); 111 | session.removeAttribute("cart"); 112 | req.getRequestDispatcher("/order.jsp").forward(req, resp); 113 | } 114 | 115 | // 生成订单号 116 | private String genOrdernum() { 117 | Date now = new Date(); 118 | DateFormat df = new SimpleDateFormat("yyyyMMdd"); 119 | String s1 = df.format(now); 120 | return s1 + System.nanoTime(); 121 | } 122 | 123 | @Override 124 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 125 | doGet(req, resp); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /WebContent/admin/managerLogin.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 管理后台登陆 8 | 9 | 10 | 203 | 204 | 205 | 206 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /WebContent/fraheader.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 新华书店图书销售管理系统 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 170 |
171 | 172 | -------------------------------------------------------------------------------- /WebContent/particulars.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8" %> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 | 5 | 6 | 7 | 8 | 书籍详情 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); 12 | %> 13 | 14 | 15 | 16 | 18 | 19 | 20 | 68 | 69 |
71 |
72 | 《${book.book_name}》返回 75 |
76 | 77 |
78 |
80 |
82 | 85 |
86 |
87 | 88 |
89 | 《${book.book_name}》 91 |
92 | 93 |
94 | ${book.book_press} 95 |      ${book.book_author} 97 |   98 |
99 | 100 |
102 | bg——img 103 |
104 | 所属分类:   ${book.category.category_name}
105 | 书籍描述: 106 | 109 | 书籍单价:  ¥${book.book_price}
111 | 书籍库存:   ${book.book_kunumber} 本
112 | 书籍销量:   ${book.book_xiaonumber} 本
113 |
114 |
115 | 116 | 117 |
118 | 添加收藏 122 |
123 |
124 | 125 |
126 | 添加收藏 130 |
131 |
132 | 133 |
134 | 135 | 140 | 144 | 145 | 146 | 151 | 156 | 157 | 158 |
159 |
160 |
161 | 192 | 193 | -------------------------------------------------------------------------------- /src/cn/xh/dao/impl/OrderDaoImpl.java: -------------------------------------------------------------------------------- 1 | package cn.xh.dao.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.ArrayList; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import com.sun.org.apache.xpath.internal.operations.Or; 13 | 14 | import cn.xh.dao.OrdetrDao; 15 | import cn.xh.domain.Book; 16 | import cn.xh.domain.Category; 17 | import cn.xh.domain.Order; 18 | import cn.xh.domain.Orderitem; 19 | import cn.xh.domain.User; 20 | import cn.xh.util.JDBCUtil; 21 | import sun.net.www.content.text.plain; 22 | 23 | public class OrderDaoImpl implements OrdetrDao { 24 | 25 | Connection connection = JDBCUtil.getConnection(); 26 | 27 | @Override 28 | public void save(Order o) { 29 | try { 30 | PreparedStatement prepareStatement = connection.prepareStatement( 31 | "insert into orders (ordernum,quantity,money,time,status,userId) values (?,?,?,?,?,?)"); 32 | prepareStatement.setString(1, o.getOrdernum()); 33 | prepareStatement.setInt(2, o.getQuantity()); 34 | prepareStatement.setDouble(3, o.getMoney()); 35 | prepareStatement.setString(4, o.getTime()); 36 | prepareStatement.setInt(5, o.getStatus()); 37 | prepareStatement.setString(6, o.getUser().getId()); 38 | prepareStatement.executeUpdate(); 39 | 40 | // 保存订单项信息 41 | List items = o.getItems(); 42 | for (Orderitem item : items) { 43 | PreparedStatement preparedStatement2 = connection.prepareStatement( 44 | "insert into orderitems (id,quantity,price,book_id,ordernum) values(?,?,?,?,?)"); 45 | preparedStatement2.setString(1, item.getId()); 46 | preparedStatement2.setInt(2, item.getQuantity()); 47 | preparedStatement2.setDouble(3, item.getPrice()); 48 | preparedStatement2.setString(4, item.getBook().getBook_id()); 49 | preparedStatement2.setString(5, item.getOrdernum()); 50 | preparedStatement2.executeUpdate(); 51 | addXiaonumber(item.getBook().getBook_id()); 52 | 53 | } 54 | } catch (Exception e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | 59 | private void addXiaonumber(String book_id) { 60 | try { 61 | Connection connection = JDBCUtil.getConnection(); 62 | PreparedStatement prepareStatement = connection.prepareStatement( 63 | "update bookdb set book_xiaonumber = book_xiaonumber+1,book_kunumber=book_kunumber-1 where book_id=?"); 64 | prepareStatement.setString(1, book_id); 65 | prepareStatement.executeUpdate(); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | 70 | } 71 | 72 | @Override 73 | public Order findOrderByNum(String ordernum) { 74 | try { 75 | PreparedStatement prepareStatement = connection.prepareStatement("select * from orders where ordernum=?"); 76 | prepareStatement.setString(1, ordernum); 77 | ResultSet rs = prepareStatement.executeQuery(); 78 | Order order = new Order(); 79 | if (rs.next()) { 80 | order.setOrdernum(rs.getString("ordernum")); 81 | order.setQuantity(rs.getInt("quantity")); 82 | order.setMoney(rs.getDouble("money")); 83 | order.setTime(rs.getString("time")); 84 | order.setStatus(rs.getInt("status")); 85 | User user = findUserByid(rs.getString("userId")); 86 | order.setUser(user); 87 | List items = finOrdersItemsByNum(rs.getString("ordernum")); 88 | order.setItems(items); 89 | } 90 | return order; 91 | } catch (Exception e) { 92 | e.printStackTrace(); 93 | } 94 | throw new RuntimeException(""); 95 | } 96 | 97 | // 根据订单id找到订单项 98 | private List finOrdersItemsByNum(String ordernum) { 99 | try { 100 | PreparedStatement prepareStatement = connection 101 | .prepareStatement("select * from orderitems where ordernum=?"); 102 | prepareStatement.setString(1, ordernum); 103 | ResultSet rs = prepareStatement.executeQuery(); 104 | List list = new ArrayList(); 105 | while (rs.next()) { 106 | Orderitem item = new Orderitem(); 107 | item.setOrdernum(ordernum); 108 | Book book = findBookById(rs.getString("book_id")); 109 | item.setBook(book); 110 | item.setId(rs.getString("id")); 111 | item.setPrice(rs.getDouble("price")); 112 | item.setQuantity(rs.getInt("quantity")); 113 | list.add(item); 114 | } 115 | return list; 116 | } catch (Exception e) { 117 | e.printStackTrace(); 118 | } 119 | throw new RuntimeException(""); 120 | } 121 | 122 | // 根据书籍id找到书籍信息 123 | private Book findBookById(String book_id) { 124 | try { 125 | PreparedStatement prepareStatement = connection.prepareStatement("select * from bookdb where book_id=?"); 126 | prepareStatement.setString(1, book_id); 127 | ResultSet rs = prepareStatement.executeQuery(); 128 | Book book = new Book(); 129 | if (rs.next()) { 130 | book.setBook_id(rs.getString("book_id")); 131 | book.setBook_name(rs.getString("book_name")); 132 | book.setBook_author(rs.getString("book_author")); 133 | book.setBook_press(rs.getString("book_press")); 134 | Category category = findCategoryById(rs.getString("book_category")); 135 | book.setCategory(category); 136 | book.setFilename(rs.getString("filename")); 137 | book.setPath(rs.getString("path")); 138 | book.setBook_desc(rs.getString("book_desc")); 139 | book.setBook_kunumber(rs.getInt("book_kunumber")); 140 | book.setBook_xiaonumber(rs.getInt("book_xiaonumber")); 141 | book.setBook_price(rs.getDouble("book_price")); 142 | return book; 143 | } 144 | } catch (Exception e) { 145 | e.printStackTrace(); 146 | } 147 | throw new RuntimeException(""); 148 | } 149 | 150 | // 根据书籍分类的id找到书籍分类信息 151 | private Category findCategoryById(String category_id) { 152 | Category category = new Category(); 153 | try { 154 | PreparedStatement preparedStatement = connection 155 | .prepareStatement("select * from category where category_id=?"); 156 | preparedStatement.setString(1, category_id); 157 | ResultSet resultSet = preparedStatement.executeQuery(); 158 | while (resultSet.next()) { 159 | category.setCategory_id(resultSet.getString("category_id")); 160 | category.setCategory_name(resultSet.getString("category_name")); 161 | category.setCategory_desc(resultSet.getString("category_desc")); 162 | return category; 163 | } 164 | } catch (Exception e) { 165 | e.printStackTrace(); 166 | } 167 | throw new RuntimeException(""); 168 | } 169 | 170 | // 根据id找到用户信息 171 | private User findUserByid(String user_id) { 172 | try { 173 | User user = new User(); 174 | PreparedStatement prepareStatement = connection.prepareStatement("select * from user where user_id=?"); 175 | prepareStatement.setString(1, user_id); 176 | ResultSet rs = prepareStatement.executeQuery(); 177 | if (rs.next()) { 178 | user.setId(rs.getString("user_id")); 179 | user.setUsername(rs.getString("user_username")); 180 | } 181 | return user; 182 | } catch (SQLException e) { 183 | e.printStackTrace(); 184 | } 185 | throw new RuntimeException(""); 186 | } 187 | 188 | @Override 189 | public List findOrdersByUser(String userId) { 190 | try { 191 | PreparedStatement prepareStatement = connection 192 | .prepareStatement("select * from orders where userId = ? order by ordernum desc"); 193 | prepareStatement.setString(1, userId); 194 | ResultSet rs = prepareStatement.executeQuery(); 195 | List list = new ArrayList(); 196 | while (rs.next()) { 197 | Order order = new Order(); 198 | List items = finOrdersItemsByNum(rs.getString("ordernum")); 199 | order.setItems(items); 200 | order.setMoney(rs.getDouble("money")); 201 | order.setOrdernum(rs.getString("ordernum")); 202 | order.setQuantity(rs.getInt("quantity")); 203 | order.setStatus(rs.getInt("status")); 204 | order.setTime(rs.getString("time")); 205 | order.setUser(findUserByid(userId)); 206 | list.add(order); 207 | } 208 | return list; 209 | } catch (Exception e) { 210 | e.printStackTrace(); 211 | } 212 | throw new RuntimeException(""); 213 | } 214 | 215 | @Override 216 | public List findOrders() { 217 | try { 218 | PreparedStatement prepareStatement = connection 219 | .prepareStatement("select * from orders order by ordernum desc"); 220 | ResultSet rs = prepareStatement.executeQuery(); 221 | List list = new ArrayList(); 222 | while (rs.next()) { 223 | Order order = new Order(); 224 | List items = finOrdersItemsByNum(rs.getString("ordernum")); 225 | order.setItems(items); 226 | order.setMoney(rs.getDouble("money")); 227 | order.setOrdernum(rs.getString("ordernum")); 228 | order.setQuantity(rs.getInt("quantity")); 229 | order.setStatus(rs.getInt("status")); 230 | order.setTime(rs.getString("time")); 231 | order.setUser(findUserByid(rs.getString("userId"))); 232 | list.add(order); 233 | } 234 | return list; 235 | } catch (Exception e) { 236 | e.printStackTrace(); 237 | } 238 | throw new RuntimeException(""); 239 | } 240 | 241 | @Override 242 | public void faHuo(String ordernum) { 243 | try { 244 | PreparedStatement prepareStatement = connection 245 | .prepareStatement("update orders set status = 1 where ordernum=?"); 246 | prepareStatement.setString(1, ordernum); 247 | prepareStatement.executeUpdate(); 248 | } catch (Exception e) { 249 | e.printStackTrace(); 250 | } 251 | } 252 | 253 | } 254 | -------------------------------------------------------------------------------- /src/cn/xh/web/controller/ClientServlet.java: -------------------------------------------------------------------------------- 1 | package cn.xh.web.controller; 2 | 3 | import java.io.IOException; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | 7 | import javax.servlet.ServletException; 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 | 14 | import cn.xh.domain.Book; 15 | import cn.xh.domain.Category; 16 | import cn.xh.domain.Favorite; 17 | import cn.xh.domain.User; 18 | import cn.xh.service.ClientService; 19 | import cn.xh.service.ManagerService; 20 | import cn.xh.service.impl.ClientServiceImpl; 21 | import cn.xh.service.impl.ManagerServiceImpl; 22 | import cn.xh.web.formbean.Cart; 23 | import cn.xh.web.formbean.CartItem; 24 | 25 | @WebServlet("/client/ClientServlet") 26 | public class ClientServlet extends HttpServlet { 27 | private ClientService service = new ClientServiceImpl(); 28 | private ManagerService managerService = new ManagerServiceImpl(); 29 | 30 | @Override 31 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 32 | req.setCharacterEncoding("UTF-8"); 33 | resp.setContentType("text/html;charset=UTF-8"); 34 | String op = req.getParameter("op");// 得到传过来的请求 35 | if (op != null && !op.equals("")) { 36 | // 登录 37 | if (op.equals("login")) { 38 | login(req, resp); 39 | } 40 | // 注销 41 | if (op.equals("layout")) { 42 | layout(req, resp); 43 | } 44 | // 注册 45 | if (op.equals("register")) { 46 | register(req, resp); 47 | } 48 | // 文学艺术类书籍列表 49 | if (op.equals("category")) { 50 | getCategoryBook(req, resp); 51 | } 52 | 53 | // 个人信息修改 54 | if (op.equals("personInformation")) { 55 | personInformation(req, resp); 56 | } 57 | // 修改密码 58 | if (op.equals("personPassword")) { 59 | personPassword(req, resp); 60 | } 61 | // 搜索框 62 | if (op.equals("search")) { 63 | search(req, resp); 64 | } 65 | // 详情页面 66 | if (op.equals("particulars")) { 67 | particulars(req, resp); 68 | } 69 | // 添加购物车 70 | if (op.equals("addCart")) { 71 | addCart(req, resp); 72 | } 73 | // 删除购物车中的购物项 74 | if (op.equals("delItem")) { 75 | delItem(req, resp); 76 | } 77 | // 修改购物项数量 78 | if (op.equals("changeNum")) { 79 | changeNum(req, resp); 80 | } 81 | // 添加收藏夹 82 | if (op.equals("addfavorite")) { 83 | addfavorite(req, resp); 84 | } 85 | // 显示收藏夹 86 | if (op.equals("showfavorite")) { 87 | showfavorite(req, resp); 88 | } 89 | // 删除收藏夹 90 | if (op.equals("delFavorite")) { 91 | delFavorite(req, resp); 92 | } 93 | // 删除收藏夹 94 | if (op.equals("buyNow")) { 95 | buNow(req, resp); 96 | } 97 | 98 | } 99 | } 100 | 101 | private void delFavorite(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { 102 | String book_id = req.getParameter("book_id"); 103 | service.delFavorite(book_id); 104 | HttpSession session = req.getSession(); 105 | List lists = (List) session.getAttribute("favorite"); 106 | Iterator iterator = lists.iterator(); 107 | while (iterator.hasNext()) { 108 | Favorite favorite = iterator.next(); 109 | if (book_id.equals(favorite.getBook().getBook_id())) { 110 | iterator.remove();// 使用迭代器的删除方法删除 111 | } 112 | } 113 | resp.sendRedirect(req.getContextPath() + "/favorite.jsp"); 114 | } 115 | 116 | private void showfavorite(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 117 | HttpSession session = req.getSession(); 118 | User user = (User) session.getAttribute("user"); 119 | List favorites = service.findFavoriteByUserId(user); 120 | session.setAttribute("favorite", favorites); 121 | req.getRequestDispatcher("/favorite.jsp").forward(req, resp); 122 | } 123 | 124 | private void addfavorite(HttpServletRequest req, HttpServletResponse resp) throws IOException { 125 | HttpSession session = req.getSession(); 126 | User user = (User) session.getAttribute("user"); 127 | String user_id = user.getId(); 128 | String book_id = req.getParameter("book_id"); 129 | boolean isExit = service.findFavorite(user_id, book_id); 130 | if (isExit == false) { 131 | service.addfavorite(user_id, book_id); 132 | } 133 | } 134 | 135 | private void changeNum(HttpServletRequest req, HttpServletResponse resp) throws IOException { 136 | String num = req.getParameter("num"); 137 | String book_id = req.getParameter("book_id"); 138 | // 取出购物车 139 | Cart cart = (Cart) req.getSession().getAttribute("cart"); 140 | CartItem item = cart.getItmes().get(book_id); 141 | item.setQuantity(Integer.parseInt(num)); 142 | resp.sendRedirect(req.getContextPath() + "/showCart.jsp"); 143 | 144 | } 145 | 146 | private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 147 | String username = req.getParameter("username"); 148 | String password = req.getParameter("password"); 149 | HttpSession session = req.getSession(); 150 | User user = service.login(username, password); 151 | if (user.getUsername() != null && user.getUsername() != "") { 152 | req.setAttribute("message", "登陆成功"); 153 | session.setAttribute("user", user); 154 | req.getRequestDispatcher("/message.jsp").forward(req, resp); 155 | } else { 156 | req.setAttribute("message", "用户名或密码错误,请重新登录"); 157 | req.getRequestDispatcher("/message.jsp").forward(req, resp); 158 | } 159 | } 160 | 161 | private void layout(HttpServletRequest req, HttpServletResponse resp) { 162 | try { 163 | HttpSession session = req.getSession(); 164 | session.removeAttribute("user");// 获取session对象,从session中移除登陆信息 165 | resp.sendRedirect("/client/ClientServlet?op=category"); 166 | } catch (Exception e) { 167 | e.printStackTrace(); 168 | } 169 | } 170 | 171 | private void register(HttpServletRequest req, HttpServletResponse resp) { 172 | try { 173 | String username = req.getParameter("username"); 174 | String password = req.getParameter("password"); 175 | String name = req.getParameter("name"); 176 | String sex = req.getParameter("sex"); 177 | String tel = req.getParameter("tel"); 178 | String address = req.getParameter("address"); 179 | 180 | boolean isExist = false;// 判断是否存在该用户 181 | 182 | if (!username.equals("") && !password.equals("")) { 183 | isExist = service.register(username, password, name, sex, tel, address); 184 | if (isExist == true) { 185 | resp.getWriter().write("该用户已经注册,请直接"); 186 | resp.getWriter().write("登录"); 187 | } else { 188 | resp.getWriter().write("注册成功!"); 189 | resp.getWriter().write("2s后跳往登录页"); 190 | resp.setHeader("Refresh", "2;URL=" + req.getContextPath() + "/client/ClientServlet?op=category"); 191 | } 192 | } 193 | } catch (Exception e) { 194 | e.printStackTrace(); 195 | } 196 | } 197 | 198 | private void getCategoryBook(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 199 | List books = service.getCategoryBook(req.getParameter("cid"));// 文学艺术类书籍 200 | req.setAttribute("books", books); 201 | List categoryList= managerService.findAllCategory(); 202 | req.setAttribute("categoryList", categoryList); 203 | req.getRequestDispatcher("/showBook.jsp").forward(req, resp); 204 | } 205 | 206 | private void personInformation(HttpServletRequest req, HttpServletResponse resp) 207 | throws ServletException, IOException { 208 | String username = req.getParameter("username"); 209 | String name = req.getParameter("name"); 210 | String sex = req.getParameter("sex"); 211 | String tel = req.getParameter("tel"); 212 | String address = req.getParameter("address"); 213 | 214 | service.personInformation(username, name, sex, tel, address); 215 | resp.getWriter().write("
修改成功!
"); 217 | } 218 | 219 | private void personPassword(HttpServletRequest req, HttpServletResponse resp) throws IOException { 220 | String username = req.getParameter("username"); 221 | String password = req.getParameter("password"); 222 | String repassword = req.getParameter("repassword"); 223 | 224 | service.personPassword(password, username); 225 | resp.getWriter().write("
修改成功!
"); 227 | } 228 | 229 | private void search(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 230 | String search = req.getParameter("search"); 231 | List searchmessage = service.search(search); 232 | req.setAttribute("books", searchmessage); 233 | req.getRequestDispatcher("/showBook.jsp").forward(req, resp); 234 | } 235 | 236 | private void particulars(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 237 | String book_id = req.getParameter("book_id"); 238 | Book book = findBookById(book_id); 239 | req.setAttribute("book", book); 240 | req.getRequestDispatcher("/particulars.jsp").forward(req, resp); 241 | } 242 | 243 | // 通过书籍id找到书籍信息 244 | private Book findBookById(String book_id) { 245 | Book book = service.findBookById(book_id); 246 | return book; 247 | } 248 | 249 | private void addCart(HttpServletRequest req, HttpServletResponse resp) throws IOException { 250 | String book_id = req.getParameter("book_id"); 251 | Book book = findBookById(book_id); 252 | 253 | HttpSession session = req.getSession(); 254 | Cart cart = (Cart) session.getAttribute("cart"); 255 | if (cart == null) { 256 | cart = new Cart(); 257 | session.setAttribute("cart", cart); 258 | } 259 | cart.addBook(book); 260 | } 261 | 262 | private void delItem(HttpServletRequest req, HttpServletResponse resp) throws IOException { 263 | String book_id = req.getParameter("book_id"); 264 | Cart cart = (Cart) req.getSession().getAttribute("cart"); 265 | cart.getItmes().remove(book_id); 266 | resp.sendRedirect(req.getContextPath() + "/showCart.jsp"); 267 | } 268 | 269 | private void buNow(HttpServletRequest req, HttpServletResponse resp) throws IOException { 270 | String book_id = req.getParameter("book_id"); 271 | Book book = findBookById(book_id); 272 | HttpSession session = req.getSession(); 273 | Cart cart = new Cart(); 274 | session.setAttribute("buyNowBook", cart); 275 | cart.addBook(book); 276 | resp.sendRedirect(req.getContextPath() + "/buyNow.jsp"); 277 | } 278 | 279 | @Override 280 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 281 | doGet(req, resp); 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /WebContent/header1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8" %> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 | 5 | 6 | 7 | 8 | 导航条 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 12 | ; 13 | %> 14 | 15 | 16 | 17 | 18 | 19 | 20 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /src/cn/xh/dao/impl/ManagerDaoImpl.java: -------------------------------------------------------------------------------- 1 | package cn.xh.dao.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import com.sun.xml.internal.ws.api.addressing.AddressingVersion.EPR; 10 | 11 | import cn.xh.dao.ManagerDao; 12 | import cn.xh.domain.Administrator; 13 | import cn.xh.domain.Book; 14 | import cn.xh.domain.Category; 15 | import cn.xh.domain.User; 16 | import cn.xh.util.JDBCUtil; 17 | 18 | public class ManagerDaoImpl implements ManagerDao { 19 | 20 | // 管理员登录 21 | @Override 22 | public Administrator login(String username, String password) { 23 | Administrator admin = new Administrator(); 24 | try { 25 | Connection connection = JDBCUtil.getConnection(); 26 | PreparedStatement prepareStatement = connection 27 | .prepareStatement("select * from administrator where admin_username=? and admin_password=?"); 28 | prepareStatement.setString(1, username); 29 | prepareStatement.setString(2, password); 30 | ResultSet rs = prepareStatement.executeQuery(); 31 | if (rs.next()) { 32 | admin.setUsername(rs.getString("admin_username")); 33 | admin.setPassword(rs.getString("admin_password")); 34 | admin.setName(rs.getString("admin_name")); 35 | admin.setSex(rs.getString("admin_sex")); 36 | admin.setTel(rs.getString("admin_tel")); 37 | } 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | return admin; 42 | } 43 | 44 | // 管理员信息修改 45 | @Override 46 | public void managerInformation(Administrator admin) { 47 | try { 48 | Connection connection = JDBCUtil.getConnection(); 49 | PreparedStatement prepareStatement = connection.prepareStatement( 50 | "update administrator set admin_name=?, admin_sex=?, admin_tel=? where admin_username=? "); 51 | prepareStatement.setString(1, admin.getName()); 52 | prepareStatement.setString(2, admin.getSex()); 53 | prepareStatement.setString(3, admin.getTel()); 54 | prepareStatement.setString(4, admin.getUsername()); 55 | prepareStatement.executeUpdate(); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | 61 | // 管理员登录密码修改 62 | @Override 63 | public void managerPassword(Administrator admin) { 64 | try { 65 | Connection connection = JDBCUtil.getConnection(); 66 | PreparedStatement prepareStatement = connection 67 | .prepareStatement("update administrator set admin_password=? where admin_username=?"); 68 | prepareStatement.setString(1, admin.getPassword()); 69 | prepareStatement.setString(2, admin.getUsername()); 70 | prepareStatement.executeUpdate(); 71 | 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | } 76 | 77 | // 获得所有书籍分类信息 78 | @Override 79 | public List findAllCategory() { 80 | List list = new ArrayList(); 81 | try { 82 | Connection connection = JDBCUtil.getConnection(); 83 | PreparedStatement preparedStatement = connection.prepareStatement("select * from category"); 84 | ResultSet rs = preparedStatement.executeQuery(); 85 | while (rs.next()) { 86 | Category category = new Category(); 87 | category.setCategory_id(rs.getString("category_id")); 88 | category.setCategory_name(rs.getString("category_name")); 89 | category.setCategory_desc(rs.getString("category_desc")); 90 | list.add(category); 91 | } 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | } 95 | return list; 96 | } 97 | 98 | // 通过分类id找到分类信息 99 | @Override 100 | public Category findCategoryById(String categoryid) { 101 | Category category = new Category(); 102 | try { 103 | Connection connection = JDBCUtil.getConnection(); 104 | PreparedStatement prepareStatement = connection 105 | .prepareStatement("select * from category where category_id = ?"); 106 | prepareStatement.setString(1, categoryid); 107 | ResultSet rs = prepareStatement.executeQuery(); 108 | if (rs.next()) { 109 | 110 | category.setCategory_id(rs.getString("category_id")); 111 | category.setCategory_name(rs.getString("category_name")); 112 | category.setCategory_desc(rs.getString("category_desc")); 113 | } 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | return category; 118 | } 119 | 120 | // 添加图书 121 | @Override 122 | public void addBook(Book book) { 123 | try { 124 | Connection connection = JDBCUtil.getConnection(); 125 | PreparedStatement prepareStatement = connection 126 | .prepareStatement("insert into bookdb values(?,?,?,?,?,?,?,?,?,?,?)"); 127 | prepareStatement.setString(1, book.getBook_id()); 128 | prepareStatement.setString(2, book.getBook_name()); 129 | prepareStatement.setString(3, book.getBook_author()); 130 | prepareStatement.setString(4, book.getBook_press()); 131 | prepareStatement.setString(5, book.getCategory().getCategory_id()); 132 | prepareStatement.setString(6, book.getFilename()); 133 | prepareStatement.setString(7, book.getPath()); 134 | prepareStatement.setString(8, book.getBook_desc()); 135 | prepareStatement.setDouble(9, book.getBook_price()); 136 | prepareStatement.setInt(10, book.getBook_kunumber()); 137 | prepareStatement.setInt(11, 0); 138 | prepareStatement.executeUpdate(); 139 | } catch (Exception e) { 140 | e.printStackTrace(); 141 | } 142 | } 143 | 144 | // 添加书籍分类 145 | @Override 146 | public void addCategory(Category category) { 147 | try { 148 | Connection connection = JDBCUtil.getConnection(); 149 | PreparedStatement prepareStatement = connection.prepareStatement("insert into category values(?,?,?)"); 150 | prepareStatement.setString(1, category.getCategory_id()); 151 | prepareStatement.setString(2, category.getCategory_name()); 152 | prepareStatement.setString(3, category.getCategory_desc()); 153 | prepareStatement.executeUpdate(); 154 | } catch (Exception e) { 155 | e.printStackTrace(); 156 | } 157 | } 158 | 159 | //分类书籍 160 | @Override 161 | public List getCategoryBook(String cid) { 162 | ClientDaoImpl clientDaoImpl = new ClientDaoImpl(); 163 | return clientDaoImpl.getCategoryBook(cid); 164 | } 165 | 166 | 167 | // 根据书籍id找到书籍信息 168 | @Override 169 | public Book findBookById(String book_id) { 170 | Book book = new Book(); 171 | try { 172 | Connection connection = JDBCUtil.getConnection(); 173 | PreparedStatement prepareStatement = connection.prepareStatement("select * from bookdb where book_id = ?"); 174 | prepareStatement.setString(1, book_id); 175 | ResultSet rs = prepareStatement.executeQuery(); 176 | if (rs.next()) { 177 | book.setBook_id(book_id); 178 | book.setBook_name(rs.getString("book_name")); 179 | book.setBook_author(rs.getString("book_author")); 180 | book.setBook_press(rs.getString("book_press")); 181 | Category category = findCategoryById(rs.getString("book_category")); 182 | book.setCategory(category); 183 | book.setFilename(rs.getString("filename")); 184 | book.setPath(rs.getString("path")); 185 | book.setBook_desc(rs.getString("book_desc")); 186 | book.setBook_price(rs.getDouble("book_price")); 187 | book.setBook_kunumber(rs.getInt("book_kunumber")); 188 | book.setBook_xiaonumber(rs.getInt("book_xiaonumber")); 189 | } 190 | } catch (Exception e) { 191 | e.printStackTrace(); 192 | } 193 | return book; 194 | } 195 | 196 | // 删除书籍 197 | @Override 198 | public void delBook(String book_id) { 199 | try { 200 | Connection connection = JDBCUtil.getConnection(); 201 | PreparedStatement prepareStatement = connection.prepareStatement(" delete from bookdb where book_id=?"); 202 | prepareStatement.setString(1, book_id); 203 | prepareStatement.executeUpdate(); 204 | } catch (Exception e) { 205 | e.printStackTrace(); 206 | } 207 | } 208 | 209 | @Override 210 | public void editBook(String book_id, String book_name, String book_author, String book_press, String book_desc, 211 | double book_price, String book_kunumber) { 212 | try { 213 | Connection connection = JDBCUtil.getConnection(); 214 | PreparedStatement prepareStatement = connection.prepareStatement( 215 | "update bookdb set book_name=?,book_author=?,book_press=?,book_desc=?,book_price=?,book_kunumber=? where book_id=?"); 216 | prepareStatement.setString(1, book_name); 217 | prepareStatement.setString(2, book_author); 218 | prepareStatement.setString(3, book_press); 219 | prepareStatement.setString(4, book_desc); 220 | prepareStatement.setDouble(5, book_price); 221 | prepareStatement.setString(6, book_kunumber); 222 | prepareStatement.setString(7, book_id); 223 | prepareStatement.executeUpdate(); 224 | 225 | } catch (Exception e) { 226 | e.printStackTrace(); 227 | } 228 | 229 | } 230 | 231 | @Override 232 | public void editCategory(Category category) { 233 | try { 234 | Connection connection = JDBCUtil.getConnection(); 235 | PreparedStatement prepareStatement = connection 236 | .prepareStatement("update category set category_name=?,category_desc=? where category_id=?"); 237 | prepareStatement.setString(1, category.getCategory_name()); 238 | prepareStatement.setString(2, category.getCategory_desc()); 239 | prepareStatement.setString(3, category.getCategory_id()); 240 | prepareStatement.executeUpdate(); 241 | } catch (Exception e) { 242 | e.printStackTrace(); 243 | } 244 | } 245 | 246 | @Override 247 | public void delCategory(String category_id) { 248 | try { 249 | Connection connection = JDBCUtil.getConnection(); 250 | PreparedStatement prepareStatement = connection 251 | .prepareStatement("delete from category where category_id=?"); 252 | prepareStatement.setString(1, category_id); 253 | prepareStatement.executeUpdate(); 254 | } catch (Exception e) { 255 | e.printStackTrace(); 256 | } 257 | 258 | } 259 | 260 | @Override 261 | public List findUsers() { 262 | try { 263 | Connection connection = JDBCUtil.getConnection(); 264 | PreparedStatement prepareStatement = connection.prepareStatement("select * from user"); 265 | ResultSet rs = prepareStatement.executeQuery(); 266 | List users = new ArrayList(); 267 | while (rs.next()) { 268 | User user = new User(); 269 | user.setAddress(rs.getString("user_address")); 270 | user.setId(rs.getString("user_id")); 271 | user.setName(rs.getString("user_name")); 272 | user.setPassword(rs.getString("user_password")); 273 | user.setSex(rs.getString("user_sex")); 274 | user.setTel(rs.getString("user_tel")); 275 | user.setUsername(rs.getString("user_username")); 276 | users.add(user); 277 | } 278 | return users; 279 | } catch (Exception e) { 280 | e.printStackTrace(); 281 | } 282 | throw new RuntimeException(); 283 | } 284 | 285 | // 添加管理人员 286 | @Override 287 | public void addAdmin(Administrator admin) { 288 | try { 289 | Connection connection = JDBCUtil.getConnection(); 290 | PreparedStatement prepareStatement = connection 291 | .prepareStatement("insert into administrator values(?,?,?,?,?)"); 292 | prepareStatement.setString(1, admin.getUsername()); 293 | prepareStatement.setString(2, admin.getPassword()); 294 | prepareStatement.setString(3, admin.getName()); 295 | prepareStatement.setString(4, admin.getSex()); 296 | prepareStatement.setString(5, admin.getTel()); 297 | 298 | prepareStatement.executeUpdate(); 299 | } catch (Exception e) { 300 | e.printStackTrace(); 301 | } 302 | 303 | } 304 | 305 | // 书籍销售情况 306 | @Override 307 | public List sales() { 308 | try { 309 | Connection connection = JDBCUtil.getConnection(); 310 | PreparedStatement prepareStatement = connection 311 | .prepareStatement("select * from bookdb where book_xiaonumber>0 order by book_xiaonumber desc"); 312 | ResultSet rs = prepareStatement.executeQuery(); 313 | List books = new ArrayList(); 314 | while (rs.next()) { 315 | Book book = new Book(); 316 | book.setBook_id(rs.getString("book_id")); 317 | book.setBook_name(rs.getString("book_name")); 318 | book.setBook_author(rs.getString("book_author")); 319 | book.setBook_press(rs.getString("book_press")); 320 | Category category = findCategoryById(rs.getString("book_category")); 321 | book.setCategory(category); 322 | book.setFilename(rs.getString("filename")); 323 | book.setPath(rs.getString("path")); 324 | book.setBook_desc(rs.getString("book_desc")); 325 | book.setBook_price(rs.getDouble("book_price")); 326 | book.setBook_kunumber(rs.getInt("book_kunumber")); 327 | book.setBook_xiaonumber(rs.getInt("book_xiaonumber")); 328 | books.add(book); 329 | } 330 | return books; 331 | } catch (Exception e) { 332 | e.printStackTrace(); 333 | } 334 | throw new RuntimeException(); 335 | } 336 | 337 | } 338 | -------------------------------------------------------------------------------- /WebContent/header.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8" %> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 | 5 | 6 | 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 10 | ; 11 | %> 12 | 13 | 新华书店图书销售管理系统 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 179 |
180 | 181 |
182 | 183 |
184 | 241 |
242 |
243 | 244 | 245 | 246 | --------------------------------------------------------------------------------