├── lib ├── javax.ejb.jar ├── javax.jms.jar ├── javax.servlet.jar ├── javax.resource.jar ├── javax.annotation.jar ├── javax.persistence.jar ├── javax.servlet.jsp.jar ├── javax.transaction.jar ├── commons-logging-1.1.3.jar ├── javax.servlet.jsp.jstl.jar ├── spring-core-3.2.5.RELEASE.jar ├── spring-beans-3.2.5.RELEASE.jar ├── spring-context-3.2.5.RELEASE.jar └── spring-expression-3.2.5.RELEASE.jar ├── web ├── book_photo │ ├── ejb.jpg │ ├── j2ee.jpg │ ├── java.gif │ ├── jsf.jpg │ ├── oracle.gif │ ├── spring.gif │ ├── javamail.gif │ ├── javaweb1.gif │ ├── javaweb2.gif │ └── javascript.gif ├── WEB-INF │ ├── lib │ │ ├── jstl.jar │ │ ├── standard.jar │ │ ├── c3p0-0.9.2-pre1.jar │ │ ├── commons-io-1.4.jar │ │ ├── commons-logging.jar │ │ ├── commons-dbutils-1.2.jar │ │ ├── mchange-commons-0.2.jar │ │ ├── commons-beanutils-1.8.0.jar │ │ ├── commons-fileupload-1.2.1.jar │ │ └── mysql-connector-java-5.0.8-bin.jar │ ├── classes │ │ ├── junit │ │ │ ├── Cat.class │ │ │ ├── Dog.class │ │ │ ├── Test.class │ │ │ ├── demo.class │ │ │ ├── Animal.class │ │ │ ├── Demo2.class │ │ │ ├── Demo3.class │ │ │ ├── Person.class │ │ │ ├── Test2.class │ │ │ ├── BookDemo.class │ │ │ ├── PersonDao.class │ │ │ ├── UserDemo.class │ │ │ ├── function.class │ │ │ ├── CategoryDemo.class │ │ │ ├── InjectPerson.class │ │ │ └── MyAnnotation.class │ │ ├── ouzicheng │ │ │ ├── Person.class │ │ │ ├── test111.class │ │ │ ├── XiaoMing.class │ │ │ ├── XiaoMingProxy$1.class │ │ │ └── XiaoMingProxy.class │ │ ├── zhongfucheng │ │ │ ├── dao │ │ │ │ ├── BookDao.class │ │ │ │ ├── OrderDao.class │ │ │ │ ├── UserDao.class │ │ │ │ ├── CategoryDao.class │ │ │ │ └── impl │ │ │ │ │ ├── BookDaoImpl.class │ │ │ │ │ ├── OrderDaoImpl.class │ │ │ │ │ ├── UserDaoImpl.class │ │ │ │ │ └── CategoryDAOImpl.class │ │ │ ├── domain │ │ │ │ ├── Book.class │ │ │ │ ├── Cart.class │ │ │ │ ├── Order.class │ │ │ │ ├── Page.class │ │ │ │ ├── User.class │ │ │ │ ├── CartItem.class │ │ │ │ ├── Category.class │ │ │ │ ├── OrderItem.class │ │ │ │ └── Privilege.class │ │ │ ├── utils │ │ │ │ ├── Utils2DB.class │ │ │ │ ├── WebUtils.class │ │ │ │ ├── DaoFactory.class │ │ │ │ ├── permission.class │ │ │ │ ├── PrivilegeException.class │ │ │ │ ├── ServiceDaoFactory.class │ │ │ │ └── ServiceDaoFactory$1.class │ │ │ ├── web │ │ │ │ ├── client │ │ │ │ │ ├── listCart.class │ │ │ │ │ ├── BuyServlet.class │ │ │ │ │ ├── LookOrder.class │ │ │ │ │ ├── UserServlet.class │ │ │ │ │ ├── IndexServlet.class │ │ │ │ │ ├── ListBookServlet.class │ │ │ │ │ └── CreateOrderServlet.class │ │ │ │ ├── filter │ │ │ │ │ ├── HtmlFilter.class │ │ │ │ │ ├── MyRequest.class │ │ │ │ │ ├── MyRequest2.class │ │ │ │ │ └── CharacterEncodingFilter.class │ │ │ │ └── manager │ │ │ │ │ ├── BookServlet.class │ │ │ │ │ ├── OrderServlet.class │ │ │ │ │ ├── CategoryServlet.class │ │ │ │ │ ├── SendOutServlet.class │ │ │ │ │ └── orderItemServlet.class │ │ │ └── service │ │ │ │ ├── BussinessServiceDao.class │ │ │ │ └── impl │ │ │ │ └── BussinessServiceImpl.class │ │ └── c3p0-config.xml │ └── web.xml ├── client │ ├── head.css │ ├── body.css │ ├── listOrder.jsp │ ├── register.jsp │ ├── listCart.jsp │ ├── body.jsp │ ├── head.jsp │ └── page.jsp ├── background │ ├── body.jsp │ ├── head.jsp │ ├── addCategory.jsp │ ├── listDetail.jsp │ ├── lookCategory.jsp │ ├── left.jsp │ ├── listOrder.jsp │ ├── listBook.jsp │ ├── addBook.jsp │ └── page.jsp ├── message.jsp ├── index.jsp └── manager.jsp ├── .idea ├── copyright │ └── profiles_settings.xml ├── markdown-navigator │ └── profiles_settings.xml ├── vcs.xml ├── modules.xml ├── misc.xml ├── libraries │ ├── lib.xml │ ├── springCore.xml │ └── Java_EE_6_Java_EE_6.xml ├── compiler.xml ├── artifacts │ └── ajax_war_exploded.xml ├── encodings.xml ├── dataSources.xml ├── markdown-navigator.xml ├── dataSources │ ├── 676d6293-663d-4ed2-9b3f-6a160569295a.xml │ └── a269c7c2-c473-4b3b-b36e-9c3ef04bb431.xml ├── uiDesigner.xml └── dataSources.ids ├── src ├── junit │ ├── Dog.java │ ├── Cat.java │ ├── Animal.java │ ├── InjectPerson.java │ ├── demo.java │ ├── MyAnnotation.java │ ├── Demo2.java │ ├── PersonDao.java │ ├── Person.java │ ├── function.java │ ├── BookDaoImplTest.java │ ├── Demo3.java │ ├── UserDemo.java │ ├── CategoryDemo.java │ ├── BookDemo.java │ ├── Test2.java │ └── Test.java ├── zhongfucheng │ ├── utils │ │ ├── permission.java │ │ ├── PrivilegeException.java │ │ ├── DaoFactory.java │ │ ├── Utils2DB.java │ │ ├── WebUtils.java │ │ └── ServiceDaoFactory.java │ ├── dao │ │ ├── CategoryDao.java │ │ ├── UserDao.java │ │ ├── OrderDao.java │ │ ├── BookDao.java │ │ └── impl │ │ │ ├── CategoryDAOImpl.java │ │ │ ├── UserDaoImpl.java │ │ │ ├── BookDaoImpl.java │ │ │ └── OrderDaoImpl.java │ ├── domain │ │ ├── Category.java │ │ ├── CartItem.java │ │ ├── Privilege.java │ │ ├── OrderItem.java │ │ ├── User.java │ │ ├── Cart.java │ │ ├── Order.java │ │ ├── Book.java │ │ └── Page.java │ ├── web │ │ ├── manager │ │ │ ├── SendOutServlet.java │ │ │ ├── orderItemServlet.java │ │ │ ├── OrderServlet.java │ │ │ ├── CategoryServlet.java │ │ │ └── BookServlet.java │ │ ├── client │ │ │ ├── listCart.java │ │ │ ├── IndexServlet.java │ │ │ ├── ListBookServlet.java │ │ │ ├── CreateOrderServlet.java │ │ │ ├── LookOrder.java │ │ │ ├── BuyServlet.java │ │ │ └── UserServlet.java │ │ └── filter │ │ │ ├── CharacterEncodingFilter.java │ │ │ └── HtmlFilter.java │ └── service │ │ ├── BussinessServiceDao.java │ │ └── impl │ │ └── BussinessServiceImpl.java └── c3p0-config.xml ├── README.md └── ajax.iml /lib/javax.ejb.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.ejb.jar -------------------------------------------------------------------------------- /lib/javax.jms.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.jms.jar -------------------------------------------------------------------------------- /lib/javax.servlet.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.servlet.jar -------------------------------------------------------------------------------- /lib/javax.resource.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.resource.jar -------------------------------------------------------------------------------- /web/book_photo/ejb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/ejb.jpg -------------------------------------------------------------------------------- /web/book_photo/j2ee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/j2ee.jpg -------------------------------------------------------------------------------- /web/book_photo/java.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/java.gif -------------------------------------------------------------------------------- /web/book_photo/jsf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/jsf.jpg -------------------------------------------------------------------------------- /lib/javax.annotation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.annotation.jar -------------------------------------------------------------------------------- /lib/javax.persistence.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.persistence.jar -------------------------------------------------------------------------------- /lib/javax.servlet.jsp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.servlet.jsp.jar -------------------------------------------------------------------------------- /lib/javax.transaction.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.transaction.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/jstl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/jstl.jar -------------------------------------------------------------------------------- /web/book_photo/oracle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/oracle.gif -------------------------------------------------------------------------------- /web/book_photo/spring.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/spring.gif -------------------------------------------------------------------------------- /web/WEB-INF/lib/standard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/standard.jar -------------------------------------------------------------------------------- /web/book_photo/javamail.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/javamail.gif -------------------------------------------------------------------------------- /web/book_photo/javaweb1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/javaweb1.gif -------------------------------------------------------------------------------- /web/book_photo/javaweb2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/javaweb2.gif -------------------------------------------------------------------------------- /lib/commons-logging-1.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/commons-logging-1.1.3.jar -------------------------------------------------------------------------------- /lib/javax.servlet.jsp.jstl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/javax.servlet.jsp.jstl.jar -------------------------------------------------------------------------------- /web/book_photo/javascript.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/book_photo/javascript.gif -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /lib/spring-core-3.2.5.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/spring-core-3.2.5.RELEASE.jar -------------------------------------------------------------------------------- /lib/spring-beans-3.2.5.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/spring-beans-3.2.5.RELEASE.jar -------------------------------------------------------------------------------- /lib/spring-context-3.2.5.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/spring-context-3.2.5.RELEASE.jar -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Cat.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Cat.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Dog.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Dog.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Test.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/demo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/demo.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/c3p0-0.9.2-pre1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/c3p0-0.9.2-pre1.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-io-1.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/commons-io-1.4.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-logging.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/commons-logging.jar -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Animal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Animal.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Demo2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Demo2.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Demo3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Demo3.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Person.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/Test2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/Test2.class -------------------------------------------------------------------------------- /lib/spring-expression-3.2.5.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/lib/spring-expression-3.2.5.RELEASE.jar -------------------------------------------------------------------------------- /src/junit/Dog.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | /** 4 | * Created by ozc on 2017/4/19. 5 | */ 6 | public class Dog extends Animal { 7 | } 8 | -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/BookDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/BookDemo.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/PersonDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/PersonDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/UserDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/UserDemo.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/function.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/function.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-dbutils-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/commons-dbutils-1.2.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/mchange-commons-0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/mchange-commons-0.2.jar -------------------------------------------------------------------------------- /src/junit/Cat.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | /** 4 | * Created by ozc on 2017/4/19. 5 | */ 6 | public class Cat extends Animal { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /web/WEB-INF/classes/ouzicheng/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/ouzicheng/Person.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/ouzicheng/test111.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/ouzicheng/test111.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-beanutils-1.8.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/commons-beanutils-1.8.0.jar -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/CategoryDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/CategoryDemo.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/InjectPerson.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/InjectPerson.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/junit/MyAnnotation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/junit/MyAnnotation.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/ouzicheng/XiaoMing.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/ouzicheng/XiaoMing.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-fileupload-1.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/commons-fileupload-1.2.1.jar -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /web/WEB-INF/classes/ouzicheng/XiaoMingProxy$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/ouzicheng/XiaoMingProxy$1.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/ouzicheng/XiaoMingProxy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/ouzicheng/XiaoMingProxy.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/BookDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/BookDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/OrderDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/OrderDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/UserDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/UserDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Book.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Cart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Cart.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Order.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Order.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Page.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Page.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/User.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/Utils2DB.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/Utils2DB.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/WebUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/WebUtils.class -------------------------------------------------------------------------------- /web/client/head.css: -------------------------------------------------------------------------------- 1 | #body { 2 | position: relative; 3 | } 4 | #user { 5 | position: absolute; 6 | margin-top: 80px; 7 | margin-left: 1314px; 8 | } -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/CategoryDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/CategoryDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/CartItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/CartItem.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Category.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Category.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/OrderItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/OrderItem.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/domain/Privilege.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/domain/Privilege.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/DaoFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/DaoFactory.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/permission.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/permission.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/listCart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/listCart.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/impl/BookDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/impl/BookDaoImpl.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/impl/OrderDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/impl/OrderDaoImpl.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/impl/UserDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/impl/UserDaoImpl.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/BuyServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/BuyServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/LookOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/LookOrder.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/UserServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/UserServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/filter/HtmlFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/filter/HtmlFilter.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/filter/MyRequest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/filter/MyRequest.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/filter/MyRequest2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/filter/MyRequest2.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/dao/impl/CategoryDAOImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/dao/impl/CategoryDAOImpl.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/PrivilegeException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/PrivilegeException.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/ServiceDaoFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/ServiceDaoFactory.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/IndexServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/IndexServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/manager/BookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/manager/BookServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/manager/OrderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/manager/OrderServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/service/BussinessServiceDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/service/BussinessServiceDao.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/utils/ServiceDaoFactory$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/utils/ServiceDaoFactory$1.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/ListBookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/ListBookServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/manager/CategoryServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/manager/CategoryServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/manager/SendOutServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/manager/SendOutServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/client/CreateOrderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/client/CreateOrderServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/manager/orderItemServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/manager/orderItemServlet.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/service/impl/BussinessServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/service/impl/BussinessServiceImpl.class -------------------------------------------------------------------------------- /web/WEB-INF/classes/zhongfucheng/web/filter/CharacterEncodingFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangxiacs/BookSystem/HEAD/web/WEB-INF/classes/zhongfucheng/web/filter/CharacterEncodingFilter.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/junit/Animal.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | /** 6 | * Created by ozc on 2017/4/19. 7 | */ 8 | @Service 9 | 10 | public class Animal { 11 | 12 | 13 | public static void main(String[] args) { 14 | 15 | 16 | 17 | 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/permission.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * Created by ozc on 2017/4/25. 8 | */ 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface permission { 12 | String value(); 13 | } 14 | -------------------------------------------------------------------------------- /.idea/libraries/lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/junit/InjectPerson.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * Created by ozc on 2017/4/24. 8 | */ 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface InjectPerson { 12 | 13 | String username(); 14 | int age(); 15 | } 16 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/CategoryDao.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao; 2 | 3 | import zhongfucheng.domain.Category; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by ozc on 2017/4/12. 9 | */ 10 | public interface CategoryDao { 11 | void addCategory(Category category); 12 | 13 | Category findCategory(String id); 14 | 15 | List getAllCategory(); 16 | } 17 | -------------------------------------------------------------------------------- /src/junit/demo.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by ozc on 2017/4/20. 7 | */ 8 | 9 | @SuppressWarnings("unchecked") 10 | public class demo { 11 | 12 | public static void main(String[] args) { 13 | 14 | ArrayList arrayList = new ArrayList(); 15 | 16 | System.out.println(arrayList); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /web/background/body.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:33 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /web/message.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 12:50 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 | ${message} 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/junit/MyAnnotation.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * Created by ozc on 2017/4/20. 8 | */ 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface MyAnnotation { 12 | 13 | //定义了两个成员变量 14 | String username() default "zicheng"; 15 | int age() default 23; 16 | } 17 | -------------------------------------------------------------------------------- /src/junit/Demo2.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * Created by ozc on 2017/4/20. 8 | */ 9 | 10 | public class Demo2 { 11 | 12 | 13 | @MyAnnotation() 14 | public void add(String username, int age) { 15 | 16 | System.out.println(username + age); 17 | } 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/junit/PersonDao.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | /** 4 | * Created by ozc on 2017/4/24. 5 | */ 6 | public class PersonDao { 7 | 8 | @InjectPerson(username = "zhongfucheng",age = 20) private Person person; 9 | 10 | public Person getPerson() { 11 | return person; 12 | } 13 | 14 | public void setPerson(Person person) { 15 | 16 | this.person = person; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /web/background/head.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 |

后台管理

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao; 2 | 3 | import zhongfucheng.domain.Privilege; 4 | import zhongfucheng.domain.User; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by ozc on 2017/4/16. 10 | */ 11 | public interface UserDao { 12 | void register(User user); 13 | 14 | User login(String username, String password); 15 | 16 | User find(String id); 17 | 18 | List findUserPrivilege(String user_id); 19 | } 20 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/OrderDao.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao; 2 | 3 | import zhongfucheng.domain.Order; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by ozc on 2017/4/17. 9 | */ 10 | public interface OrderDao { 11 | void addOrder(Order order); 12 | 13 | Order findOrder(String user_id); 14 | 15 | List getAllOrder(boolean state); 16 | 17 | void updateState(String user_id); 18 | 19 | List findUserOrder(String user_id); 20 | } 21 | -------------------------------------------------------------------------------- /src/junit/Person.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | /** 4 | * Created by ozc on 2017/4/24. 5 | */ 6 | public class Person { 7 | 8 | private String username; 9 | private int age; 10 | 11 | public String getUsername() { 12 | return username; 13 | } 14 | 15 | public void setUsername(String username) { 16 | this.username = username; 17 | } 18 | 19 | public int getAge() { 20 | return age; 21 | } 22 | 23 | public void setAge(int age) { 24 | this.age = age; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/BookDao.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao; 2 | 3 | import zhongfucheng.domain.Book; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by ozc on 2017/4/12. 9 | */ 10 | public interface BookDao { 11 | void addBook(Book book); 12 | 13 | Book findBook(String id); 14 | 15 | List getPageData(int start, int end); 16 | 17 | List getPageData(int start, int end, String category_id); 18 | 19 | long getTotalRecord(); 20 | 21 | long getCategoryTotalRecord(String category_id); 22 | } 23 | -------------------------------------------------------------------------------- /src/junit/function.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by ozc on 2017/4/19. 8 | */ 9 | public abstract class function { 10 | 11 | public static void main(String[] args) { 12 | 13 | 14 | List list = new ArrayList(); 15 | List list2 = list; 16 | 17 | } 18 | 19 | 20 | //使用通配符 21 | public static void test(List list) { 22 | 23 | } 24 | 25 | //使用泛型方法 26 | public void test2(List t) { 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/PrivilegeException.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | /** 4 | * Created by ozc on 2017/4/25. 5 | */ 6 | public class PrivilegeException extends Exception { 7 | 8 | public PrivilegeException() { 9 | super(); 10 | } 11 | 12 | public PrivilegeException(String message) { 13 | super(message); 14 | } 15 | 16 | public PrivilegeException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public PrivilegeException(Throwable cause) { 21 | super(cause); 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/libraries/springCore.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/3/29 5 | Time: 17:01 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 前台页面 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | <% 21 | request 22 | 23 | %> 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/DaoFactory.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | public class DaoFactory { 7 | 8 | private static final DaoFactory factory = new DaoFactory(); 9 | private DaoFactory(){} 10 | 11 | public static DaoFactory getInstance(){ 12 | return factory; 13 | } 14 | 15 | public T createDao(String className,Class clazz){ 16 | try{ 17 | T t = (T) Class.forName(className).newInstance(); 18 | return t; 19 | }catch (Exception e) { 20 | throw new RuntimeException(e); 21 | } 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /web/background/addCategory.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 12:44 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 添加分类 12 | 13 | 14 | 15 |
16 | 17 | 分类名称:
18 | 分类描述:
19 | 20 | 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 图书管理系统【部署开发环境、解决分类、图书、前台页面模块】:https://mp.weixin.qq.com/s?__biz=MzI4Njg5MDA5NA==&mid=2247483796&idx=1&sn=9cddb5d137a6c559a98576b37322df2a&chksm=ebd74095dca0c9832fdfb040813daf24e7ce815aab83542d13a4b270078ab535354fb4be70d2#rd 2 | 3 | 图书管理系统【用户、购买、订单模块、添加权限】:https://mp.weixin.qq.com/s?__biz=MzI4Njg5MDA5NA==&mid=2247483800&idx=1&sn=b78414039ae7afe1bcff2dfe50ff451e&chksm=ebd74099dca0c98f34d6b4357dab81dd4be65eb46c6476c149a528558316c075fbcc817dd7f7#rd 4 | 5 | 图书管理系统【总结】:https://mp.weixin.qq.com/s?__biz=MzI4Njg5MDA5NA==&mid=2247483804&idx=1&sn=13f0c5cafa1a5039cdc4b534e2af408f&chksm=ebd7409ddca0c98be10214c4185dd6755a2df5e9ae6adaa2799a4088efb6180300ac7fad77f2#rd 6 | -------------------------------------------------------------------------------- /web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Refresh 8 | Refresh 9 | 1 10 | 11 | 12 | Refresh 13 | /Refresh 14 | 15 | -------------------------------------------------------------------------------- /web/manager.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 后台管理 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/junit/BookDaoImplTest.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by ozc on 2017/5/5. 7 | */ 8 | public class BookDaoImplTest { 9 | @org.junit.Test 10 | public void addBook() throws Exception { 11 | 12 | } 13 | 14 | @Test 15 | public void findBook() throws Exception { 16 | 17 | } 18 | 19 | @Test 20 | public void getPageData() throws Exception { 21 | 22 | } 23 | 24 | @Test 25 | public void getPageData1() throws Exception { 26 | 27 | } 28 | 29 | @Test 30 | public void getTotalRecord() throws Exception { 31 | 32 | } 33 | 34 | @Test 35 | public void getCategoryTotalRecord() throws Exception { 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Category.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | public class Category { 7 | private String id; 8 | private String name; 9 | private String description; 10 | 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getDescription() { 29 | return description; 30 | } 31 | 32 | public void setDescription(String description) { 33 | this.description = description; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/CartItem.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/16. 5 | */ 6 | public class CartItem { 7 | 8 | private Book book; 9 | private double price; 10 | private int quantity; 11 | 12 | public double getPrice() { 13 | return this.book.getPrice() * this.quantity; 14 | } 15 | 16 | public void setPrice(double price) { 17 | this.price = price; 18 | } 19 | 20 | public Book getBook() { 21 | return book; 22 | } 23 | 24 | public void setBook(Book book) { 25 | this.book = book; 26 | } 27 | public int getQuantity() { 28 | return quantity; 29 | } 30 | 31 | public void setQuantity(int quantity) { 32 | this.quantity = quantity; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.idea/artifacts/ajax_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/ajax_war_exploded 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /web/client/body.css: -------------------------------------------------------------------------------- 1 | #body { 2 | position: relative; 3 | } 4 | 5 | #category { 6 | border: 1px solid #000; 7 | position: absolute; 8 | width: 300px; 9 | height: 400px; 10 | float: left; 11 | left: 200px; 12 | top: 70px;; 13 | } 14 | 15 | #bookandpages { 16 | border: 1px solid #000000; 17 | position: absolute; 18 | width: 780px; 19 | height: 538px;; 20 | float: left; 21 | left: 500px; 22 | margin-left: 50px; 23 | } 24 | 25 | #books{ 26 | margin-left: 50px; 27 | margin-top: 30px; 28 | } 29 | #image{ 30 | float: left; 31 | margin-right: 40px; 32 | } 33 | #bookinfo{ 34 | float: left; 35 | } 36 | #page { 37 | height: 62px; 38 | width: 780px; 39 | position: fixed; 40 | margin-left: 549px; 41 | margin-top: 477px; 42 | text-align: center; 43 | line-height: 50px; 44 | } 45 | -------------------------------------------------------------------------------- /src/junit/Demo3.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | import java.lang.reflect.Method; 5 | 6 | /** 7 | * Created by ozc on 2017/4/21. 8 | */ 9 | public class Demo3 { 10 | 11 | 12 | public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException { 13 | 14 | //反射出该类的方法 15 | Class aClass = Demo2.class; 16 | Method method = aClass.getMethod("add", String.class, int.class); 17 | 18 | //通过该方法得到注解上的具体信息 19 | MyAnnotation annotation = method.getAnnotation(MyAnnotation.class); 20 | String username = annotation.username(); 21 | int age = annotation.age(); 22 | 23 | //将注解上的信息注入到方法上 24 | Object o = aClass.newInstance(); 25 | method.invoke(o, username, age); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /web/background/listDetail.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/17 5 | Time: 16:15 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 详细信息 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
书籍的编号价钱数量操作
${item.book_id}${item.price}${item.quantity}修改
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /.idea/libraries/Java_EE_6_Java_EE_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Privilege.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/25. 5 | */ 6 | public class Privilege { 7 | 8 | private String id ; 9 | private String name; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public boolean equals(Object o) { 29 | if (this == o) return true; 30 | if (o == null || getClass() != o.getClass()) return false; 31 | 32 | Privilege privilege = (Privilege) o; 33 | 34 | return name != null ? name.equals(privilege.name) : privilege.name == null; 35 | 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | return name != null ? name.hashCode() : 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/Utils2DB.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | import com.mchange.v2.c3p0.ComboPooledDataSource; 7 | 8 | import javax.sql.DataSource; 9 | import java.sql.Connection; 10 | import java.sql.SQLException; 11 | 12 | /** 13 | * Created by ozc on 2017/2/22. 14 | */ 15 | public class Utils2DB { 16 | 17 | private static ComboPooledDataSource comboPooledDataSource = null; 18 | 19 | static { 20 | 21 | //它会自动寻找配置文件,节点为mysql的数据库 22 | comboPooledDataSource = new ComboPooledDataSource(); 23 | } 24 | 25 | 26 | public static DataSource getDataSource() { 27 | return comboPooledDataSource ; 28 | } 29 | 30 | public static Connection connection() { 31 | try { 32 | return comboPooledDataSource.getConnection(); 33 | } catch (SQLException e) { 34 | e.printStackTrace(); 35 | throw new RuntimeException("数据库初始化失败了!"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /web/background/lookCategory.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 16:11 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 查看所有的分类 13 | 14 | 15 | 16 | 17 | 暂时还没有分类数据哦,请你添加把 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 |
分类名字分类描述操作
${category.name}${category.description} 34 | 删除 35 | 修改 36 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /web/client/listOrder.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/17 5 | Time: 15:21 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 列出订单 13 | 14 | 15 | 16 | 17 | 您还没有下过任何订单!!111111 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
下单人:订单时间订单状态订单价钱
${user.username}${order.ordertime}${order.state==false?"未发货":"已发货"}${order.price}
43 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /src/junit/UserDemo.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import org.junit.Test; 4 | import zhongfucheng.dao.UserDao; 5 | import zhongfucheng.dao.impl.UserDaoImpl; 6 | import zhongfucheng.domain.User; 7 | 8 | /** 9 | * Created by ozc on 2017/4/16. 10 | */ 11 | public class UserDemo { 12 | UserDao userDao = new UserDaoImpl(); 13 | 14 | @Test 15 | public void add() { 16 | 17 | User user = new User(); 18 | user.setId("1"); 19 | user.setUsername("zhong"); 20 | user.setPassword("123"); 21 | user.setCellphone("10085"); 22 | user.setAddress("广州萝岗"); 23 | user.setEmail("40368324234234@QQ.com"); 24 | 25 | userDao.register(user); 26 | } 27 | 28 | @Test 29 | public void find() { 30 | 31 | String id = "1"; 32 | User user = userDao.find(id); 33 | 34 | System.out.println(user.getEmail()); 35 | } 36 | 37 | @Test 38 | public void login() { 39 | String username = "zhong"; 40 | String password = "123"; 41 | User user = userDao.login(username, password); 42 | 43 | System.out.println(user.getAddress()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /web/background/left.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 | 15 | 分类管理 16 |
17 | 添加分类 18 |
19 | 查看分类 20 | 21 | 22 |
23 |
24 | 图书管理
25 | 添加图书
26 | 查看图书
27 | 28 |
29 |
30 | 31 | 订单管理
32 | 待处理订单
33 | 已发货订单
34 | 35 |
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/junit/CategoryDemo.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import org.junit.Test; 4 | import zhongfucheng.dao.CategoryDao; 5 | import zhongfucheng.dao.impl.CategoryDAOImpl; 6 | import zhongfucheng.domain.Category; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by ozc on 2017/4/12. 12 | */ 13 | public class CategoryDemo { 14 | 15 | @Test 16 | public void add() { 17 | 18 | Category category = new Category(); 19 | category.setId("2"); 20 | category.setName("数据库系列"); 21 | category.setDescription("这是数据库系列"); 22 | 23 | CategoryDao category1 = new CategoryDAOImpl(); 24 | category1.addCategory(category); 25 | 26 | } 27 | 28 | @Test 29 | public void find() { 30 | 31 | String id = "1"; 32 | CategoryDao category1 = new CategoryDAOImpl(); 33 | Category category = category1.findCategory(id); 34 | 35 | System.out.println(category.getName()); 36 | } 37 | @Test 38 | public void getAll() { 39 | 40 | 41 | CategoryDao category1 = new CategoryDAOImpl(); 42 | List categories = category1.getAllCategory(); 43 | 44 | for (Category category : categories) { 45 | System.out.println(category.getName()); 46 | } 47 | } 48 | 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/OrderItem.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/17. 5 | */ 6 | public class OrderItem { 7 | 8 | private String id; 9 | 10 | //一个订单可以对应多个订单,记住订单 11 | private String order_id; 12 | 13 | //一本书对应多个订单项,订单项一定是由书组成,记住书 14 | private String book_id; 15 | 16 | private double price; 17 | private int quantity; 18 | 19 | 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getOrder_id() { 30 | return order_id; 31 | } 32 | 33 | public void setOrder_id(String order_id) { 34 | this.order_id = order_id; 35 | } 36 | 37 | public String getBook_id() { 38 | return book_id; 39 | } 40 | 41 | public void setBook_id(String book_id) { 42 | this.book_id = book_id; 43 | } 44 | 45 | public double getPrice() { 46 | return price; 47 | } 48 | 49 | public void setPrice(double price) { 50 | this.price = price; 51 | } 52 | 53 | public int getQuantity() { 54 | return quantity; 55 | } 56 | 57 | public void setQuantity(int quantity) { 58 | this.quantity = quantity; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/manager/SendOutServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.manager; 2 | 3 | import zhongfucheng.service.BussinessServiceDao; 4 | import zhongfucheng.service.impl.BussinessServiceImpl; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Created by ozc on 2017/4/17. 15 | */ 16 | @WebServlet(name = "SendOutServlet",urlPatterns = "/SendOutServlet") 17 | public class SendOutServlet extends HttpServlet { 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 19 | 20 | BussinessServiceDao service = new BussinessServiceImpl(); 21 | String id = request.getParameter("id"); 22 | 23 | service.sendOutOrder(id); 24 | request.setAttribute("message", "已发货!"); 25 | request.getRequestDispatcher("/message.jsp").forward(request, response); 26 | return; 27 | } 28 | 29 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 30 | 31 | this.doPost(request, response); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/zhongfucheng/service/BussinessServiceDao.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.service; 2 | 3 | import zhongfucheng.domain.*; 4 | import zhongfucheng.utils.permission; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by ozc on 2017/4/25. 10 | */ 11 | public interface BussinessServiceDao { 12 | 13 | 14 | @permission("添加分类") 15 | /*添加分类*/ void addCategory(Category category); 16 | 17 | /*查找分类*/ 18 | void findCategory(String id); 19 | 20 | @permission("查找分类") 21 | /*查看分类*/ List getAllCategory(); 22 | 23 | /*添加图书*/ 24 | void addBook(Book book); 25 | 26 | /*查找图书*/ 27 | Book findBook(String id); 28 | 29 | /*获取图书的分页数据*/ 30 | Page getPageData(String currentPageCount); 31 | 32 | /*获取图书分类后的分页数据*/ 33 | Page getPageData(String currentPageCount, String category_id); 34 | 35 | void registerUser(User user); 36 | 37 | User loginUser(String username, String password); 38 | 39 | User findUser(String id); 40 | 41 | void buyBook(Cart cart, Book book); 42 | 43 | void createOrder(Cart cart, User user); 44 | 45 | Order findOrder(String user_id); 46 | 47 | List getAllOrder(boolean state); 48 | 49 | void sendOutOrder(String id); 50 | 51 | List findUserOrder(String user_id); 52 | 53 | List findUserPrivilege(String user_id); 54 | } 55 | -------------------------------------------------------------------------------- /web/client/register.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/16 5 | Time: 11:06 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 注册页面 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
用户名:
密码:
手机号码:
地址:
邮箱:
44 | 45 | 46 |
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/User.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/16. 5 | */ 6 | public class User { 7 | private String id; 8 | private String username; 9 | private String password; 10 | private String email; 11 | private String cellphone; 12 | private String address; 13 | 14 | 15 | public String getId() { 16 | return id; 17 | } 18 | 19 | public void setId(String id) { 20 | this.id = id; 21 | } 22 | 23 | public String getUsername() { 24 | return username; 25 | } 26 | 27 | public void setUsername(String username) { 28 | this.username = username; 29 | } 30 | 31 | public String getPassword() { 32 | return password; 33 | } 34 | 35 | public void setPassword(String password) { 36 | this.password = password; 37 | } 38 | 39 | public String getEmail() { 40 | return email; 41 | } 42 | 43 | public void setEmail(String email) { 44 | this.email = email; 45 | } 46 | 47 | public String getCellphone() { 48 | return cellphone; 49 | } 50 | 51 | public void setCellphone(String cellphone) { 52 | this.cellphone = cellphone; 53 | } 54 | 55 | public String getAddress() { 56 | return address; 57 | } 58 | 59 | public void setAddress(String address) { 60 | this.address = address; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /web/background/listOrder.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/17 5 | Time: 16:03 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 还没有任何订单哦! 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 49 |
下单人:订单时间订单状态订单价钱操作
${order.user_id}${order.ordertime}${order.state==false?"未发货":"已发货"}${order.price} 41 | 查看详细信息 42 | 43 | 发货 44 |
50 | 51 | 52 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/manager/orderItemServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.manager; 2 | 3 | import zhongfucheng.domain.Order; 4 | import zhongfucheng.service.BussinessServiceDao; 5 | import zhongfucheng.service.impl.BussinessServiceImpl; 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 java.io.IOException; 13 | 14 | /** 15 | * Created by ozc on 2017/4/17. 16 | */ 17 | @WebServlet(name = "orderItemServlet",urlPatterns = "/orderItemServlet") 18 | public class orderItemServlet extends HttpServlet { 19 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 20 | 21 | BussinessServiceDao service = new BussinessServiceImpl(); 22 | 23 | //得到用户想要查看详细信息的表单 24 | String order_id = request.getParameter("order_id"); 25 | 26 | Order order = service.findOrder(order_id); 27 | 28 | //将该order对象给相对应的JSP显示 29 | request.setAttribute("order", order); 30 | request.getRequestDispatcher("/background/listDetail.jsp").forward(request, response); 31 | 32 | } 33 | 34 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 35 | 36 | this.doPost(request, response); 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /web/background/listBook.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 21:01 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 查看所有图书 13 | 14 | 15 | 16 | 17 | 暂时还没有任何图书哦 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 |
书名作者价钱描述图片操作
${book.name}${book.author}${book.price}${book.description}查看图片 41 | 删除 42 | 修改 43 |
50 |
51 | 52 | 53 |
54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/junit/BookDemo.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import org.junit.Test; 4 | import zhongfucheng.dao.BookDao; 5 | import zhongfucheng.dao.impl.BookDaoImpl; 6 | import zhongfucheng.domain.Book; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by ozc on 2017/4/12. 12 | */ 13 | public class BookDemo { 14 | 15 | BookDao bookDao = new BookDaoImpl(); 16 | 17 | 18 | @Test 19 | 20 | public void add() { 21 | Book book = new Book(); 22 | book.setId("5"); 23 | book.setName("SQLServer"); 24 | book.setAuthor("我也不知道"); 25 | book.setImage("33333332432"); 26 | book.setPrice(33.22); 27 | book.setDescription("这是一本好书"); 28 | book.setCategory_id("2"); 29 | 30 | bookDao.addBook(book); 31 | } 32 | 33 | @Test 34 | public void look() { 35 | 36 | List bookList = bookDao.getPageData(3, 3); 37 | 38 | for (Book book : bookList) { 39 | System.out.println(book.getName()); 40 | } 41 | 42 | List books = bookDao.getPageData(0,2,"2"); 43 | 44 | for (Book book : books) { 45 | System.out.println(book.getName()); 46 | 47 | } 48 | } 49 | @Test 50 | public void getRecord() { 51 | System.out.println(bookDao.getTotalRecord()); 52 | } 53 | 54 | @Test 55 | public void find() { 56 | String id = "2"; 57 | Book book = bookDao.findBook(id); 58 | 59 | System.out.println(book.getName()); 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/listCart.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Cart; 4 | import zhongfucheng.domain.User; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Created by ozc on 2017/4/16. 15 | */ 16 | @WebServlet(name = "listCart",urlPatterns = "/listCart") 17 | public class listCart extends HttpServlet { 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 19 | 20 | //先判断该用户是否登陆了 21 | User user = (User) request.getSession().getAttribute("user"); 22 | if (user == null) { 23 | request.setAttribute("message", "您还没有登陆呢!"); 24 | request.getRequestDispatcher("/message.jsp").forward(request, response); 25 | return; 26 | } 27 | 28 | //如果登陆了..... 29 | Cart cart = (Cart) request.getSession().getAttribute("cart"); 30 | //把该用户的购物车给JSP页面显示 31 | request.getSession().setAttribute("cart", cart); 32 | request.getRequestDispatcher("/client/listCart.jsp").forward(request, response); 33 | 34 | 35 | } 36 | 37 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 38 | this.doPost(request, response); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /web/client/listCart.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/16 5 | Time: 17:19 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 显示购物车页面 13 | 14 | 15 | 16 | 17 | 您还没有购买过任何商品哦!!! 18 | 19 | 20 | 21 | 22 | 23 |

您购物车下有如下的商品:


24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 53 | 54 |
书名:作者:数量:价钱:
${cartItme.value.book.name}${cartItme.value.book.author}${cartItme.value.quantity}${cartItme.value.price}
总价:${cart.price}
48 | 清空购物车 49 | 51 | 生成订单 52 |
55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Cart.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by ozc on 2017/4/16. 8 | */ 9 | public class Cart { 10 | 11 | private Map map = new HashMap<>(); 12 | private double price; 13 | 14 | 15 | //提供把商品添加到购物的功能 16 | public void addBook2Cart(Book book) { 17 | 18 | //得到对应的购物项 19 | CartItem cartItem = map.get(book.getId()); 20 | 21 | //如果是null,说明购物车还没有该购物项 22 | if (cartItem == null) { 23 | cartItem = new CartItem(); 24 | cartItem.setQuantity(1); 25 | cartItem.setBook(book); 26 | cartItem.setPrice(book.getPrice()); 27 | 28 | //把购物项加到购物车中 29 | map.put(book.getId(), cartItem); 30 | } else { 31 | 32 | //如果购物车有该购物项了,那么将购物项的数量+1 33 | cartItem.setQuantity(cartItem.getQuantity() + 1); 34 | } 35 | } 36 | 37 | 38 | //购物车的价钱是购物项价钱的总和 39 | public double getPrice() { 40 | 41 | double totalPrice = 0; 42 | for (Map.Entry me : map.entrySet()) { 43 | CartItem cartItem = me.getValue(); 44 | totalPrice += cartItem.getPrice(); 45 | } 46 | 47 | return totalPrice; 48 | } 49 | 50 | public Map getMap() { 51 | return map; 52 | } 53 | 54 | public void setMap(Map map) { 55 | this.map = map; 56 | } 57 | 58 | 59 | public void setPrice(double price) { 60 | this.price = price; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Order.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | import java.util.Date; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | /** 8 | * Created by ozc on 2017/4/17. 9 | */ 10 | public class Order { 11 | 12 | private String id; 13 | 14 | //下单的时间、日期、状态 15 | private Date ordertime; 16 | private double price; 17 | private boolean state; 18 | 19 | //一个用户可以有多个订单,把用户记住 20 | private String user_id; 21 | 22 | //一个订单中有多个订单项 23 | private Set items = new HashSet<>(); 24 | 25 | public Set getItems() { 26 | return items; 27 | } 28 | 29 | public void setItems(Set items) { 30 | this.items = items; 31 | } 32 | 33 | public String getId() { 34 | return id; 35 | } 36 | 37 | public void setId(String id) { 38 | this.id = id; 39 | } 40 | 41 | public Date getOrdertime() { 42 | return ordertime; 43 | } 44 | 45 | public void setOrdertime(Date ordertime) { 46 | this.ordertime = ordertime; 47 | } 48 | 49 | public double getPrice() { 50 | return price; 51 | } 52 | 53 | public void setPrice(double price) { 54 | this.price = price; 55 | } 56 | 57 | public boolean isState() { 58 | return state; 59 | } 60 | 61 | public void setState(boolean state) { 62 | this.state = state; 63 | } 64 | 65 | public String getUser_id() { 66 | return user_id; 67 | } 68 | 69 | public void setUser_id(String user_id) { 70 | this.user_id = user_id; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ajax.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/IndexServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Category; 4 | import zhongfucheng.domain.Page; 5 | import zhongfucheng.service.BussinessServiceDao; 6 | import zhongfucheng.service.impl.BussinessServiceImpl; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ozc on 2017/4/13. 18 | */ 19 | @WebServlet(name = "IndexServlet",urlPatterns = "/IndexServlet") 20 | public class IndexServlet extends HttpServlet { 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 22 | 23 | //得到所有的分类数据,给body页面 24 | BussinessServiceDao service = new BussinessServiceImpl(); 25 | List categories = service.getAllCategory(); 26 | request.setAttribute("categories", categories); 27 | String currentPageCount = request.getParameter("currentPageCount"); 28 | 29 | //得到所有分类的图书,给body页面 30 | Page page = service.getPageData(currentPageCount); 31 | request.setAttribute("page", page); 32 | 33 | request.getRequestDispatcher("/client/body.jsp").forward(request,response); 34 | 35 | } 36 | 37 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 38 | this.doPost(request,response); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/manager/OrderServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.manager; 2 | 3 | import zhongfucheng.domain.Order; 4 | import zhongfucheng.service.BussinessServiceDao; 5 | import zhongfucheng.service.impl.BussinessServiceImpl; 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 java.io.IOException; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by ozc on 2017/4/17. 17 | */ 18 | @WebServlet(name = "OrderServlet",urlPatterns = "/OrderServlet") 19 | public class OrderServlet extends HttpServlet { 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | 22 | 23 | 24 | BussinessServiceDao service = new BussinessServiceImpl(); 25 | String state = request.getParameter("state"); 26 | 27 | 28 | if (state.equals("true")) { 29 | List list = service.getAllOrder(true); 30 | request.setAttribute("list",list); 31 | 32 | } else if (state.equals("false")) { 33 | List list = service.getAllOrder(false); 34 | request.setAttribute("list", list); 35 | } 36 | 37 | 38 | request.getRequestDispatcher("/background/listOrder.jsp").forward(request, response); 39 | 40 | 41 | 42 | 43 | } 44 | 45 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 46 | 47 | this.doPost(request, response); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/ListBookServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Category; 4 | import zhongfucheng.domain.Page; 5 | import zhongfucheng.service.BussinessServiceDao; 6 | import zhongfucheng.service.impl.BussinessServiceImpl; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ozc on 2017/4/14. 18 | */ 19 | @WebServlet(name = "ListBookServlet",urlPatterns = "/ListBookServlet") 20 | public class ListBookServlet extends HttpServlet { 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 22 | 23 | BussinessServiceDao service = new BussinessServiceImpl(); 24 | String currentPageCount = request.getParameter("currentPageCount"); 25 | String category_id = request.getParameter("category_id"); 26 | 27 | Page page = service.getPageData(currentPageCount, category_id); 28 | List categories = service.getAllCategory(); 29 | 30 | request.setAttribute("page", page); 31 | request.setAttribute("categories", categories); 32 | request.getRequestDispatcher("/client/body.jsp").forward(request,response); 33 | 34 | 35 | 36 | } 37 | 38 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 39 | 40 | this.doPost(request, response); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Book.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | public class Book { 7 | private String id; 8 | private String name; 9 | private String author; 10 | private String description; 11 | private double price; 12 | 13 | //记住图片的名称,后面就可以根据名字的名称来查看图片了 14 | private String image; 15 | 16 | //记住分类的id 17 | private String category_id; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public String getAuthor() { 36 | return author; 37 | } 38 | 39 | public void setAuthor(String author) { 40 | this.author = author; 41 | } 42 | 43 | public String getDescription() { 44 | return description; 45 | } 46 | 47 | public void setDescription(String description) { 48 | this.description = description; 49 | } 50 | 51 | public double getPrice() { 52 | return price; 53 | } 54 | 55 | public void setPrice(double price) { 56 | this.price = price; 57 | } 58 | 59 | public String getImage() { 60 | return image; 61 | } 62 | 63 | public void setImage(String image) { 64 | this.image = image; 65 | } 66 | 67 | public String getCategory_id() { 68 | return category_id; 69 | } 70 | 71 | public void setCategory_id(String category_id) { 72 | this.category_id = category_id; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql 6 | true 7 | com.mysql.jdbc.Driver 8 | jdbc:mysql://localhost:3306/zhongfucheng 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | mysql 20 | true 21 | com.mysql.jdbc.Driver 22 | jdbc:mysql://localhost:3306/zhongfucheng 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/c3p0-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.mysql.jdbc.Driver 5 | jdbc:mysql://localhost:3306/zhongfucheng?characterEncoding=utf8 6 | root 7 | root 8 | 9 | 5 10 | 10 11 | 5 12 | 20 13 | 14 | 15 | 16 | com.mysql.jdbc.Driver 17 | jdbc:mysql://localhost:3306/zhongfucheng 18 | root 19 | root 20 | 21 | 5 22 | 10 23 | 5 24 | 20 25 | 26 | 27 | 28 | 29 | oracle.jdbc.driver.OracleDriver 30 | jdbc:oracle:thin:@//localhost:1521/事例名... 31 | 用户名 32 | 密码 33 | 34 | 5 35 | 10 36 | 5 37 | 20 38 | 39 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/CreateOrderServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Cart; 4 | import zhongfucheng.domain.User; 5 | import zhongfucheng.service.BussinessServiceDao; 6 | import zhongfucheng.service.impl.BussinessServiceImpl; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | /** 16 | * Created by ozc on 2017/4/17. 17 | */ 18 | @WebServlet(name = "CreateOrderServlet",urlPatterns = "/CreateOrderServlet") 19 | public class CreateOrderServlet extends HttpServlet { 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | 22 | BussinessServiceDao service = new BussinessServiceImpl(); 23 | 24 | //检查该用户的购物车是否有商品 25 | Cart cart = (Cart) request.getSession().getAttribute("cart"); 26 | if (cart == null) { 27 | request.setAttribute("message", "您购物车没有商品,无法生成订单"); 28 | request.getRequestDispatcher("/message.jsp").forward(request, response); 29 | return; 30 | } 31 | 32 | //如果有商品,得到当前用户 33 | User user = (User) request.getSession().getAttribute("user"); 34 | service.createOrder(cart, user); 35 | request.setAttribute("message", "订单已经生成了,准备好钱来收货把"); 36 | request.getRequestDispatcher("/message.jsp").forward(request, response); 37 | return; 38 | 39 | } 40 | 41 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 42 | 43 | this.doPost(request, response); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /web/WEB-INF/classes/c3p0-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.mysql.jdbc.Driver 5 | jdbc:mysql://localhost:3306/zhongfucheng?characterEncoding=utf8 6 | root 7 | root 8 | 9 | 5 10 | 10 11 | 5 12 | 20 13 | 14 | 15 | 16 | com.mysql.jdbc.Driver 17 | jdbc:mysql://localhost:3306/zhongfucheng 18 | root 19 | root 20 | 21 | 5 22 | 10 23 | 5 24 | 20 25 | 26 | 27 | 28 | 29 | oracle.jdbc.driver.OracleDriver 30 | jdbc:oracle:thin:@//localhost:1521/事例名... 31 | 用户名 32 | 密码 33 | 34 | 5 35 | 10 36 | 5 37 | 20 38 | 39 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/WebUtils.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | import org.apache.commons.beanutils.BeanUtils; 4 | import org.apache.commons.beanutils.ConvertUtils; 5 | import org.apache.commons.beanutils.locale.converters.DateLocaleConverter; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import java.util.Date; 9 | import java.util.Enumeration; 10 | import java.util.UUID; 11 | 12 | /** 13 | * Created by ozc on 2017/4/12. 14 | */ 15 | public class WebUtils { 16 | public static T request2Bean(HttpServletRequest httpServletRequest, Class aClass) { 17 | 18 | 19 | try { 20 | //对于日期而言,是需要日期转换器的 21 | ConvertUtils.register(new DateLocaleConverter(), Date.class); 22 | 23 | //获取Bean的对象 24 | T bean = aClass.newInstance(); 25 | 26 | httpServletRequest.setCharacterEncoding("UTF-8"); 27 | 28 | //获取表单中所有的名字 29 | Enumeration enumeration = httpServletRequest.getParameterNames(); 30 | 31 | //遍历表单提交过来的名字 32 | while (enumeration.hasMoreElements()) { 33 | 34 | //每个名字 35 | String name = (String) enumeration.nextElement(); 36 | 37 | //获取得到值 38 | String value = httpServletRequest.getParameter(name); 39 | 40 | //如果用户提交的数据不为空,那么将数据封装到Bean中 41 | if (!value.equals("") && value != null) { 42 | BeanUtils.setProperty(bean, name, value); 43 | } 44 | } 45 | return bean; 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | throw new RuntimeException("封装数据到Bean中,失败了!"); 49 | } 50 | } 51 | 52 | public static String makeId() { 53 | return UUID.randomUUID().toString(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /web/background/addBook.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 19:11 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 添加图书 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 54 | 55 |
图书名称:
作者:
图书价钱:
类型: 34 | 39 |
上传图片
详细描述
51 | 52 | 53 |
56 |
57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/client/body.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:33 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | 17 |
18 |
19 | 书籍分类 : 20 |
21 | 22 |
  • 23 | ${categories.name} 24 |
  • 25 |
    26 |
    27 | 28 |
    29 | 30 |
    31 | 32 |
    33 | 34 |
    35 |
    36 |
  • 37 | 书名:${book.name} 38 |
  • 39 |
  • 价格:${book.price}
  • 40 |
  • 作者:${book.author}
  • 41 |
  • 购买
  • 42 | 43 |
    44 | 45 | 46 |
    47 | <%--这里要清除浮动,十分重要!--%> 48 |
    49 |
    50 | 51 |
    52 |
    53 | 54 |
    55 |
    56 | 57 | 58 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/LookOrder.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Order; 4 | import zhongfucheng.domain.User; 5 | import zhongfucheng.service.BussinessServiceDao; 6 | import zhongfucheng.service.impl.BussinessServiceImpl; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ozc on 2017/4/17. 18 | */ 19 | @WebServlet(name = "LookOrder",urlPatterns = "/LookOrder") 20 | public class LookOrder extends HttpServlet { 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 22 | 23 | BussinessServiceDao service = new BussinessServiceImpl(); 24 | 25 | //检查该用户是否登陆了 26 | User user = (User) request.getSession().getAttribute("user"); 27 | if (user == null) { 28 | request.setAttribute("message", "您还没登陆,等您登陆了再来看把"); 29 | request.getRequestDispatcher("/message.jsp").forward(request, response); 30 | return; 31 | } 32 | 33 | //用户登陆了! 34 | List orders = service.findUserOrder(user.getId()); 35 | System.out.println("这里是订单有多少个:"+orders.size()); 36 | 37 | //交给相对应的JSP 显示 38 | request.setAttribute("orders", orders); 39 | request.setAttribute("user",user); 40 | request.getRequestDispatcher("/client/listOrder.jsp").forward(request, response); 41 | return ; 42 | } 43 | 44 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 45 | 46 | this.doPost(request, response); 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /web/client/head.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/4/12 5 | Time: 10:33 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | Title 13 | 14 | 31 | 32 | 33 |

    欢迎来到购物中心

    34 | 35 | 首页 36 | 查看购物车 37 | 查看订单 38 | 39 | 40 |
    41 | 用户名: 42 | 密码: 43 | 44 | 45 |
    46 |
    47 | 48 | 49 |
    50 |       欢迎您:${user.username}    注销 51 |
    52 |
    53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/junit/Test2.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.beans.IntrospectionException; 4 | import java.beans.PropertyDescriptor; 5 | import java.lang.annotation.Annotation; 6 | import java.lang.reflect.Field; 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.lang.reflect.Method; 9 | 10 | /** 11 | * Created by ozc on 2017/4/24. 12 | */ 13 | public class Test2 { 14 | 15 | public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, InstantiationException, InvocationTargetException { 16 | 17 | //1.得到想要注入的属性 18 | Field field = PersonDao.class.getDeclaredField("person"); 19 | 20 | //2.得到属性的具体对象 21 | Person person = (Person) field.getType().newInstance(); 22 | 23 | //3.得到属性上的注解 24 | Annotation annotation = field.getAnnotation(InjectPerson.class); 25 | 26 | //4.得到注解的属性【注解上的属性使用方法来表示的】 27 | Method[] methods = annotation.getClass().getMethods(); 28 | 29 | //5.将注入的属性填充到person对象上 30 | for (Method method : methods) { 31 | 32 | //5.1得到注解属性的名字 33 | String name = method.getName(); 34 | 35 | //查看一下Person对象上有没有与之对应的写方法 36 | try { 37 | 38 | //如果有 39 | PropertyDescriptor descriptor = new PropertyDescriptor(name, Person.class); 40 | 41 | //得到Person对象上的写方法 42 | Method method1 = descriptor.getWriteMethod(); 43 | 44 | //得到注解上的值 45 | Object o = method.invoke(annotation, null); 46 | 47 | //填充person对象 48 | method1.invoke(person, o); 49 | } catch (IntrospectionException e) { 50 | 51 | //如果没有想对应的属性,继续循环 52 | continue; 53 | } 54 | } 55 | 56 | //循环完之后,person就已经填充好数据了 57 | 58 | 59 | //6.把person对象设置到PersonDao中 60 | PersonDao personDao = new PersonDao(); 61 | field.setAccessible(true); 62 | field.set(personDao, person); 63 | 64 | System.out.println(personDao.getPerson().getUsername()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /web/client/page.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/3/1 5 | Time: 21:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%--显示当前页数--%> 11 | 当前页数是:[${page.currentPageCount}]    12 | 13 | <%--如果当前的页码大于1,才显示上一步--%> 14 | 15 | 16 | <%--把传递过去的页码-1就行了--%> 17 | 18 | 上一步 19 | 20 | 21 | 22 | 23 | <%--提供页数的界面--%> 24 | 25 | 26 | [${pageNum}]  27 | 28 | 29 | 30 | <%--如果当前的页码小于总页数,才显示下一步--%> 31 | 32 | 33 | <%--把传递过去的页码-1就行了--%> 34 | 35 | 下一步 36 |    37 | 38 | 39 | 40 | 41 | 42 | 总页数是:${page.totalPageCount}   43 | 44 | 总记录数是:${page.totalRecord} 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/BuyServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.Book; 4 | import zhongfucheng.domain.Cart; 5 | import zhongfucheng.domain.User; 6 | import zhongfucheng.service.BussinessServiceDao; 7 | import zhongfucheng.service.impl.BussinessServiceImpl; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | 16 | /** 17 | * Created by ozc on 2017/4/16. 18 | */ 19 | @WebServlet(name = "BuyServlet",urlPatterns = "/BuyServlet") 20 | public class BuyServlet extends HttpServlet { 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 22 | 23 | BussinessServiceDao service = new BussinessServiceImpl(); 24 | 25 | //先检查该用户是否登陆了。 26 | User user = (User) request.getSession().getAttribute("user"); 27 | if (user == null) { 28 | request.setAttribute("message", "您还没登陆,请登陆了再来购买"); 29 | request.getRequestDispatcher("/message.jsp").forward(request, response); 30 | return ; 31 | } 32 | 33 | //如果登陆了... 34 | 35 | //得到该用户的购物车 36 | Cart cart = (Cart) request.getSession().getAttribute("cart"); 37 | if (cart == null) { 38 | cart = new Cart(); 39 | request.getSession().setAttribute("cart", cart); 40 | } 41 | 42 | //得到用户想买的书籍 43 | String book_id = request.getParameter("book_id"); 44 | Book book = service.findBook(book_id); 45 | 46 | //把书籍添加到购物车中 47 | service.buyBook(cart, book); 48 | request.setAttribute("message", "该商品已添加到购物车中"); 49 | request.getRequestDispatcher("/message.jsp").forward(request,response); 50 | 51 | 52 | } 53 | 54 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 55 | 56 | this.doPost(request, response); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /web/background/page.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: ozc 4 | Date: 2017/3/1 5 | Time: 21:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%--显示当前页数--%> 11 | 当前页数是:[${page.currentPageCount}]    12 | 13 | <%--如果当前的页码大于1,才显示上一步--%> 14 | 15 | 16 | <%--把传递过去的页码-1就行了--%> 17 | 18 | 上一步 19 | 20 | 21 | 22 | 23 | <%--提供页数的界面--%> 24 | 25 | 26 | [${pageNum}]  27 | 28 | 29 | 30 | <%--如果当前的页码小于总页数,才显示下一步--%> 31 | 32 | 33 | <%--把传递过去的页码-1就行了--%> 34 | 35 | 下一步 36 |    37 | 38 | 39 | 40 | 41 | 42 | 总页数是:${page.totalPageCount}   43 | 44 | 总记录数是:${page.totalRecord} 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/filter/CharacterEncodingFilter.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.filter; 2 | 3 | import javax.servlet.*; 4 | import javax.servlet.annotation.WebFilter; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletRequestWrapper; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | import java.io.UnsupportedEncodingException; 10 | 11 | /** 12 | * Created by ozc on 2017/4/12. 13 | */ 14 | @WebFilter(filterName = "CharacterEncodingFilter",urlPatterns = "/*") 15 | public class CharacterEncodingFilter implements Filter { 16 | 17 | 18 | public void doFilter(ServletRequest req, ServletResponse resp, 19 | FilterChain chain) throws IOException, ServletException { 20 | HttpServletRequest request = (HttpServletRequest) req; 21 | HttpServletResponse response = (HttpServletResponse) resp; 22 | 23 | request.setCharacterEncoding("UTF-8"); 24 | response.setCharacterEncoding("UTF-8"); 25 | response.setContentType("text/html;charset=UTF-8"); 26 | chain.doFilter(new MyRequest(request), response); 27 | } 28 | 29 | public void init(FilterConfig filterConfig) throws ServletException { 30 | // TODO Auto-generated method stub 31 | 32 | } 33 | 34 | public void destroy() { 35 | // TODO Auto-generated method stub 36 | 37 | } 38 | } 39 | class MyRequest extends HttpServletRequestWrapper { 40 | private HttpServletRequest request; 41 | public MyRequest(HttpServletRequest request) { 42 | super(request); 43 | this.request = request; 44 | 45 | } 46 | @Override 47 | public String getParameter(String name) { 48 | 49 | String value = this.request.getParameter(name); 50 | if(value==null){ 51 | return null; 52 | } 53 | if(!this.request.getMethod().equalsIgnoreCase("get")){ 54 | return value; 55 | } 56 | try { 57 | value = new String(value.getBytes("iso8859-1"),"UTF-8"); 58 | } catch (UnsupportedEncodingException e) { 59 | throw new RuntimeException(e); 60 | } 61 | return value; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/impl/CategoryDAOImpl.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao.impl; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | 7 | import org.apache.commons.dbutils.QueryRunner; 8 | import org.apache.commons.dbutils.handlers.BeanHandler; 9 | import org.apache.commons.dbutils.handlers.BeanListHandler; 10 | import org.apache.commons.dbutils.handlers.ScalarHandler; 11 | import zhongfucheng.domain.Category; 12 | import zhongfucheng.utils.Utils2DB; 13 | 14 | import java.sql.SQLException; 15 | import java.util.List; 16 | 17 | /** 18 | * 分类模块 19 | * 1:添加分类 20 | * 2:查找分类 21 | * 3:修改分类 22 | * 23 | * 24 | * */ 25 | public class CategoryDAOImpl implements zhongfucheng.dao.CategoryDao { 26 | 27 | @Override 28 | public void addCategory(Category category) { 29 | 30 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 31 | 32 | String sql = "INSERT INTO category (id, name, description) VALUES(?,?,?)"; 33 | try { 34 | queryRunner.update(sql, new Object[]{category.getId(), category.getName(), category.getDescription()}); 35 | 36 | } catch (SQLException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | 41 | @Override 42 | public Category findCategory(String id) { 43 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 44 | String sql = "SELECT * FROM category WHERE id=?"; 45 | 46 | try { 47 | Category category = (Category) queryRunner.query(sql, id, new BeanHandler(Category.class)); 48 | 49 | return category; 50 | 51 | } catch (SQLException e) { 52 | throw new RuntimeException(e); 53 | } 54 | 55 | } 56 | 57 | @Override 58 | public List getAllCategory() { 59 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 60 | String sql = "SELECT * FROM category"; 61 | 62 | try { 63 | List categories = (List) queryRunner.query(sql, new BeanListHandler(Category.class)); 64 | 65 | return categories; 66 | } catch (SQLException e) { 67 | throw new RuntimeException(e); 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/junit/Test.java: -------------------------------------------------------------------------------- 1 | package junit; 2 | 3 | import java.beans.IntrospectionException; 4 | import java.beans.PropertyDescriptor; 5 | import java.lang.annotation.Annotation; 6 | import java.lang.reflect.Field; 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.lang.reflect.Method; 9 | 10 | /** 11 | * Created by ozc on 2017/4/24. 12 | */ 13 | public class Test { 14 | 15 | public static void main(String[] args) throws NoSuchFieldException, IntrospectionException, IllegalAccessException, InstantiationException, InvocationTargetException { 16 | 17 | //1.使用内省【后边需要得到属性的写方法】,得到想要注入的属性 18 | PropertyDescriptor descriptor = new PropertyDescriptor("person", PersonDao.class); 19 | 20 | //2得到Person对象的 21 | Person person = (Person) descriptor.getPropertyType().newInstance(); 22 | 23 | //3.得到该属性的写方法【setPerson()】 24 | Method method = descriptor.getWriteMethod(); 25 | 26 | //4.得到写方法的注解 27 | Annotation annotation = method.getAnnotation(InjectPerson.class); 28 | 29 | //5.得到注解上的信息【注解的成员变量就是用方法来定义的】 30 | Method[] methods = annotation.getClass().getMethods(); 31 | 32 | //6.将注解上的信息填充到person对象上 33 | 34 | for (Method m : methods) { 35 | 36 | //得到注解上属性的名字【age或name】 37 | String name = m.getName(); 38 | 39 | //看看Person对象有没有与之对应的方法【setAge(),setName()】 40 | try { 41 | 42 | //6.1这里假设:有与之对应的写方法,得到写方法 43 | PropertyDescriptor descriptor1 = new PropertyDescriptor(name, Person.class); 44 | Method method1 = descriptor1.getWriteMethod();//setAge(), setName() 45 | 46 | //得到注解中的值 47 | Object o = m.invoke(annotation, null); 48 | 49 | //调用Person对象的setter方法,将注解上的值设置进去 50 | method1.invoke(person, o); 51 | 52 | } catch (Exception e) { 53 | 54 | //6.2 Person对象没有与之对应的方法,会跳到catch来。我们要让它继续遍历注解就好了 55 | continue; 56 | } 57 | } 58 | 59 | //5.将person对象赋给PersonDao【通过写方法】 60 | PersonDao personDao = new PersonDao(); 61 | method.invoke(personDao, person); 62 | 63 | System.out.println(personDao.getPerson().getUsername()); 64 | System.out.println(personDao.getPerson().getAge()); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/filter/HtmlFilter.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.filter; 2 | 3 | import javax.servlet.*; 4 | import javax.servlet.annotation.WebFilter; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletRequestWrapper; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | /** 11 | * Created by ozc on 2017/4/12. 12 | */ 13 | @WebFilter(filterName = "HtmlFilter",urlPatterns = "/*") 14 | public class HtmlFilter implements Filter { 15 | 16 | 17 | public void doFilter(ServletRequest req, ServletResponse resp, 18 | FilterChain chain) throws IOException, ServletException { 19 | 20 | HttpServletRequest request = (HttpServletRequest) req; 21 | HttpServletResponse response = (HttpServletResponse) resp; 22 | 23 | chain.doFilter(new MyRequest2(request), response); 24 | 25 | } 26 | 27 | public void destroy() { 28 | // TODO Auto-generated method stub 29 | } 30 | 31 | public void init(FilterConfig filterConfig) throws ServletException { 32 | // TODO Auto-generated method stub 33 | } 34 | 35 | } 36 | class MyRequest2 extends HttpServletRequestWrapper { 37 | 38 | private HttpServletRequest request; 39 | public MyRequest2(HttpServletRequest request) { 40 | super(request); 41 | this.request = request; 42 | } 43 | @Override 44 | public String getParameter(String name) { 45 | 46 | String value = this.request.getParameter(name); 47 | if(value==null){ 48 | return null; 49 | } 50 | return filter(value); 51 | } 52 | 53 | public String filter(String message) { 54 | 55 | if (message == null) 56 | return (null); 57 | 58 | char content[] = new char[message.length()]; 59 | message.getChars(0, message.length(), content, 0); 60 | StringBuffer result = new StringBuffer(content.length + 50); 61 | for (int i = 0; i < content.length; i++) { 62 | switch (content[i]) { 63 | case '<': 64 | result.append("<"); 65 | break; 66 | case '>': 67 | result.append(">"); 68 | break; 69 | case '&': 70 | result.append("&"); 71 | break; 72 | case '"': 73 | result.append("""); 74 | break; 75 | default: 76 | result.append(content[i]); 77 | } 78 | } 79 | return (result.toString()); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/impl/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao.impl; 2 | 3 | /** 4 | * Created by ozc on 2017/4/16. 5 | */ 6 | 7 | import org.apache.commons.dbutils.QueryRunner; 8 | import org.apache.commons.dbutils.handlers.BeanHandler; 9 | import org.apache.commons.dbutils.handlers.BeanListHandler; 10 | import zhongfucheng.domain.Privilege; 11 | import zhongfucheng.domain.User; 12 | import zhongfucheng.utils.Utils2DB; 13 | 14 | import java.sql.SQLException; 15 | import java.util.List; 16 | 17 | /** 18 | * 用户的登录注册模块 19 | * 1:登陆 20 | * 2:注册 21 | * 3:根据id查找具体的用户 22 | */ 23 | public class UserDaoImpl implements zhongfucheng.dao.UserDao { 24 | 25 | 26 | 27 | @Override 28 | public void register(User user) { 29 | 30 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 31 | 32 | String sql = "INSERT INTO user (id,username,cellphone,address,email,password) VALUES(?,?,?,?,?,?)"; 33 | try { 34 | 35 | queryRunner.update(sql, new Object[]{user.getId(),user.getUsername(), user.getCellphone(), user.getAddress(), user.getEmail(), user.getPassword()}); 36 | } catch (SQLException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | 41 | @Override 42 | public User login(String username, String password) { 43 | 44 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 45 | 46 | String sql = "SELECT * FROM user WHERE username = ? AND password=?"; 47 | try { 48 | 49 | return (User) queryRunner.query(sql, new Object[]{username, password}, new BeanHandler(User.class)); 50 | } catch (SQLException e) { 51 | throw new RuntimeException(e); 52 | } 53 | } 54 | 55 | @Override 56 | public User find(String id) { 57 | 58 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 59 | 60 | String sql = "SELECT * FROM user WHERE id=?"; 61 | try { 62 | 63 | return (User) queryRunner.query(sql, id, new BeanHandler(User.class)); 64 | } catch (SQLException e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | 69 | 70 | public List findUserPrivilege(String user_id) { 71 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 72 | 73 | String sql = "SELECT p.* FROM privilege p, user_privilege up WHERE p.id = up.privilege_id AND up.user_id = ?"; 74 | try { 75 | return (List) queryRunner.query(sql, new Object[]{user_id}, new BeanListHandler(Privilege.class)); 76 | } catch (SQLException e) { 77 | throw new RuntimeException(e); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/client/UserServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.client; 2 | 3 | import zhongfucheng.domain.User; 4 | import zhongfucheng.service.BussinessServiceDao; 5 | import zhongfucheng.service.impl.BussinessServiceImpl; 6 | import zhongfucheng.utils.WebUtils; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | /** 16 | * Created by ozc on 2017/4/16. 17 | */ 18 | @WebServlet(name = "UserServlet",urlPatterns = "/UserServlet") 19 | public class UserServlet extends HttpServlet { 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | 22 | String method = request.getParameter("method"); 23 | 24 | BussinessServiceDao service = new BussinessServiceImpl(); 25 | if (method.equals("login")) { 26 | 27 | try { 28 | //得到页面传递过来的数据 29 | String username = request.getParameter("username"); 30 | String password = request.getParameter("password"); 31 | User user = service.loginUser(username, password); 32 | 33 | request.getSession().setAttribute("user",user); 34 | request.getRequestDispatcher("/client/head.jsp").forward(request, response); 35 | 36 | } catch (Exception e) { 37 | request.setAttribute("message", "登陆失败了!"); 38 | request.getRequestDispatcher("/message.jsp").forward(request, response); 39 | } 40 | 41 | } else if (method.equals("register")) { 42 | 43 | try { 44 | //得到JSP传递过来的数据,封装成Bean对象 45 | User user = WebUtils.request2Bean(request, User.class); 46 | user.setId(WebUtils.makeId()); 47 | 48 | service.registerUser(user); 49 | 50 | request.setAttribute("message", "注册成功了!"); 51 | 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | request.setAttribute("message", "注册失败了!"); 55 | } 56 | request.getRequestDispatcher("/message.jsp").forward(request, response); 57 | } else if (method.equals("Logout")) { 58 | 59 | //销毁session 60 | request.getSession().invalidate(); 61 | 62 | //回到首页 63 | request.getRequestDispatcher("/client/head.jsp").forward(request, response); 64 | 65 | } 66 | } 67 | 68 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 69 | 70 | this.doPost(request, response); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/manager/CategoryServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.manager; 2 | 3 | import zhongfucheng.domain.Category; 4 | import zhongfucheng.domain.User; 5 | import zhongfucheng.service.BussinessServiceDao; 6 | import zhongfucheng.utils.PrivilegeException; 7 | import zhongfucheng.utils.ServiceDaoFactory; 8 | import zhongfucheng.utils.WebUtils; 9 | 10 | import javax.servlet.ServletException; 11 | import javax.servlet.annotation.WebServlet; 12 | import javax.servlet.http.HttpServlet; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by ozc on 2017/4/12. 20 | */ 21 | @WebServlet(name = "CategoryServlet",urlPatterns = "/CategoryServlet") 22 | public class CategoryServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | 25 | BussinessServiceDao service = ServiceDaoFactory.getInstance().createDao("zhongfucheng.service.impl.BussinessServiceImpl", BussinessServiceDao.class, (User) request.getSession().getAttribute("user")); 26 | 27 | String method = request.getParameter("method"); 28 | 29 | if (method.equals("add")) { 30 | try { 31 | //把浏览器带过来的数据封装到bean中 32 | Category category = WebUtils.request2Bean(request, Category.class); 33 | category.setId(WebUtils.makeId()); 34 | 35 | service.addCategory(category); 36 | request.setAttribute("message", "添加分类成功!"); 37 | 38 | } catch (Exception e) { 39 | if (e.getCause() instanceof PrivilegeException) { 40 | request.setAttribute("message", e.getCause().getMessage()); 41 | e.printStackTrace(); 42 | } else { 43 | request.setAttribute("message","添加分类失败"); 44 | e.printStackTrace(); 45 | } 46 | request.getRequestDispatcher("/message.jsp").forward(request, response); 47 | } 48 | 49 | 50 | } else if (method.equals("find")) { 51 | 52 | } else if (method.equals("update")) { 53 | 54 | } else if (method.equals("look")) { 55 | 56 | try { 57 | List list = service.getAllCategory(); 58 | request.setAttribute("list", list); 59 | request.getRequestDispatcher("/background/lookCategory.jsp").forward(request, response); 60 | return; 61 | 62 | } catch (Exception e) { 63 | if (e.getCause() instanceof PrivilegeException) { 64 | e.printStackTrace(); 65 | request.setAttribute("message", e.getCause().getMessage()); 66 | request.getRequestDispatcher("/message.jsp").forward(request, response); 67 | return; 68 | } 69 | } 70 | } else { 71 | throw new RuntimeException("分类模块没有该操作!"); 72 | } 73 | } 74 | 75 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 76 | 77 | this.doPost(request, response); 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/zhongfucheng/utils/ServiceDaoFactory.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.utils; 2 | 3 | import zhongfucheng.domain.Privilege; 4 | import zhongfucheng.domain.User; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.lang.reflect.InvocationHandler; 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | import java.lang.reflect.Proxy; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by ozc on 2017/4/12. 15 | */ 16 | public class ServiceDaoFactory { 17 | 18 | private static final ServiceDaoFactory factory = new ServiceDaoFactory(); 19 | 20 | private ServiceDaoFactory() { 21 | } 22 | 23 | public static ServiceDaoFactory getInstance() { 24 | return factory; 25 | } 26 | 27 | 28 | //需要判断该用户是否有权限 29 | public T createDao(String className, Class clazz, final User user) { 30 | 31 | System.out.println("添加分类进来了!"); 32 | 33 | try { 34 | //得到该类的类型 35 | final T t = (T) Class.forName(className).newInstance(); 36 | //返回一个动态代理对象出去 37 | return (T) Proxy.newProxyInstance(ServiceDaoFactory.class.getClassLoader(), t.getClass().getInterfaces(), new InvocationHandler() { 38 | 39 | @Override 40 | public Object invoke(Object proxy, Method method, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, PrivilegeException { 41 | //判断用户调用的是什么方法 42 | String methodName = method.getName(); 43 | System.out.println(methodName); 44 | 45 | //得到用户调用的真实方法 46 | Method method1 = t.getClass().getMethod(methodName,method.getParameterTypes()); 47 | 48 | //查看方法上有没有注解 49 | permission permis = method1.getAnnotation(permission.class); 50 | 51 | //如果注解为空,那么表示该方法并不需要权限,直接调用方法即可 52 | if (permis == null) { 53 | return method.invoke(t, args); 54 | } 55 | 56 | //如果注解不为空,得到注解上的权限 57 | String privilege = permis.value(); 58 | 59 | //设置权限【后面通过它来判断用户的权限有没有自己】 60 | Privilege p = new Privilege(); 61 | p.setName(privilege); 62 | 63 | //到这里的时候,已经是需要权限了,那么判断用户是否登陆了 64 | if (user == null) { 65 | 66 | //这里抛出的异常是代理对象抛出的,sun公司会自动转换成运行期异常抛出,于是在Servlet上我们根据getCause()来判断是不是该异常,从而做出相对应的提示。 67 | throw new PrivilegeException("对不起请先登陆"); 68 | } 69 | 70 | //执行到这里用户已经登陆了,判断用户有没有权限 71 | Method m = t.getClass().getMethod("findUserPrivilege", String.class); 72 | List list = (List) m.invoke(t, user.getId()); 73 | 74 | //看下权限集合中有没有包含方法需要的权限。使用contains方法,在Privilege对象中需要重写hashCode和equals() 75 | if (!list.contains(p)) { 76 | //这里抛出的异常是代理对象抛出的,sun公司会自动转换成运行期异常抛出,于是在Servlet上我们根据getCause()来判断是不是该异常,从而做出相对应的提示。 77 | throw new PrivilegeException("您没有权限,请联系管理员!"); 78 | } 79 | 80 | //执行到这里的时候,已经有权限了,所以可以放行了 81 | return method.invoke(t, args); 82 | } 83 | }); 84 | 85 | } catch (Exception e) { 86 | new RuntimeException(e); 87 | } 88 | return null; 89 | } 90 | } -------------------------------------------------------------------------------- /src/zhongfucheng/dao/impl/BookDaoImpl.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao.impl; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | 7 | import org.apache.commons.dbutils.QueryRunner; 8 | import org.apache.commons.dbutils.handlers.BeanHandler; 9 | import org.apache.commons.dbutils.handlers.BeanListHandler; 10 | import org.apache.commons.dbutils.handlers.ScalarHandler; 11 | import zhongfucheng.domain.Book; 12 | 13 | import zhongfucheng.utils.Utils2DB; 14 | 15 | import java.sql.SQLException; 16 | import java.util.List; 17 | 18 | /** 19 | * 图书模块 20 | * 1:添加图书 21 | * 2:查看图书 22 | * 3:查找图书的分页数据【图书一般来说有很多,所以要分页】 23 | */ 24 | public class BookDaoImpl implements zhongfucheng.dao.BookDao { 25 | 26 | @Override 27 | public void addBook(Book book) { 28 | 29 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 30 | 31 | String sql = "INSERT INTO book (id,name,description,author,price,image,category_id) VALUES(?,?,?,?,?,?,?)"; 32 | try { 33 | queryRunner.update(sql, new Object[]{book.getId(), book.getName(), book.getDescription(), book.getAuthor(), book.getPrice(),book.getImage(), book.getCategory_id()}); 34 | 35 | } catch (SQLException e) { 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | 40 | @Override 41 | public Book findBook(String id) { 42 | 43 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 44 | 45 | String sql = "SELECT * FROM book WHERE id=?"; 46 | 47 | try { 48 | return (Book) queryRunner.query(sql, id, new BeanHandler(Book.class)); 49 | } catch (SQLException e) { 50 | throw new RuntimeException(e); 51 | } 52 | } 53 | 54 | /**得到图书的分页数据*/ 55 | @Override 56 | public List getPageData(int start, int end) { 57 | 58 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 59 | 60 | String sql = "SELECT * FROM book limit ?,?"; 61 | 62 | try { 63 | return (List) queryRunner.query(sql, new BeanListHandler(Book.class), new Object[]{start, end}); 64 | } catch (SQLException e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | 69 | /**得到按照分类图书的分页数据*/ 70 | @Override 71 | public List getPageData(int start, int end, String category_id) { 72 | 73 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 74 | 75 | //WHERE字句在limit字句的前边,注意Object[]的参数位置! 76 | String sql = "SELECT * FROM book WHERE category_id=? limit ?,?"; 77 | 78 | try { 79 | return (List) queryRunner.query(sql, new BeanListHandler(Book.class), new Object[]{ category_id,start, end}); 80 | } catch (SQLException e) { 81 | throw new RuntimeException(e); 82 | } 83 | } 84 | 85 | /** 86 | * 得到图书的总记录数 87 | */ 88 | @Override 89 | public long getTotalRecord() { 90 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 91 | 92 | String sql = "SELECT COUNT(*) FROM book"; 93 | 94 | try { 95 | return (long) queryRunner.query(sql, new ScalarHandler()); 96 | 97 | } catch (SQLException e) { 98 | throw new RuntimeException(e); 99 | } 100 | } 101 | /** 102 | * 得到分类后图书的总记录数 103 | * getCategoryTotalRecord 104 | */ 105 | public long getCategoryTotalRecord(String category_id) { 106 | 107 | try { 108 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 109 | 110 | String sql = "SELECT COUNT(*) FROM book WHERE category_id=?"; 111 | return (long) queryRunner.query(sql, category_id, new ScalarHandler()); 112 | 113 | } catch (SQLException e) { 114 | throw new RuntimeException(e); 115 | } 116 | } 117 | 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/zhongfucheng/domain/Page.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.domain; 2 | 3 | /** 4 | * Created by ozc on 2017/4/12. 5 | */ 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by ozc on 2017/3/1. 11 | */ 12 | public class Page { 13 | 14 | //保存着分页的数据 15 | private List list; 16 | 17 | //总记录数 18 | private long totalRecord; 19 | 20 | //每页显示记录数,这里我规定每页显示3条 21 | private int linesize = 3; 22 | 23 | //总页数 24 | private int totalPageCount; 25 | 26 | //当前显示的页数 27 | private int currentPageCount; 28 | 29 | //开始取的记录位置 30 | private int startIndex; 31 | 32 | //记录JSP页面开始的页数和结束的页数 33 | private int startPage; 34 | private int endPage; 35 | 36 | private String url; 37 | 38 | 39 | public Page() { 40 | } 41 | 42 | public Page(int currentPageCount, long totalRecord) { 43 | 44 | 45 | //将传递进来的currentPageCount初始化 46 | this.currentPageCount = currentPageCount; 47 | 48 | //总页数 49 | totalPageCount = (int) (totalRecord % linesize == 0 ? totalRecord / linesize : totalRecord / linesize + 1); 50 | 51 | this.totalRecord = totalRecord; 52 | 53 | //开始取数据的位置 54 | startIndex = (currentPageCount - 1) * linesize; 55 | 56 | 57 | //如果当前页小于10,那么开始页为1,结束页为10就行了 58 | if (this.currentPageCount <= 10) { 59 | this.startPage = 1; 60 | this.endPage = totalPageCount; 61 | } else { 62 | this.startPage = this.currentPageCount - 4; 63 | this.endPage = this.totalPageCount + 5; 64 | 65 | //加减后页数越界的情况 66 | if (startPage < 1) { 67 | this.startPage = 1; 68 | this.endPage = totalPageCount; 69 | } 70 | if (endPage > totalPageCount) { 71 | this.startPage = this.currentPageCount - 9; 72 | this.endPage = this.totalPageCount; 73 | } 74 | } 75 | 76 | 77 | } 78 | 79 | public String getUrl() { 80 | return url; 81 | } 82 | 83 | public void setUrl(String url) { 84 | this.url = url; 85 | } 86 | 87 | public int getStartIndex() { 88 | return startIndex; 89 | } 90 | 91 | public void setCurrentPageCount(int currentPageCount) { 92 | this.currentPageCount = currentPageCount; 93 | } 94 | 95 | public void setStartIndex(int startIndex) { 96 | this.startIndex = startIndex; 97 | } 98 | 99 | public int getStartPage() { 100 | return startPage; 101 | } 102 | 103 | public void setStartPage(int startPage) { 104 | this.startPage = startPage; 105 | } 106 | 107 | public int getEndPage() { 108 | return endPage; 109 | } 110 | 111 | public void setEndPage(int endPage) { 112 | this.endPage = endPage; 113 | } 114 | 115 | public int getTotalPageCount() { 116 | return totalPageCount; 117 | } 118 | 119 | public void setTotalPageCount(int totalPageCount) { 120 | this.totalPageCount = totalPageCount; 121 | } 122 | 123 | public List getList() { 124 | return list; 125 | } 126 | 127 | public void setList(List list) { 128 | this.list = list; 129 | } 130 | 131 | public long getTotalRecord() { 132 | return totalRecord; 133 | } 134 | 135 | public void setTotalRecord(long totalRecord) { 136 | this.totalRecord = totalRecord; 137 | } 138 | 139 | public int getLinesize() { 140 | return linesize; 141 | } 142 | 143 | public void setLinesize(int linesize) { 144 | this.linesize = linesize; 145 | } 146 | 147 | 148 | public long getCurrentPageCount() { 149 | return currentPageCount; 150 | } 151 | 152 | public void setCurrentPageCount(long currentPageCount) { 153 | this.currentPageCount = (int) currentPageCount; 154 | } 155 | } -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/zhongfucheng/dao/impl/OrderDaoImpl.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.dao.impl; 2 | 3 | import org.apache.commons.dbutils.QueryRunner; 4 | import org.apache.commons.dbutils.handlers.BeanHandler; 5 | import org.apache.commons.dbutils.handlers.BeanListHandler; 6 | import zhongfucheng.domain.Order; 7 | import zhongfucheng.domain.OrderItem; 8 | import zhongfucheng.domain.User; 9 | import zhongfucheng.utils.Utils2DB; 10 | 11 | import java.sql.SQLException; 12 | import java.util.List; 13 | import java.util.Set; 14 | 15 | /** 16 | * Created by ozc on 2017/4/17. 17 | */ 18 | public class OrderDaoImpl implements zhongfucheng.dao.OrderDao { 19 | 20 | @Override 21 | public void addOrder(Order order) { 22 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 23 | String sql1 = "INSERT INTO orders(id,ordertime,user_id,state,price) VALUES(?,?,?,?,?)"; 24 | try { 25 | //订单的基本信息 26 | queryRunner.update(sql1, new Object[]{order.getId(), order.getOrdertime(), order.getUser_id(), order.isState(), order.getPrice()}); 27 | 28 | //订单项的信息 29 | String sql2 = "INSERT INTO orderItem(id,price,quantity,order_id,book_id) VALUES(?,?,?,?,?)"; 30 | 31 | Set items = order.getItems(); 32 | 33 | for (OrderItem item : items) { 34 | queryRunner.update(sql2, new Object[]{item.getId(), item.getPrice(), item.getQuantity(), item.getOrder_id(), item.getBook_id()}); 35 | } 36 | } catch (SQLException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | 41 | @Override 42 | public Order findOrder(String id) { 43 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 44 | 45 | Order order; 46 | try { 47 | //找出订单的基本信息 48 | String sql = "SELECT * FROM orders WHERE id=?"; 49 | order = (Order) queryRunner.query(sql, new BeanHandler(Order.class), new Object[]{id}); 50 | 51 | //找出订单的所有订单项 52 | String sql2 = "SELECT * FROM orderItem WHERE order_id=?"; 53 | List list = (List) queryRunner.query(sql2, new BeanListHandler(OrderItem.class), new Object[]{order.getId()}); 54 | 55 | System.out.println("这是数据库拿到的list集合:"+list.size()); 56 | 57 | 58 | //将所有订单项装到订单里边 59 | order.getItems().addAll(list); 60 | System.out.println("这是数据库拿到的"+order.getItems().size()); 61 | 62 | 63 | //找出该订单是属于哪一个用户的 64 | String sql3 = "SELECT * FROM orders o,user u WHERE o.user_id=u.id AND o.id=? "; 65 | User user = (User) queryRunner.query(sql3, new BeanHandler(User.class), new Object[]{order.getId()}); 66 | 67 | order.setUser_id(user.getId()); 68 | return order; 69 | 70 | 71 | } catch (SQLException e) { 72 | throw new RuntimeException(e); 73 | } 74 | } 75 | 76 | 77 | //更新订单的状态 78 | public void updateState(String id) { 79 | 80 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 81 | 82 | String sql = "UPDATE orders SET state=? WHERE id=?"; 83 | 84 | try { 85 | queryRunner.update(sql, new Object[]{true, id}); 86 | } catch (SQLException e) { 87 | throw new RuntimeException(e); 88 | } 89 | } 90 | 91 | //查看已经发货或没发货的订单信息 92 | public List getAllOrder(boolean state) { 93 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 94 | 95 | String sql = "SELECT * FROM orders WHERE state=? "; 96 | try { 97 | return (List) queryRunner.query(sql, new BeanListHandler(Order.class), new Object[]{state}); 98 | } catch (SQLException e) { 99 | throw new RuntimeException(e); 100 | } 101 | } 102 | 103 | //通过用户的id查找用户的订单,可能是不止一个的 104 | public List findUserOrder(String user_id) { 105 | QueryRunner queryRunner = new QueryRunner(Utils2DB.getDataSource()); 106 | 107 | String sql = "SELECT * FROM orders WHERE user_id=? "; 108 | 109 | try { 110 | return (List) queryRunner.query(sql, new BeanListHandler(Order.class), new Object[]{user_id}); 111 | 112 | } catch (SQLException e) { 113 | throw new RuntimeException(e); 114 | } 115 | 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/zhongfucheng/web/manager/BookServlet.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.web.manager; 2 | 3 | import org.apache.commons.beanutils.BeanUtils; 4 | import org.apache.commons.fileupload.FileItem; 5 | import org.apache.commons.fileupload.disk.DiskFileItemFactory; 6 | import org.apache.commons.fileupload.servlet.ServletFileUpload; 7 | import zhongfucheng.domain.Book; 8 | import zhongfucheng.domain.Category; 9 | import zhongfucheng.domain.Page; 10 | import zhongfucheng.service.BussinessServiceDao; 11 | import zhongfucheng.service.impl.BussinessServiceImpl; 12 | import zhongfucheng.utils.WebUtils; 13 | 14 | import javax.servlet.ServletException; 15 | import javax.servlet.annotation.WebServlet; 16 | import javax.servlet.http.HttpServlet; 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.io.File; 20 | import java.io.FileOutputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.List; 24 | 25 | /** 26 | * Created by ozc on 2017/4/12. 27 | */ 28 | @WebServlet(name = "BookServlet",urlPatterns = "/BookServlet") 29 | public class BookServlet extends HttpServlet { 30 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | 32 | String method = request.getParameter("method"); 33 | BussinessServiceDao service = new BussinessServiceImpl(); 34 | 35 | if (method.equals("addUI")) { 36 | 37 | List list = service.getAllCategory(); 38 | request.setAttribute("list", list); 39 | request.getRequestDispatcher("/background/addBook.jsp").forward(request, response); 40 | 41 | } else if (method.equals("add")) { 42 | 43 | //上传文件和普通数据分割开,封装到Book对象上 44 | Book book = uploadData(request); 45 | 46 | book.setId(WebUtils.makeId()); 47 | service.addBook(book); 48 | request.setAttribute("message", "添加图书成功"); 49 | request.getRequestDispatcher("/message.jsp").forward(request, response); 50 | } else if (method.equals("look")) { 51 | 52 | String currentPageCount = request.getParameter("currentPageCount"); 53 | Page page = service.getPageData(currentPageCount); 54 | 55 | request.setAttribute("page",page); 56 | request.getRequestDispatcher("/background/listBook.jsp").forward(request, response); 57 | } 58 | 59 | 60 | } 61 | 62 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 63 | 64 | this.doPost(request, response); 65 | } 66 | 67 | private Book uploadData(HttpServletRequest request) { 68 | 69 | Book book = new Book(); 70 | try{ 71 | 72 | //1.得到解析器工厂 73 | DiskFileItemFactory factory = new DiskFileItemFactory(); 74 | 75 | //2.得到解析器 76 | ServletFileUpload upload = new ServletFileUpload(factory); 77 | 78 | //设置编码 79 | upload.setHeaderEncoding("UTF-8"); 80 | 81 | 82 | //为上传表单,则调用解析器解析上传数据 83 | List list = upload.parseRequest(request); //FileItem 84 | 85 | //遍历list,得到用于封装第一个上传输入项数据fileItem对象 86 | for(FileItem item : list){ 87 | 88 | if(item.isFormField()){ 89 | 90 | //得到的是普通输入项 91 | String name = item.getFieldName(); //得到输入项的名称 92 | String value = item.getString("UTF-8"); 93 | 94 | //使用BeanUtils封装数据 95 | BeanUtils.setProperty(book, name, value); 96 | }else{ 97 | 98 | //得到上传输入项 99 | 100 | //得到上传文件名全路径 101 | String filename = item.getName(); 102 | 103 | //截取文件名 104 | filename = filename.substring(filename.lastIndexOf("\\")+1); 105 | 106 | InputStream in = item.getInputStream(); //得到上传数据 107 | 108 | int len = 0; 109 | byte buffer[]= new byte[1024]; 110 | 111 | //如果没有这个目录,就创建它 112 | String savepath = this.getServletContext().getRealPath("/image"); 113 | File file = new File(savepath); 114 | if (!file.exists()) { 115 | file.mkdir(); 116 | } 117 | 118 | FileOutputStream out = new FileOutputStream(savepath + "\\" + filename); 119 | while((len=in.read(buffer))>0){ 120 | out.write(buffer, 0, len); 121 | } 122 | //设置图片的名字 123 | book.setImage(filename); 124 | 125 | in.close(); 126 | out.close(); 127 | 128 | //关闭临时文件 129 | item.delete(); 130 | } 131 | } 132 | 133 | }catch (Exception e) { 134 | e.printStackTrace(); 135 | } 136 | return book; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/zhongfucheng/service/impl/BussinessServiceImpl.java: -------------------------------------------------------------------------------- 1 | package zhongfucheng.service.impl; 2 | 3 | import zhongfucheng.dao.BookDao; 4 | import zhongfucheng.dao.CategoryDao; 5 | import zhongfucheng.dao.OrderDao; 6 | import zhongfucheng.dao.UserDao; 7 | import zhongfucheng.domain.*; 8 | import zhongfucheng.service.BussinessServiceDao; 9 | import zhongfucheng.utils.DaoFactory; 10 | import zhongfucheng.utils.WebUtils; 11 | import zhongfucheng.utils.permission; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * Created by ozc on 2017/4/12. 19 | */ 20 | public class BussinessServiceImpl implements BussinessServiceDao { 21 | 22 | private CategoryDao categoryDao = DaoFactory.getInstance().createDao("zhongfucheng.dao.impl.CategoryDAOImpl", CategoryDao.class); 23 | 24 | private BookDao bookDao = DaoFactory.getInstance().createDao("zhongfucheng.dao.impl.BookDaoImpl", BookDao.class); 25 | 26 | private UserDao userDao = DaoFactory.getInstance().createDao("zhongfucheng.dao.impl.UserDaoImpl", UserDao.class); 27 | 28 | private OrderDao orderDao = DaoFactory.getInstance().createDao("zhongfucheng.dao.impl.OrderDaoImpl", OrderDao.class); 29 | 30 | 31 | @Override 32 | @permission("添加分类") 33 | /*添加分类*/ 34 | public void addCategory(Category category) { 35 | categoryDao.addCategory(category); 36 | } 37 | 38 | 39 | /*查找分类*/ 40 | @Override 41 | public void findCategory(String id) { 42 | categoryDao.findCategory(id); 43 | } 44 | 45 | @Override 46 | @permission("查找分类") 47 | /*查看分类*/ 48 | public List getAllCategory() { 49 | return categoryDao.getAllCategory(); 50 | } 51 | 52 | /*添加图书*/ 53 | @Override 54 | public void addBook(Book book) { 55 | bookDao.addBook(book); 56 | 57 | } 58 | 59 | /*查找图书*/ 60 | @Override 61 | public Book findBook(String id) { 62 | return bookDao.findBook(id); 63 | } 64 | 65 | /*获取图书的分页数据*/ 66 | @Override 67 | public Page getPageData(String currentPageCount) { 68 | 69 | Page page=null; 70 | 71 | if (currentPageCount == null) { 72 | page = new Page(1, bookDao.getTotalRecord()); 73 | } else { 74 | page = new Page(Integer.valueOf(currentPageCount), bookDao.getTotalRecord()); 75 | } 76 | 77 | List books = bookDao.getPageData(page.getStartIndex(), page.getLinesize()); 78 | page.setList(books); 79 | 80 | 81 | return page; 82 | 83 | } 84 | 85 | /*获取图书分类后的分页数据*/ 86 | @Override 87 | public Page getPageData(String currentPageCount, String category_id) { 88 | 89 | Page page=null; 90 | if (currentPageCount == null) { 91 | page = new Page(1, bookDao.getCategoryTotalRecord(category_id)); 92 | } else { 93 | page = new Page(Integer.valueOf(currentPageCount), bookDao.getCategoryTotalRecord(category_id)); 94 | } 95 | 96 | List books = bookDao.getPageData(page.getStartIndex(), page.getLinesize(), category_id); 97 | page.setList(books); 98 | return page; 99 | } 100 | 101 | @Override 102 | public void registerUser(User user) { 103 | userDao.register(user); 104 | } 105 | 106 | @Override 107 | public User loginUser(String username, String password) { 108 | return userDao.login(username, password); 109 | } 110 | 111 | @Override 112 | public User findUser(String id) { 113 | return userDao.find(id); 114 | } 115 | 116 | @Override 117 | public void buyBook(Cart cart, Book book) { 118 | cart.addBook2Cart(book); 119 | 120 | } 121 | 122 | @Override 123 | public void createOrder(Cart cart, User user) { 124 | 125 | //订单的基本信息 126 | String order_id = WebUtils.makeId(); 127 | Order order = new Order(); 128 | order.setId(order_id); 129 | order.setPrice(cart.getPrice()); 130 | order.setOrdertime(new Date()); 131 | order.setState(false); 132 | order.setUser_id(user.getId()); 133 | 134 | 135 | //订单项的基本信息 136 | //得到每个购物项,购物项就作为订单项 137 | for (Map.Entry me : cart.getMap().entrySet()) { 138 | 139 | OrderItem orderItem = new OrderItem(); 140 | CartItem cartItem = me.getValue(); 141 | 142 | orderItem.setId(WebUtils.makeId()); 143 | orderItem.setPrice(cartItem.getPrice()); 144 | orderItem.setBook_id(cartItem.getBook().getId()); 145 | orderItem.setQuantity(cartItem.getQuantity()); 146 | orderItem.setOrder_id(order_id); 147 | order.getItems().add(orderItem); 148 | } 149 | 150 | System.out.println(cart.getMap().size()); 151 | orderDao.addOrder(order); 152 | 153 | } 154 | 155 | @Override 156 | public Order findOrder(String user_id) { 157 | 158 | return orderDao.findOrder(user_id); 159 | } 160 | 161 | @Override 162 | public List getAllOrder(boolean state) { 163 | return orderDao.getAllOrder(state); 164 | } 165 | 166 | @Override 167 | public void sendOutOrder(String id) { 168 | 169 | orderDao.updateState(id); 170 | } 171 | 172 | @Override 173 | public List findUserOrder(String user_id) { 174 | return orderDao.findUserOrder(user_id); 175 | } 176 | 177 | @Override 178 | public List findUserPrivilege(String user_id) { 179 | return userDao.findUserPrivilege(user_id); 180 | } 181 | 182 | } 183 | -------------------------------------------------------------------------------- /.idea/dataSources/676d6293-663d-4ed2-9b3f-6a160569295a.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 |
    16 |
    17 |
    18 | 19 | varchar(40)|0 20 | 1 21 | 22 | 23 | varchar(10)|0 24 | 1 25 | 26 | 27 | varchar(255)|0 28 | 29 | 30 | name 31 | 1 32 | 33 | 34 | id 35 | 1 36 | 37 | 38 | name 39 | name 40 | 41 | 42 | varchar(40)|0 43 | 1 44 | 45 | 46 | varchar(10)|0 47 | 1 48 | 49 | 50 | varchar(255)|0 51 | 52 | 53 | varchar(10)|0 54 | 55 | 56 | float|0 57 | 58 | 59 | varchar(100)|0 60 | 61 | 62 | varchar(40)|0 63 | 64 | 65 | category_id 66 | 67 | 68 | name 69 | 1 70 | 71 | 72 | id 73 | 1 74 | 75 | 76 | name 77 | name 78 | 79 | 80 | category_id 81 | category 82 | PRIMARY 83 | id 84 | restrict 85 | restrict 86 | 87 | 88 | varchar(40)|0 89 | 1 90 | 91 | 92 | varchar(20)|0 93 | 1 94 | 95 | 96 | varchar(20)|0 97 | 1 98 | 99 | 100 | varchar(40)|0 101 | 1 102 | 103 | 104 | varchar(30)|0 105 | 106 | 107 | varchar(30)|0 108 | 1 109 | 110 | 111 | id 112 | 1 113 | 114 | 115 | varchar(40)|0 116 | 1 117 | 118 | 119 | datetime|0 120 | 1 121 | 122 | 123 | varchar(40)|0 124 | 125 | 126 | tinyint(1)|0 127 | 128 | 129 | double|0 130 | 131 | 132 | user_id 133 | 134 | 135 | id 136 | 1 137 | 138 | 139 | user_id 140 | user 141 | PRIMARY 142 | id 143 | restrict 144 | restrict 145 | 146 | 147 | varchar(40)|0 148 | 1 149 | 150 | 151 | double|0 152 | 153 | 154 | int(11)|0 155 | 156 | 157 | varchar(40)|0 158 | 159 | 160 | varchar(40)|0 161 | 162 | 163 | book_id 164 | 165 | 166 | order_id 167 | 168 | 169 | id 170 | 1 171 | 172 | 173 | order_id 174 | orders 175 | PRIMARY 176 | id 177 | restrict 178 | restrict 179 | 180 | 181 | book_id 182 | book 183 | PRIMARY 184 | id 185 | restrict 186 | restrict 187 | 188 | 189 | -------------------------------------------------------------------------------- /.idea/dataSources/a269c7c2-c473-4b3b-b36e-9c3ef04bb431.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 |
    14 |
    15 |
    16 |
    17 |
    18 |
    19 |
    20 | 21 | varchar(40)|0 22 | 1 23 | 24 | 25 | varchar(10)|0 26 | 1 27 | 28 | 29 | varchar(255)|0 30 | 31 | 32 | varchar(10)|0 33 | 34 | 35 | float|0 36 | 37 | 38 | varchar(100)|0 39 | 40 | 41 | varchar(40)|0 42 | 43 | 44 | category_id 45 | 46 | 47 | name 48 | 1 49 | 50 | 51 | id 52 | 1 53 | 54 | 55 | name 56 | name 57 | 58 | 59 | category_id 60 | category 61 | PRIMARY 62 | id 63 | restrict 64 | restrict 65 | 66 | 67 | varchar(40)|0 68 | 1 69 | 70 | 71 | varchar(10)|0 72 | 1 73 | 74 | 75 | varchar(255)|0 76 | 77 | 78 | name 79 | 1 80 | 81 | 82 | id 83 | 1 84 | 85 | 86 | name 87 | name 88 | 89 | 90 | varchar(40)|0 91 | 1 92 | 93 | 94 | double|0 95 | 96 | 97 | int(11)|0 98 | 99 | 100 | varchar(40)|0 101 | 102 | 103 | varchar(40)|0 104 | 105 | 106 | book_id 107 | 108 | 109 | order_id 110 | 111 | 112 | id 113 | 1 114 | 115 | 116 | order_id 117 | orders 118 | PRIMARY 119 | id 120 | restrict 121 | restrict 122 | 123 | 124 | book_id 125 | book 126 | PRIMARY 127 | id 128 | restrict 129 | restrict 130 | 131 | 132 | varchar(40)|0 133 | 1 134 | 135 | 136 | datetime|0 137 | 1 138 | 139 | 140 | varchar(40)|0 141 | 142 | 143 | tinyint(1)|0 144 | 145 | 146 | double|0 147 | 148 | 149 | user_id 150 | 151 | 152 | id 153 | 1 154 | 155 | 156 | user_id 157 | user 158 | PRIMARY 159 | id 160 | restrict 161 | restrict 162 | 163 | 164 | varchar(40)|0 165 | 1 166 | 167 | 168 | varchar(20)|0 169 | 1 170 | 171 | 172 | varchar(20)|0 173 | 1 174 | 175 | 176 | varchar(40)|0 177 | 1 178 | 179 | 180 | varchar(30)|0 181 | 182 | 183 | varchar(30)|0 184 | 1 185 | 186 | 187 | id 188 | 1 189 | 190 | 191 | varchar(40)|0 192 | 1 193 | 194 | 195 | varchar(40)|0 196 | 197 | 198 | id 199 | 1 200 | 201 | 202 | varchar(40)|0 203 | 1 204 | 205 | 206 | varchar(40)|0 207 | 1 208 | 209 | 210 | privilege_id 211 | 212 | 213 | user_id 214 | privilege_id 215 | 1 216 | 217 | 218 | privilege_id 219 | privilege 220 | PRIMARY 221 | id 222 | restrict 223 | restrict 224 | 225 | 226 | user_id 227 | user 228 | PRIMARY 229 | id 230 | restrict 231 | restrict 232 | 233 | 234 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/dataSources.ids: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 |
    16 |
    17 |
    18 |
    19 | 20 | 1 21 | varchar(40)|0 22 | 23 | 24 | 1 25 | varchar(10)|0 26 | 27 | 28 | varchar(255)|0 29 | 30 | 31 | name 32 | 33 | 1 34 | 35 | 36 | id 37 | 1 38 | 39 | 40 | name 41 | name 42 | 43 | 44 | 1 45 | varchar(40)|0 46 | 47 | 48 | 1 49 | varchar(10)|0 50 | 51 | 52 | varchar(255)|0 53 | 54 | 55 | varchar(10)|0 56 | 57 | 58 | float|0 59 | 60 | 61 | varchar(100)|0 62 | 63 | 64 | varchar(40)|0 65 | 66 | 67 | category_id 68 | 69 | 70 | 71 | name 72 | 73 | 1 74 | 75 | 76 | id 77 | 1 78 | 79 | 80 | name 81 | name 82 | 83 | 84 | category_id 85 | ~.category.PRIMARY 86 | restrict 87 | restrict 88 | 89 | 90 | 1 91 | varchar(40)|0 92 | 93 | 94 | 1 95 | varchar(20)|0 96 | 97 | 98 | 1 99 | varchar(20)|0 100 | 101 | 102 | 1 103 | varchar(40)|0 104 | 105 | 106 | varchar(30)|0 107 | 108 | 109 | 1 110 | varchar(30)|0 111 | 112 | 113 | id 114 | 1 115 | 116 | 117 | 1 118 | varchar(40)|0 119 | 120 | 121 | 1 122 | datetime|0 123 | 124 | 125 | varchar(40)|0 126 | 127 | 128 | tinyint(1)|0 129 | 130 | 131 | double|0 132 | 133 | 134 | user_id 135 | 136 | 137 | 138 | id 139 | 1 140 | 141 | 142 | user_id 143 | ~.user.PRIMARY 144 | restrict 145 | restrict 146 | 147 | 148 | 1 149 | varchar(40)|0 150 | 151 | 152 | double|0 153 | 154 | 155 | int(11)|0 156 | 157 | 158 | varchar(40)|0 159 | 160 | 161 | varchar(40)|0 162 | 163 | 164 | book_id 165 | 166 | 167 | 168 | order_id 169 | 170 | 171 | 172 | id 173 | 1 174 | 175 | 176 | order_id 177 | ~.orders.PRIMARY 178 | restrict 179 | restrict 180 | 181 | 182 | book_id 183 | ~.book.PRIMARY 184 | restrict 185 | restrict 186 | 187 | 188 | 189 | 190 | 191 | #@ 192 | ` 193 | 194 | 195 | 196 | 197 | 1 198 | 199 | 200 | 201 | 202 | 203 | 204 |
    205 |
    206 |
    207 |
    208 |
    209 |
    210 |
    211 | 212 | 1 213 | varchar(40)|0 214 | 215 | 216 | 1 217 | varchar(10)|0 218 | 219 | 220 | varchar(255)|0 221 | 222 | 223 | varchar(10)|0 224 | 225 | 226 | float|0 227 | 228 | 229 | varchar(100)|0 230 | 231 | 232 | varchar(40)|0 233 | 234 | 235 | category_id 236 | 237 | 238 | 239 | name 240 | 241 | 1 242 | 243 | 244 | id 245 | 1 246 | 247 | 248 | name 249 | name 250 | 251 | 252 | category_id 253 | ~.category.PRIMARY 254 | restrict 255 | restrict 256 | 257 | 258 | 1 259 | varchar(40)|0 260 | 261 | 262 | 1 263 | varchar(10)|0 264 | 265 | 266 | varchar(255)|0 267 | 268 | 269 | name 270 | 271 | 1 272 | 273 | 274 | id 275 | 1 276 | 277 | 278 | name 279 | name 280 | 281 | 282 | 1 283 | varchar(40)|0 284 | 285 | 286 | double|0 287 | 288 | 289 | int(11)|0 290 | 291 | 292 | varchar(40)|0 293 | 294 | 295 | varchar(40)|0 296 | 297 | 298 | book_id 299 | 300 | 301 | 302 | order_id 303 | 304 | 305 | 306 | id 307 | 1 308 | 309 | 310 | order_id 311 | ~.orders.PRIMARY 312 | restrict 313 | restrict 314 | 315 | 316 | book_id 317 | ~.book.PRIMARY 318 | restrict 319 | restrict 320 | 321 | 322 | 1 323 | varchar(40)|0 324 | 325 | 326 | 1 327 | datetime|0 328 | 329 | 330 | varchar(40)|0 331 | 332 | 333 | tinyint(1)|0 334 | 335 | 336 | double|0 337 | 338 | 339 | user_id 340 | 341 | 342 | 343 | id 344 | 1 345 | 346 | 347 | user_id 348 | ~.user.PRIMARY 349 | restrict 350 | restrict 351 | 352 | 353 | 1 354 | varchar(40)|0 355 | 356 | 357 | 1 358 | varchar(20)|0 359 | 360 | 361 | 1 362 | varchar(20)|0 363 | 364 | 365 | 1 366 | varchar(40)|0 367 | 368 | 369 | varchar(30)|0 370 | 371 | 372 | 1 373 | varchar(30)|0 374 | 375 | 376 | id 377 | 1 378 | 379 | 380 | 1 381 | varchar(40)|0 382 | 383 | 384 | varchar(40)|0 385 | 386 | 387 | id 388 | 1 389 | 390 | 391 | 1 392 | varchar(40)|0 393 | 394 | 395 | 1 396 | varchar(40)|0 397 | 398 | 399 | privilege_id 400 | 401 | 402 | 403 | user_id 404 | privilege_id 405 | 1 406 | 407 | 408 | privilege_id 409 | ~.privilege.PRIMARY 410 | restrict 411 | restrict 412 | 413 | 414 | user_id 415 | ~.user.PRIMARY 416 | restrict 417 | restrict 418 | 419 | 420 | 421 | --------------------------------------------------------------------------------