diff --git a/Shop/.classpath b/Shop/.classpath new file mode 100644 index 0000000..ae827d4 --- /dev/null +++ b/Shop/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/Shop/.project b/Shop/.project new file mode 100644 index 0000000..e2fe394 --- /dev/null +++ b/Shop/.project @@ -0,0 +1,36 @@ + + + Shop + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/Shop/.settings/.jsdtscope b/Shop/.settings/.jsdtscope new file mode 100644 index 0000000..3a28de0 --- /dev/null +++ b/Shop/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Shop/.settings/org.eclipse.jdt.core.prefs b/Shop/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f42de36 --- /dev/null +++ b/Shop/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Shop/.settings/org.eclipse.wst.common.component b/Shop/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..c063365 --- /dev/null +++ b/Shop/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Shop/.settings/org.eclipse.wst.common.project.facet.core.xml b/Shop/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..8f11b7c --- /dev/null +++ b/Shop/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.container b/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.name b/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/Shop/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/Shop/WebContent/META-INF/MANIFEST.MF b/Shop/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/Shop/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/Shop/WebContent/Test.jsp b/Shop/WebContent/Test.jsp new file mode 100644 index 0000000..f55a3e6 --- /dev/null +++ b/Shop/WebContent/Test.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + + Hello Shop!!!! + + \ No newline at end of file diff --git a/Shop/WebContent/WEB-INF/lib/IKAnalyzer2012.jar b/Shop/WebContent/WEB-INF/lib/IKAnalyzer2012.jar new file mode 100644 index 0000000..aca4a07 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/IKAnalyzer2012.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/antlr-2.7.6.jar b/Shop/WebContent/WEB-INF/lib/antlr-2.7.6.jar new file mode 100644 index 0000000..3702b64 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/antlr-2.7.6.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/asm-3.3.jar b/Shop/WebContent/WEB-INF/lib/asm-3.3.jar new file mode 100644 index 0000000..d44dfd8 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/asm-3.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/asm-commons-3.3.jar b/Shop/WebContent/WEB-INF/lib/asm-commons-3.3.jar new file mode 100644 index 0000000..e509842 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/asm-commons-3.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/asm-tree-3.3.jar b/Shop/WebContent/WEB-INF/lib/asm-tree-3.3.jar new file mode 100644 index 0000000..374bc2e Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/asm-tree-3.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/backport-util-concurrent.jar b/Shop/WebContent/WEB-INF/lib/backport-util-concurrent.jar new file mode 100644 index 0000000..3a4c279 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/backport-util-concurrent.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar new file mode 100644 index 0000000..03e68c7 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.net.sf.cglib-2.2.0.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.net.sf.cglib-2.2.0.jar new file mode 100644 index 0000000..83989cb Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.net.sf.cglib-2.2.0.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.aopalliance-1.0.0.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aopalliance-1.0.0.jar new file mode 100644 index 0000000..3c5cf8b Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aopalliance-1.0.0.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar new file mode 100644 index 0000000..a8ef066 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.logging-1.1.1.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.logging-1.1.1.jar new file mode 100644 index 0000000..f50c78c Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.logging-1.1.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.pool-1.5.3.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.pool-1.5.3.jar new file mode 100644 index 0000000..743c39b Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.apache.commons.pool-1.5.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar new file mode 100644 index 0000000..839df2d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar new file mode 100644 index 0000000..7bbb83a Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/commons-collections-3.1.jar b/Shop/WebContent/WEB-INF/lib/commons-collections-3.1.jar new file mode 100644 index 0000000..41e230f Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/commons-collections-3.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar b/Shop/WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar new file mode 100644 index 0000000..af0cda2 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/commons-io-2.2.jar b/Shop/WebContent/WEB-INF/lib/commons-io-2.2.jar new file mode 100644 index 0000000..84ca565 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/commons-io-2.2.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/commons-lang3-3.1.jar b/Shop/WebContent/WEB-INF/lib/commons-lang3-3.1.jar new file mode 100644 index 0000000..a85e539 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/commons-lang3-3.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/commons-logging-1.1.3.jar b/Shop/WebContent/WEB-INF/lib/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/commons-logging-1.1.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/dom4j-1.6.1.jar b/Shop/WebContent/WEB-INF/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/dom4j-1.6.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/ehcache-1.5.0.jar b/Shop/WebContent/WEB-INF/lib/ehcache-1.5.0.jar new file mode 100644 index 0000000..1a83c6a Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/ehcache-1.5.0.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/freemarker-2.3.19.jar b/Shop/WebContent/WEB-INF/lib/freemarker-2.3.19.jar new file mode 100644 index 0000000..b13671d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/freemarker-2.3.19.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar b/Shop/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar new file mode 100644 index 0000000..4c9ac4e Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/hibernate3.jar b/Shop/WebContent/WEB-INF/lib/hibernate3.jar new file mode 100644 index 0000000..7275ad6 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/hibernate3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/java-mail-1.4.4.jar b/Shop/WebContent/WEB-INF/lib/java-mail-1.4.4.jar new file mode 100644 index 0000000..9d60d13 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/java-mail-1.4.4.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar b/Shop/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar new file mode 100644 index 0000000..8f692f4 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/jstl.jar b/Shop/WebContent/WEB-INF/lib/jstl.jar new file mode 100644 index 0000000..a02abec Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/jstl.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/jta-1.1.jar b/Shop/WebContent/WEB-INF/lib/jta-1.1.jar new file mode 100644 index 0000000..6d225b7 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/jta-1.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/junit-4.9b2.jar b/Shop/WebContent/WEB-INF/lib/junit-4.9b2.jar new file mode 100644 index 0000000..aec30a0 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/junit-4.9b2.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/log4j-1.2.17.jar b/Shop/WebContent/WEB-INF/lib/log4j-1.2.17.jar new file mode 100644 index 0000000..1d425cf Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/log4j-1.2.17.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/lucene-core-3.6.0.jar b/Shop/WebContent/WEB-INF/lib/lucene-core-3.6.0.jar new file mode 100644 index 0000000..5cb8dae Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/lucene-core-3.6.0.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/mysql-connector-java-5.1.30-bin.jar b/Shop/WebContent/WEB-INF/lib/mysql-connector-java-5.1.30-bin.jar new file mode 100644 index 0000000..afef9b2 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/mysql-connector-java-5.1.30-bin.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/ognl-3.0.6.jar b/Shop/WebContent/WEB-INF/lib/ognl-3.0.6.jar new file mode 100644 index 0000000..b0838b7 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/ognl-3.0.6.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar new file mode 100644 index 0000000..db6f529 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..7cd3a62 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar new file mode 100644 index 0000000..11fc11b Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar new file mode 100644 index 0000000..f2e2e92 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar new file mode 100644 index 0000000..bd1367d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e46f9eb Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar new file mode 100644 index 0000000..ea9500d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6ef99d8 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e149290 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar new file mode 100644 index 0000000..dcd1e4d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar new file mode 100644 index 0000000..f7a3b83 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar new file mode 100644 index 0000000..9cea2ae Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..d0550cc Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar new file mode 100644 index 0000000..1688cf7 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd b/Shop/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd new file mode 100644 index 0000000..b3aa6af --- /dev/null +++ b/Shop/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd @@ -0,0 +1,21 @@ +Library-SymbolicName: org.springframework.spring +Library-Version: 3.0.5.RELEASE +Library-Name: Spring Framework +Import-Bundle: + org.springframework.aop;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.asm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.aspects;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.beans;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.context;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.context.support;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.core;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.expression;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.jdbc;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.jms;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.orm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.oxm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.transaction;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web.servlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web.portlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + com.springsource.org.aopalliance;version="[1.0.0, 1.0.0]" diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar new file mode 100644 index 0000000..237995c Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar new file mode 100644 index 0000000..2f52122 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar new file mode 100644 index 0000000..5a2381a Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6ec9d68 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar new file mode 100644 index 0000000..6d13bd4 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar b/Shop/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar new file mode 100644 index 0000000..e351ae7 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar b/Shop/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar new file mode 100644 index 0000000..f1f4fdd Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/slf4j-log4j12-1.6.1.jar b/Shop/WebContent/WEB-INF/lib/slf4j-log4j12-1.6.1.jar new file mode 100644 index 0000000..873d119 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/slf4j-log4j12-1.6.1.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/standard.jar b/Shop/WebContent/WEB-INF/lib/standard.jar new file mode 100644 index 0000000..bc528ac Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/standard.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/struts2-core-2.3.16.3.jar b/Shop/WebContent/WEB-INF/lib/struts2-core-2.3.16.3.jar new file mode 100644 index 0000000..2c05fda Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/struts2-core-2.3.16.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/struts2-spring-plugin-2.3.16.3.jar b/Shop/WebContent/WEB-INF/lib/struts2-spring-plugin-2.3.16.3.jar new file mode 100644 index 0000000..5feb35d Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/struts2-spring-plugin-2.3.16.3.jar differ diff --git a/Shop/WebContent/WEB-INF/lib/xwork-core-2.3.16.3.jar b/Shop/WebContent/WEB-INF/lib/xwork-core-2.3.16.3.jar new file mode 100644 index 0000000..05ab811 Binary files /dev/null and b/Shop/WebContent/WEB-INF/lib/xwork-core-2.3.16.3.jar differ diff --git a/Shop/WebContent/WEB-INF/web.xml b/Shop/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000..56af88f --- /dev/null +++ b/Shop/WebContent/WEB-INF/web.xml @@ -0,0 +1,57 @@ + + + Shop + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + + + ManagerFilter + com.cn.shop.filter.ManagerFilter + + + ManagerFilter + /manager/* + + + + openSessionInViewFilter + org.springframework.orm.hibernate3.support.OpenSessionInViewFilter + + + openSessionInViewFilter + /* + + + + + + + + + + org.springframework.web.context.ContextLoaderListener + + + + + contextConfigLocation + + classpath:beans.xml + + + + struts2 + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /* + + \ No newline at end of file diff --git a/Shop/WebContent/cart.jsp b/Shop/WebContent/cart.jsp new file mode 100644 index 0000000..15a7686 --- /dev/null +++ b/Shop/WebContent/cart.jsp @@ -0,0 +1,119 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + +<%@taglib uri="/struts-tags" prefix="s" %> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + +我的购物车 + + + +

+ 购物车 +

+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ 选择 + + 商品名称 + + 单价 + + 数量 + + 合计 +
+ + + ${item.value.product.name} + + ${item.value.product.price} + + + + ${item.value.cost} +
+ 您的购物车中所有商品总金额:${sessionScope.cart.price } +
+
+
+ + + + + + + + + + +
+ + + + + + + + + +
+

+   +

+
+ + + + \ No newline at end of file diff --git a/Shop/WebContent/fail.jsp b/Shop/WebContent/fail.jsp new file mode 100644 index 0000000..ae1c347 --- /dev/null +++ b/Shop/WebContent/fail.jsp @@ -0,0 +1,14 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + + + Fail!!!! + + + \ No newline at end of file diff --git a/Shop/WebContent/find.jsp b/Shop/WebContent/find.jsp new file mode 100644 index 0000000..ddd7c2e --- /dev/null +++ b/Shop/WebContent/find.jsp @@ -0,0 +1,25 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + <% String context = request.getContextPath(); %> + + + + +搜索商品 + + + +
+ + 搜索框:
+ + + + + + + +
+ + + \ No newline at end of file diff --git a/Shop/WebContent/findlist.jsp b/Shop/WebContent/findlist.jsp new file mode 100644 index 0000000..21169b8 --- /dev/null +++ b/Shop/WebContent/findlist.jsp @@ -0,0 +1,118 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + +<%@taglib uri="/struts-tags" prefix="s" %> + + + + + + +我的购物车 + + +

+ 本系统的所有商品列表如下: +
+
+ + + + + + + + <%-- + + + + + --%> + + + + + + + + + + +
+ 产品图片 + + 产品名称 + + 添加到购物车 +
+ ${p.name} + + 添加到购物车 +
+ + + + + + <%-- --%> + + + + + + + + + + | + + + + ">添加到购物车 + <%-- ">修改Category --%> +
+ + +
+ + + + + + 首页 + + 首页 + + 上一页 + + 上一页 + + 下一页 + + 下一页 + + 末页 + + 末页 + + + + + + +
+ + 查看购物车   + 结帐   + 返回首页   + 登录   + 注册   + +

+ + + \ No newline at end of file diff --git a/Shop/WebContent/index.jsp b/Shop/WebContent/index.jsp new file mode 100644 index 0000000..581522a --- /dev/null +++ b/Shop/WebContent/index.jsp @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + + + +欢迎进入淘淘商城 + + + + + + + \ No newline at end of file diff --git a/Shop/WebContent/list.jsp b/Shop/WebContent/list.jsp new file mode 100644 index 0000000..3105c46 --- /dev/null +++ b/Shop/WebContent/list.jsp @@ -0,0 +1,140 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + +<%@taglib uri="/struts-tags" prefix="s" %> + + + + + + +我的购物车 + + +

+ 搜索商品   +
+ 本系统的所有商品列表如下: +
+
+ + + + + + + + + + <%-- + + + + + --%> + + + + + + + + + + + + + + + + +
+ 产品图片 + + 产品名称 + + 产品价格 + + 产品描述 + + 添加到购物车 +
+ ${p.name} + + 添加到购物车 +
+ + + + + + + + + + + + + + + + + | + + + | + + + | + + + + ">添加到购物车 + <%-- ">修改Category --%> +
+ + +
+ + + + + + 首页 + + 首页 + + 上一页 + + 上一页 + + 下一页 + + 下一页 + + 末页 + + 末页 + + + + + + +
+ + 查看购物车   + 结帐   + 返回首页   + 登录   + 注册   + + +

+ + + \ No newline at end of file diff --git a/Shop/WebContent/login.jsp b/Shop/WebContent/login.jsp new file mode 100644 index 0000000..f816ad2 --- /dev/null +++ b/Shop/WebContent/login.jsp @@ -0,0 +1,27 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + <% String context = request.getContextPath(); %> + + + + +我的购物车 + + + +
+ + 用户名:
+ + 密码:
+ + + + + + + +
+ + + \ No newline at end of file diff --git a/Shop/WebContent/manager/addProduct.jsp b/Shop/WebContent/manager/addProduct.jsp new file mode 100644 index 0000000..dc37499 --- /dev/null +++ b/Shop/WebContent/manager/addProduct.jsp @@ -0,0 +1,39 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib prefix="s" uri="/struts-tags" %> + +<% + +String context = request.getContextPath(); + +%> + + + + +商品编辑 + + + +
+    + + + + + + + + + +
商品名称:
商品价格:
商品描述:
商品图片:
+ + + + + +
+ + + \ No newline at end of file diff --git a/Shop/WebContent/manager/flush.jsp b/Shop/WebContent/manager/flush.jsp new file mode 100644 index 0000000..1edda4e --- /dev/null +++ b/Shop/WebContent/manager/flush.jsp @@ -0,0 +1,14 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + + + +Insert title here + + + + + + \ No newline at end of file diff --git a/Shop/WebContent/manager/index.jsp b/Shop/WebContent/manager/index.jsp new file mode 100644 index 0000000..14695af --- /dev/null +++ b/Shop/WebContent/manager/index.jsp @@ -0,0 +1,25 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + + + +后台界面 + + + + 添加商品   + +
+ 商品列表   +
+ + 查看订单状态   + +
+ 返回前台首页 + + + + \ No newline at end of file diff --git a/Shop/WebContent/manager/manager.jsp b/Shop/WebContent/manager/manager.jsp new file mode 100644 index 0000000..e95d906 --- /dev/null +++ b/Shop/WebContent/manager/manager.jsp @@ -0,0 +1,107 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + <% String context = request.getContextPath(); %> + +<%@taglib uri="/struts-tags" prefix="s" %> + + + + + +后台管理 + + + +

+ 订单列表 +

+
+ + + + + + + + + + <%-- + + + + + + + + --%> + + + + + + + + + + + +
+ 订单状态 + + 订单用户名 + + 订单号 + + 订单总价 + + 操作 +
+ ${o.statusText} + + ${o.user.name} + + ${o.orderNum} + + ${o.cost} + + + 下一步 + +
+ + + + + + + + + + + + + + + + + + + ">下一步 + + + + + <%-- ">修改Category --%> +
+
+
+ + 退出 + + 返回主页 + +
+ + + + \ No newline at end of file diff --git a/Shop/WebContent/manager/productlist.jsp b/Shop/WebContent/manager/productlist.jsp new file mode 100644 index 0000000..d5521b1 --- /dev/null +++ b/Shop/WebContent/manager/productlist.jsp @@ -0,0 +1,137 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% String context = request.getContextPath(); %> + +<%@taglib uri="/struts-tags" prefix="s" %> + + + + + +商品列表 + + + + +

+ 本系统的所有商品列表如下: +
+
+ + + + + + + + + + + <%-- + + + + + --%> + + + + + + + + + + + + + + + + + + + +
+ 产品图片 + + 产品名称 + + 产品价格 + + 产品描述 + + 修改商品 + + 删除商品 +
+ ${p.name} + + 添加到购物车 +
+ + + + + + + + + + + + + + | + + + | + + + | + + + + ">修改商品 + <%-- ">修改Category --%> + + + + ">删除商品 + <%-- ">修改Category --%> +
+ + +
+ + + + + + 首页 + + 首页 + + 上一页 + + 上一页 + + 下一页 + + 下一页 + + 末页 + + 末页 + +
+ + 返回主页 + + + + +

+ + \ No newline at end of file diff --git a/Shop/WebContent/manager/reflush.jsp b/Shop/WebContent/manager/reflush.jsp new file mode 100644 index 0000000..f091eb8 --- /dev/null +++ b/Shop/WebContent/manager/reflush.jsp @@ -0,0 +1,13 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + + + +reflush + + + + + \ No newline at end of file diff --git a/Shop/WebContent/manager/updateproduct.jsp b/Shop/WebContent/manager/updateproduct.jsp new file mode 100644 index 0000000..5f1680d --- /dev/null +++ b/Shop/WebContent/manager/updateproduct.jsp @@ -0,0 +1,39 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib prefix="s" uri="/struts-tags" %> + +<% + +String context = request.getContextPath(); + +%> + + + + + +修噶商品 + + +
+    + + + + + + + + + +
商品名称:
商品价格:
商品描述:
商品图片:
+ + + + + +
+ + + \ No newline at end of file diff --git a/Shop/WebContent/order.jsp b/Shop/WebContent/order.jsp new file mode 100644 index 0000000..3999cf3 --- /dev/null +++ b/Shop/WebContent/order.jsp @@ -0,0 +1,133 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + +<%@taglib uri="/struts-tags" prefix="s" %> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + +我的购物车 + + + +

+ 你所购买的商品如下: +

+ + + + + + + + + + + + + + + + + + + + +
+ 商品名称 + + 单价 + + 数量 + + 合计 +
+ ${item.value.product.name } + + ${item.value.product.price } + + ${item.value.number } + + ${item.value.cost } +
+ 您的购物车中所有商品总金额:${sessionScope.cart.price } +
+

+

+ 用户联系方式如下: +

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ 姓名: + + +
+ 地址: + + +
+ 邮政编码: + + +
+ E-mail: + + +
+ 联系电话: + + +
+
+ + + + + + + + +
+ + + + + + +
+
+ + + \ No newline at end of file diff --git a/Shop/WebContent/reflushfind.jsp b/Shop/WebContent/reflushfind.jsp new file mode 100644 index 0000000..d82acaa --- /dev/null +++ b/Shop/WebContent/reflushfind.jsp @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% String context = request.getContextPath(); %> + + + + +reflushfind + + + + //这样获取页面数 + + + + \ No newline at end of file diff --git a/Shop/WebContent/reflushlist.jsp b/Shop/WebContent/reflushlist.jsp new file mode 100644 index 0000000..ada08a0 --- /dev/null +++ b/Shop/WebContent/reflushlist.jsp @@ -0,0 +1,14 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% String context = request.getContextPath(); %> + + + + +reflushlist + + + //这样获取页面数 + + + \ No newline at end of file diff --git a/Shop/WebContent/registerreminder.jsp b/Shop/WebContent/registerreminder.jsp new file mode 100644 index 0000000..8e39ae0 --- /dev/null +++ b/Shop/WebContent/registerreminder.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +邮箱认证 + + + 请登录您的邮箱验证!!! + + \ No newline at end of file diff --git a/Shop/WebContent/success.jsp b/Shop/WebContent/success.jsp new file mode 100644 index 0000000..6fbaa5c --- /dev/null +++ b/Shop/WebContent/success.jsp @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +我的订单 + + + +

+
+ 订单生成!订单号为${orderNum } +
+

+ + + \ No newline at end of file diff --git a/Shop/WebContent/userregister.jsp b/Shop/WebContent/userregister.jsp new file mode 100644 index 0000000..99968bc --- /dev/null +++ b/Shop/WebContent/userregister.jsp @@ -0,0 +1,75 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<% String context = request.getContextPath(); %> + + + + +用户注册 + + + + + +

用户注册

+ + +
+ + + + + + + + + + + + + + + + + + + + +
用户名:
密码:
确定密码:
地址:
邮编:
E-Mail:
家庭电话号码:
手机号码:
办公室号码:
验证码: + +   + + "/> + +
+ + + + + +
+ + + + +
+ + + \ No newline at end of file diff --git a/Shop/build/classes/IKAnalyzer.cfg.xml b/Shop/build/classes/IKAnalyzer.cfg.xml new file mode 100644 index 0000000..c26bc4a --- /dev/null +++ b/Shop/build/classes/IKAnalyzer.cfg.xml @@ -0,0 +1,11 @@ + + + + IK Analyzer 扩展配置 + + + stopword.dic; + + \ No newline at end of file diff --git a/Shop/build/classes/beans.xml b/Shop/build/classes/beans.xml new file mode 100644 index 0000000..b2e8dd1 --- /dev/null +++ b/Shop/build/classes/beans.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shop/build/classes/com/cn/shop/action/CartAction.class b/Shop/build/classes/com/cn/shop/action/CartAction.class new file mode 100644 index 0000000..25e4520 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/CartAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/FindAction.class b/Shop/build/classes/com/cn/shop/action/FindAction.class new file mode 100644 index 0000000..ce39049 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/FindAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/ListAction.class b/Shop/build/classes/com/cn/shop/action/ListAction.class new file mode 100644 index 0000000..c9967e4 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/ListAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/LoginAction.class b/Shop/build/classes/com/cn/shop/action/LoginAction.class new file mode 100644 index 0000000..fb1d366 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/LoginAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/LoginOutAction.class b/Shop/build/classes/com/cn/shop/action/LoginOutAction.class new file mode 100644 index 0000000..212c5e2 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/LoginOutAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/ManagerAction.class b/Shop/build/classes/com/cn/shop/action/ManagerAction.class new file mode 100644 index 0000000..abde173 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/ManagerAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/OrderAction.class b/Shop/build/classes/com/cn/shop/action/OrderAction.class new file mode 100644 index 0000000..bb48c20 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/OrderAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/ProductAction.class b/Shop/build/classes/com/cn/shop/action/ProductAction.class new file mode 100644 index 0000000..e7901d2 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/ProductAction.class differ diff --git a/Shop/build/classes/com/cn/shop/action/RegisterAction.class b/Shop/build/classes/com/cn/shop/action/RegisterAction.class new file mode 100644 index 0000000..001fab1 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/action/RegisterAction.class differ diff --git a/Shop/build/classes/com/cn/shop/common/Constants.class b/Shop/build/classes/com/cn/shop/common/Constants.class new file mode 100644 index 0000000..809e3bc Binary files /dev/null and b/Shop/build/classes/com/cn/shop/common/Constants.class differ diff --git a/Shop/build/classes/com/cn/shop/dao/BaseDAO.class b/Shop/build/classes/com/cn/shop/dao/BaseDAO.class new file mode 100644 index 0000000..b1a82ad Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dao/BaseDAO.class differ diff --git a/Shop/build/classes/com/cn/shop/dao/BaseDAOImpl.class b/Shop/build/classes/com/cn/shop/dao/BaseDAOImpl.class new file mode 100644 index 0000000..e2b2555 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dao/BaseDAOImpl.class differ diff --git a/Shop/build/classes/com/cn/shop/dao/UserDAO.class b/Shop/build/classes/com/cn/shop/dao/UserDAO.class new file mode 100644 index 0000000..c952fcd Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dao/UserDAO.class differ diff --git a/Shop/build/classes/com/cn/shop/dao/UserDAOImpl.class b/Shop/build/classes/com/cn/shop/dao/UserDAOImpl.class new file mode 100644 index 0000000..6da39de Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dao/UserDAOImpl.class differ diff --git a/Shop/build/classes/com/cn/shop/dto/ProductDTO.class b/Shop/build/classes/com/cn/shop/dto/ProductDTO.class new file mode 100644 index 0000000..fa3b185 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dto/ProductDTO.class differ diff --git a/Shop/build/classes/com/cn/shop/dto/UserDTO.class b/Shop/build/classes/com/cn/shop/dto/UserDTO.class new file mode 100644 index 0000000..4094e7f Binary files /dev/null and b/Shop/build/classes/com/cn/shop/dto/UserDTO.class differ diff --git a/Shop/build/classes/com/cn/shop/filter/ManagerFilter.class b/Shop/build/classes/com/cn/shop/filter/ManagerFilter.class new file mode 100644 index 0000000..e461b05 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/filter/ManagerFilter.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Administrator.class b/Shop/build/classes/com/cn/shop/model/Administrator.class new file mode 100644 index 0000000..3853147 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/Administrator.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Cart.class b/Shop/build/classes/com/cn/shop/model/Cart.class new file mode 100644 index 0000000..1b1fb41 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/Cart.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Item.class b/Shop/build/classes/com/cn/shop/model/Item.class new file mode 100644 index 0000000..efc4bfb Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/Item.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Item.hbm.xml b/Shop/build/classes/com/cn/shop/model/Item.hbm.xml new file mode 100644 index 0000000..843a860 --- /dev/null +++ b/Shop/build/classes/com/cn/shop/model/Item.hbm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/build/classes/com/cn/shop/model/Order.class b/Shop/build/classes/com/cn/shop/model/Order.class new file mode 100644 index 0000000..c26cfb4 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/Order.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Order.hbm.xml b/Shop/build/classes/com/cn/shop/model/Order.hbm.xml new file mode 100644 index 0000000..1e9a219 --- /dev/null +++ b/Shop/build/classes/com/cn/shop/model/Order.hbm.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/build/classes/com/cn/shop/model/Product.class b/Shop/build/classes/com/cn/shop/model/Product.class new file mode 100644 index 0000000..21beadf Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/Product.class differ diff --git a/Shop/build/classes/com/cn/shop/model/Product.hbm.xml b/Shop/build/classes/com/cn/shop/model/Product.hbm.xml new file mode 100644 index 0000000..0e524c4 --- /dev/null +++ b/Shop/build/classes/com/cn/shop/model/Product.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/build/classes/com/cn/shop/model/User.class b/Shop/build/classes/com/cn/shop/model/User.class new file mode 100644 index 0000000..7418558 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/model/User.class differ diff --git a/Shop/build/classes/com/cn/shop/model/User.hbm.xml b/Shop/build/classes/com/cn/shop/model/User.hbm.xml new file mode 100644 index 0000000..ddf9a4a --- /dev/null +++ b/Shop/build/classes/com/cn/shop/model/User.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shop/build/classes/com/cn/shop/service/OrderService.class b/Shop/build/classes/com/cn/shop/service/OrderService.class new file mode 100644 index 0000000..3567d69 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/OrderService.class differ diff --git a/Shop/build/classes/com/cn/shop/service/OrderServiceImpl.class b/Shop/build/classes/com/cn/shop/service/OrderServiceImpl.class new file mode 100644 index 0000000..a97f89d Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/OrderServiceImpl.class differ diff --git a/Shop/build/classes/com/cn/shop/service/ProductService.class b/Shop/build/classes/com/cn/shop/service/ProductService.class new file mode 100644 index 0000000..ee8bf10 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/ProductService.class differ diff --git a/Shop/build/classes/com/cn/shop/service/ProductServiceImpl.class b/Shop/build/classes/com/cn/shop/service/ProductServiceImpl.class new file mode 100644 index 0000000..e9f2daf Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/ProductServiceImpl.class differ diff --git a/Shop/build/classes/com/cn/shop/service/UserService.class b/Shop/build/classes/com/cn/shop/service/UserService.class new file mode 100644 index 0000000..d872489 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/UserService.class differ diff --git a/Shop/build/classes/com/cn/shop/service/UserServiceImpl.class b/Shop/build/classes/com/cn/shop/service/UserServiceImpl.class new file mode 100644 index 0000000..45691b5 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/service/UserServiceImpl.class differ diff --git a/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender$1.class b/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender$1.class new file mode 100644 index 0000000..9afdeb3 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender$1.class differ diff --git a/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender.class b/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender.class new file mode 100644 index 0000000..3a7ee66 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/EmailAttachmentSender.class differ diff --git a/Shop/build/classes/com/cn/shop/util/FenciUtil.class b/Shop/build/classes/com/cn/shop/util/FenciUtil.class new file mode 100644 index 0000000..03f1e4e Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/FenciUtil.class differ diff --git a/Shop/build/classes/com/cn/shop/util/ProductCode.class b/Shop/build/classes/com/cn/shop/util/ProductCode.class new file mode 100644 index 0000000..a974405 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/ProductCode.class differ diff --git a/Shop/build/classes/com/cn/shop/util/UpLoadUtil.class b/Shop/build/classes/com/cn/shop/util/UpLoadUtil.class new file mode 100644 index 0000000..a0debd5 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/UpLoadUtil.class differ diff --git a/Shop/build/classes/com/cn/shop/util/WordFilter.class b/Shop/build/classes/com/cn/shop/util/WordFilter.class new file mode 100644 index 0000000..a742d05 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/WordFilter.class differ diff --git a/Shop/build/classes/com/cn/shop/util/ZipImage.class b/Shop/build/classes/com/cn/shop/util/ZipImage.class new file mode 100644 index 0000000..f0273d1 Binary files /dev/null and b/Shop/build/classes/com/cn/shop/util/ZipImage.class differ diff --git a/Shop/build/classes/com/cn/test/Keyword.class b/Shop/build/classes/com/cn/test/Keyword.class new file mode 100644 index 0000000..0f644bb Binary files /dev/null and b/Shop/build/classes/com/cn/test/Keyword.class differ diff --git a/Shop/build/classes/com/cn/test/OrderTest.class b/Shop/build/classes/com/cn/test/OrderTest.class new file mode 100644 index 0000000..90d959e Binary files /dev/null and b/Shop/build/classes/com/cn/test/OrderTest.class differ diff --git a/Shop/build/classes/com/cn/test/ProductTest.class b/Shop/build/classes/com/cn/test/ProductTest.class new file mode 100644 index 0000000..c534efb Binary files /dev/null and b/Shop/build/classes/com/cn/test/ProductTest.class differ diff --git a/Shop/build/classes/com/cn/test/Test1.class b/Shop/build/classes/com/cn/test/Test1.class new file mode 100644 index 0000000..95108a7 Binary files /dev/null and b/Shop/build/classes/com/cn/test/Test1.class differ diff --git a/Shop/build/classes/com/cn/test/UserTest.class b/Shop/build/classes/com/cn/test/UserTest.class new file mode 100644 index 0000000..ab5bdfd Binary files /dev/null and b/Shop/build/classes/com/cn/test/UserTest.class differ diff --git a/Shop/build/classes/filter.dic b/Shop/build/classes/filter.dic new file mode 100644 index 0000000..be5aedc --- /dev/null +++ b/Shop/build/classes/filter.dic @@ -0,0 +1,5 @@ +ͣ·Ьñӿȹ˿ +ԱŮ +Ը +룺кС +ɫɫɫҺɫõɫƷɫϺɫɫɫۻɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫ diff --git a/Shop/build/classes/hibernate.cfg.xml b/Shop/build/classes/hibernate.cfg.xml new file mode 100644 index 0000000..ae77684 --- /dev/null +++ b/Shop/build/classes/hibernate.cfg.xml @@ -0,0 +1,69 @@ + + + + + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost/shop + root + 123456 + + + 1 + + + org.hibernate.dialect.MySQLDialect + + + thread + + + org.hibernate.cache.NoCacheProvider + + + true + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/build/classes/log4j.properties b/Shop/build/classes/log4j.properties new file mode 100644 index 0000000..961e887 --- /dev/null +++ b/Shop/build/classes/log4j.properties @@ -0,0 +1,44 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +log4j.rootLogger=warn, stdout + + log4j.appender.hfile = org.apache.log4j.DailyRollingFileAppender + log4j.appender.hfile.File = D\://data//log_bias.log + log4j.appender.hfile.layout = org.apache.log4j.PatternLayout + log4j.appender.hfile.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + +#log4j.logger.org.hibernate=debug +#log4j.logger.org.hibernate=debug + +#log4j.logger.org.hibernate.ejb=debug +#log4j.logger.org.hibernate.ejb.packaging=debug +#log4j.logger.org.hibernate.reflection=debug + +#log4j.logger.org.hibernate.engine.Cascades=debug +#log4j.logger.org.hibernate.hql=debug + +### log just the SQL +#log4j.logger.org.hibernate.SQL=debug + +### log JDBC bind parameters ### +#log4j.logger.org.hibernate.type=info +#log4j.logger.org.hibernate.type=trace + +### log schema export/update ### +log4j.logger.org.hibernate.tool.hbm2ddl=debug + +### log HQL parse trees +#log4j.logger.org.hibernate.hql=debug + +### log cache activity ### +#log4j.logger.org.hibernate.cache=debug + +### log JDBC resource acquisition +#log4j.logger.org.hibernate.jdbc=debug + +### enable the following line if you want to track down connection ### +### leakages when using DriverManagerConnectionProvider ### +#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace diff --git a/Shop/build/classes/stopword.dic b/Shop/build/classes/stopword.dic new file mode 100644 index 0000000..c1b994b --- /dev/null +++ b/Shop/build/classes/stopword.dic @@ -0,0 +1,33 @@ +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with \ No newline at end of file diff --git a/Shop/build/classes/struts.xml b/Shop/build/classes/struts.xml new file mode 100644 index 0000000..b563503 --- /dev/null +++ b/Shop/build/classes/struts.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + /cart.jsp + + + /login.jsp + + + + + /manager/index.jsp + + + + + + + /login.jsp + + + + + + + + /list.jsp + + + + + + + + /reflushlist.jsp + + + + + /reflushfind.jsp + + + + + + + + + + + + + /cart.jsp + + + + + + + /cart.jsp + + + + + + /cart.jsp + + + + + + /cart.jsp + + + + + + + + /login.jsp + + + /order.jsp + + + + + + /success.jsp + + + + + + + /userregister.jsp + + + + /registerreminder.jsp + + + + + + + + /login.jsp + + + + + + + + + + + + + + + /findlist.jsp + + + + + + + + + + + + + + + + + /manager/manager.jsp + + + + + + /manager/flush.jsp + + + + + + + /manager/index.jsp + + + + + + + /manager/productlist.jsp + + + + + + + + /manager/updateproduct.jsp + + + + + + + /manager/reflush.jsp + + + + + + + + /manager/reflush.jsp + + + + + + + + + diff --git a/Shop/sql/shop.sql b/Shop/sql/shop.sql new file mode 100644 index 0000000..e3a32fd --- /dev/null +++ b/Shop/sql/shop.sql @@ -0,0 +1,43 @@ +/*创建商品表*/ +create table store_product +( + id bigint auto_increment primary key, + name varchar(32) not null, + description varchar(500), + imageSrc varchar(500), + price double not null +); + +/*创建用户表*/ +create table store_user +( + id bigint auto_increment primary key, + name varchar(32) unique not null, + password varchar(16) not null, + address varchar(100), + postCode varchar(10), + email varchar(50), + homePhone varchar(32), + cellPhone varchar(32), + officePhone varchar(32), + type varchar(20), + workNo varchar(20) +); +insert into store_user values(1,'throne212','123','成都市XXX街','621000','throne212@xxx.com','123456789','123456789','123456789','common',null); +insert into store_user values(2,'admin','123','','','admin@xxx.com','','','','admin','001'); + +/*创建订单表*/ +create table store_order( + id bigint primary key, + orderNum varchar(17) unique not null, + status integer not null, + user_id bigint references store_user(id), + cost double(10,2) +); +/*创建订单项表*/ +create table store_order_item( + id bigint auto_increment primary key, + amount integer not null, + product_id bigint references store_product(id), + order_id bigint references store_order(id) +); diff --git a/Shop/src/IKAnalyzer.cfg.xml b/Shop/src/IKAnalyzer.cfg.xml new file mode 100644 index 0000000..c26bc4a --- /dev/null +++ b/Shop/src/IKAnalyzer.cfg.xml @@ -0,0 +1,11 @@ + + + + IK Analyzer 扩展配置 + + + stopword.dic; + + \ No newline at end of file diff --git a/Shop/src/beans.xml b/Shop/src/beans.xml new file mode 100644 index 0000000..b2e8dd1 --- /dev/null +++ b/Shop/src/beans.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shop/src/com/cn/shop/action/CartAction.java b/Shop/src/com/cn/shop/action/CartAction.java new file mode 100644 index 0000000..9939d89 --- /dev/null +++ b/Shop/src/com/cn/shop/action/CartAction.java @@ -0,0 +1,155 @@ +package com.cn.shop.action; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Cart; +import com.cn.shop.model.Item; +import com.opensymphony.xwork2.ActionSupport; + +public class CartAction extends ActionSupport { + + private Logger logger = Logger.getLogger(this.getClass()); + + private HttpServletRequest request ; + + private HttpSession session ; + + + + //ﳵҳ + + public String CartIndex( ) + { + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + Cart cart = (Cart) this.session.getAttribute( Constants.SESSION_CART); + + if( cart == null ) + { + cart = new Cart( ); + + this.session.setAttribute(Constants.SESSION_CART, cart ); + } + + + return "cart"; + + + } + + //޸ĹﳵƷ + public String modifyItemNumber( ) + { + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + + String [] itemCheck = this.request.getParameterValues("itemCheck"); + + if( itemCheck == null || itemCheck.length == 0 ) + { + return "cart"; + } + else + { + Cart cart = ( Cart ) this.session.getAttribute(Constants.SESSION_CART); + + for( String productId : itemCheck ) + { + String number = this.request.getParameter("number"+productId); + + cart.modifyNumberBYProductId(Long.valueOf(productId), Integer.valueOf(number)); + } + + for( Long id : cart.getCartItems().keySet() ) + { + Item it = cart.getCartItems().get(id); + + System.out.println( it.getProduct().getName() + " " + it.getNumber() ); + } + + return "cart"; + } + } + + //ɾﳵƷĿ + + public String deleteItem( ) + { + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + String [] itemCheck = this.request.getParameterValues("itemCheck"); + + if( itemCheck == null || itemCheck.length == 0 ) + { + return "cart"; + } + else + { + logger.info("Deleting item size="+itemCheck.length ); + + Long [ ] productIds = new Long[ itemCheck.length ]; + + for( int i = 0; i < productIds.length; i++ ) + { + productIds[ i ] = Long.valueOf(itemCheck[i]); + + + } + + Cart cart = ( Cart ) this.session.getAttribute(Constants.SESSION_CART ); + + cart.deleteItemByProductId(productIds); + + for( Long id : cart.getCartItems().keySet() ) + { + Item it = cart.getCartItems().get(id); + + System.out.println( it.getProduct().getName() + " " + it.getNumber() ); + } + + return "cart"; + } + + } + + //չﳵҳ + public String clear( ) + { + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + logger.info("Cart is clearing..."); + + Cart cart = ( Cart ) this.session.getAttribute(Constants.SESSION_CART ); + + cart.clear(); + + for( Long id : cart.getCartItems().keySet() ) + { + Item it = cart.getCartItems().get(id); + + System.out.println( it.getProduct().getName() + " " + it.getNumber() ); + } + + return "cart"; + } + + + + +} diff --git a/Shop/src/com/cn/shop/action/FindAction.java b/Shop/src/com/cn/shop/action/FindAction.java new file mode 100644 index 0000000..2756804 --- /dev/null +++ b/Shop/src/com/cn/shop/action/FindAction.java @@ -0,0 +1,227 @@ +package com.cn.shop.action; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.model.Product; +import com.cn.shop.service.ProductService; +import com.cn.shop.util.FenciUtil; +import com.cn.shop.util.WordFilter; +import com.opensymphony.xwork2.ActionSupport; + +public class FindAction extends ActionSupport { + + //Ʒservice IOC + private ProductService productService; + + //ؼ + private String keyword; + + //ƪ + + private List< Product > findlist; + + //ҳ + + private int page; + + private int maxpage; + + private HttpServletRequest request; + + + + public int getPage() { + return page; + } + + + + public void setPage(int page) { + this.page = page; + } + + + + public int getMaxpage() { + return maxpage; + } + + + + public void setMaxpage(int maxpage) { + this.maxpage = maxpage; + } + + + + public String getKeyword() { + return keyword; + } + + + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + + + + + public ProductService getProductService() { + return productService; + } + + + + public void setProductService(ProductService productService) { + this.productService = productService; + } + + + + public List getFindlist() { + return findlist; + } + + + + public void setFindlist(List findlist) { + this.findlist = findlist; + } + + + + //Ʒ + public String findproduct( ) + { + if( keyword == null ) + { + return "restart"; + } + + System.out.println("ؼ"+keyword); + + //ִ + List keylist = new ArrayList(); + + //ļfiltermap + + Map filtermap = new HashMap( ); + + + //ȡؼֵkeymap + + Map keymap = new HashMap( ); + + //ؼ + + String word = null; + + //ļַ + + String url = ServletActionContext.getServletContext().getRealPath("/WEB-INF/classes/filter.dic") ; + + + System.out.println( url ); + + + + + try { + + //1зִ + FenciUtil.fenci(keyword, keylist ); + + for( int i = 0 ; i < keylist.size() ; i++ ) + + { + System.out.println( keylist.get(i) ); + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + //2ļ ָļurl + + WordFilter.readType(filtermap , url ); + + for( String key : filtermap.keySet() ) + { + + System.out.println("key" + key + "value" + filtermap.get(key)); + } + + //3ȡؼ + + for( int i = 0 ; i < keylist.size(); i++ ) + { + //ȡؼ + word = keylist.get(i); + + //ȡؼ + + WordFilter.filterword(word, filtermap, keymap); + + + + } + + //鿴 keymap + + System.out.println("====================="); + + for( String key : keymap.keySet() ) + { + + System.out.println("key" + key + "value" + keymap.get(key)); + } + + + + this.request = ServletActionContext.getRequest(); + + int maxpage = this.productService.findnum(keymap); + + int pageNo =1; + + int pageSize = 5; + + if( page > 0 ) + { + pageNo = page; + } + + + findlist = this.productService.find(keymap, pageNo, pageSize); + + //list.jspҳpage maxpage ظ» bug + + request.setAttribute("fpage", pageNo); + + request.setAttribute("fmaxpage", maxpage); + + + System.out.println( "С" + findlist.size() ); + + + + + + + return "success"; + } + + +} diff --git a/Shop/src/com/cn/shop/action/ListAction.java b/Shop/src/com/cn/shop/action/ListAction.java new file mode 100644 index 0000000..d2ec94d --- /dev/null +++ b/Shop/src/com/cn/shop/action/ListAction.java @@ -0,0 +1,213 @@ +package com.cn.shop.action; + +import java.util.List; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Cart; +import com.cn.shop.model.Product; +import com.cn.shop.service.ProductService; +import com.cn.shop.service.UserService; + +import com.opensymphony.xwork2.ActionSupport; + +public class ListAction extends ActionSupport { + + //Ʒservice IOC + private ProductService productService; + + //Ʒ + private List< Product > productlist; + + //ƷID + private Long productId; + + private UserService userService; + + private HttpServletRequest request; + + private HttpServletResponse response; + + private HttpSession session; + + private ServletContext application; + + //ʾͼƬ 2014.8.28 + + //ʱСͼƬС + +/* private String imageUrl; + + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } +*/ + //ӷҳ + + private int page; + + private int maxpage; + + // type list.jsp findlist.jspҳ 2014.8.31 + + /*ͨtype == 1 list.jsp findlist.jspҳ, type== 1,findlist.jspҳ*/ + + private int type; + + + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + // page maxpage request + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + + + public int getMaxpage() { + return maxpage; + } + + public void setMaxpage(int maxpage) { + this.maxpage = maxpage; + } + + public ProductService getProductService() { + return productService; + } + + public void setProductService(ProductService productService) { + this.productService = productService; + } + + public List getProductlist() { + return productlist; + } + + public void setProductlist(List productlist) { + this.productlist = productlist; + } + + + public Long getProductId() { + return productId; + } + + public void setProductId(Long productId) { + this.productId = productId; + } + + /*public String list( ) + { + productlist = this.productService.getALLProducts(); + + return"list"; + }*/ + + //ӷҳʾ2014.8.19 + + public String list( ) + { + this.request = ServletActionContext.getRequest(); + + int maxpage = this.productService.maxSize(); + + int pageNo =1; + + int pageSize = 5; + + if( page > 0 ) + { + pageNo = page; + } + + + productlist = this.productService.getByPage(pageNo , pageSize ); + + request.setAttribute("page", pageNo); + + request.setAttribute("maxpage", maxpage); + + return"list"; + } + + + + public String addItem( ) + { + String ret = "add"; + + System.out.println(productId); + + Product product = this.productService.getProduct(productId); + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + Cart cart = (Cart) this.session.getAttribute( Constants.SESSION_CART); + + if( cart == null ) + { + cart = new Cart( ); + + this.session.setAttribute(Constants.SESSION_CART, cart ); + } + + cart.addItem(product, 1); + + System.out.println( cart.getPrice() ); + + //System.out.println("type:" + type ); + + + if( type == 1 ) + { + ret ="find"; + + //20148.31 bug ȡtypeעָ + + type = 0; + } + + return ret; + } + //ʱСͼƬС + + /*public void showImage( ) + { + + + request = ServletActionContext.getRequest(); + + response = ServletActionContext.getResponse(); + + String url = imageUrl.substring(0, imageUrl.length() -3 ); + + com.cn.shop.util.ZipImage.zip(request, response, url ); + } + */ + +} diff --git a/Shop/src/com/cn/shop/action/LoginAction.java b/Shop/src/com/cn/shop/action/LoginAction.java new file mode 100644 index 0000000..ee56096 --- /dev/null +++ b/Shop/src/com/cn/shop/action/LoginAction.java @@ -0,0 +1,110 @@ +package com.cn.shop.action; + +import javax.annotation.Resource; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Administrator; +import com.cn.shop.model.User; +import com.cn.shop.service.UserService; +import com.opensymphony.xwork2.ActionSupport; + + +public class LoginAction extends ActionSupport { + + private String username; + + private String password; + + private UserService userService; + + private HttpServletRequest request; + + private HttpSession session; + + private ServletContext application; + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + + + + public UserService getUserService() { + return userService; + } + + + public void setUserService(UserService userService) { + this.userService = userService; + } + + @Override + public String execute() throws Exception { + // TODO Auto-generated method stub + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + + + + String ret=""; + + User user = this.userService.login(username, password); + + if( user == null ) + { + this.request.setAttribute("msg", "¼ʧ"); + + ret="restart"; + + } + else + { + this.session.setAttribute(Constants.SESSION_USER, user ); + + //жǷΪԱ̨ + + if( user instanceof Administrator ) + { + ret = "manager"; + } + else + { + + ret="user"; + } + } + + return ret; + + } + + + + + +} diff --git a/Shop/src/com/cn/shop/action/LoginOutAction.java b/Shop/src/com/cn/shop/action/LoginOutAction.java new file mode 100644 index 0000000..3e4da9c --- /dev/null +++ b/Shop/src/com/cn/shop/action/LoginOutAction.java @@ -0,0 +1,44 @@ +package com.cn.shop.action; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.User; +import com.opensymphony.xwork2.ActionSupport; + +public class LoginOutAction extends ActionSupport { + + private HttpServletRequest request; + + private HttpSession session; + + private ServletContext application; + + @Override + public String execute() throws Exception { + // TODO Auto-generated method stub + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + User user = (User) this.session.getAttribute(Constants.SESSION_USER); + + System.out.println( user.getName() ); + + this.session.removeAttribute(Constants.SESSION_USER ); + + return "out"; + + + + + } + + + +} diff --git a/Shop/src/com/cn/shop/action/ManagerAction.java b/Shop/src/com/cn/shop/action/ManagerAction.java new file mode 100644 index 0000000..ef875ad --- /dev/null +++ b/Shop/src/com/cn/shop/action/ManagerAction.java @@ -0,0 +1,81 @@ +package com.cn.shop.action; + +import java.util.List; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Order; +import com.cn.shop.service.OrderService; +import com.opensymphony.xwork2.ActionSupport; + +public class ManagerAction extends ActionSupport { + + private OrderService orderService; + + private List orders; + + private Long orderId; + + private String msg ; + + + public OrderService getOrderService() { + return orderService; + } + + public void setOrderService(OrderService orderService) { + this.orderService = orderService; + } + + + + public List getOrders() { + return orders; + } + + public void setOrders(List orders) { + this.orders = orders; + } + + + + public Long getOrderId() { + return orderId; + } + + public void setOrderId(Long orderId) { + this.orderId = orderId; + } + + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String index( ) + { + orders = orderService.getAllOrder(); + + for( Order o : orders ) + { + System.out.println( o.getCost() ); + } + + return "manager"; + + } + + public String next( ) + { + + orderService.nextOrderStatus(orderId); + + + + return "next"; + } + +} diff --git a/Shop/src/com/cn/shop/action/OrderAction.java b/Shop/src/com/cn/shop/action/OrderAction.java new file mode 100644 index 0000000..c3d4e94 --- /dev/null +++ b/Shop/src/com/cn/shop/action/OrderAction.java @@ -0,0 +1,86 @@ +package com.cn.shop.action; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Cart; +import com.cn.shop.model.Order; +import com.cn.shop.model.User; +import com.cn.shop.service.OrderService; +import com.opensymphony.xwork2.ActionSupport; + +//Action +public class OrderAction extends ActionSupport { + + private OrderService orderService; + + public OrderService getOrderService() { + return orderService; + } + + public void setOrderService(OrderService orderService) { + this.orderService = orderService; + } + + private HttpServletRequest request ; + + private HttpSession session ; + + + //ҳ + public String index( ) + { + String ret = ""; + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + User user = (User)this.session.getAttribute(Constants.SESSION_USER); + + if( user == null ) + { + ret ="login"; + } + else + { + ret ="order"; + } + + return ret; + } + + //ύ + public String postOrder( ) + { + + this.request = ServletActionContext.getRequest(); + + this.session = this.request.getSession(); + + User user = (User)this.session.getAttribute(Constants.SESSION_USER); + + Cart cart = ( Cart )this.session.getAttribute(Constants.SESSION_CART); + + Order order = new Order( ); + + order.setUser(user); + + order.setItems( cart.getItems() ); + + order.setStatus( Constants.ORDER_STATUS_POST ); + + //ҵ㣬¶ + + String orderNum = orderService.generateOrder(order); + + this.request.setAttribute(Constants.REQ_ORDER_NUMBER, orderNum ); + + + return "success"; + } + +} diff --git a/Shop/src/com/cn/shop/action/ProductAction.java b/Shop/src/com/cn/shop/action/ProductAction.java new file mode 100644 index 0000000..125d9ae --- /dev/null +++ b/Shop/src/com/cn/shop/action/ProductAction.java @@ -0,0 +1,249 @@ +package com.cn.shop.action; + +import java.io.File; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.dto.ProductDTO; +import com.cn.shop.dto.UserDTO; +import com.cn.shop.model.Product; +import com.cn.shop.model.User; +import com.cn.shop.service.ProductService; +import com.cn.shop.util.UpLoadUtil; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.ModelDriven; + + +/*̨ƷɾIJ2014.8.28*/ +public class ProductAction extends ActionSupport implements ModelDriven { + + //Ʒservice IOC + private ProductService productService; + + //bug ģʽ½ܲӳ implements ModelDriven + + private ProductDTO productDTO = new ProductDTO( ); + + private Product product ; + + //̨Ʒ 2014.8.29 + + //Ʒ + private List< Product > productlist; + + private HttpServletRequest request; + + private HttpServletResponse response; + + //ӷҳ + + private int page; + + private int maxpage; + + //޸Ʒ 2014.8.29 + + private Product updateproduct; + + private long productId; + + //ģʽ bug + + /*private String name; //Ʒ + + private Double price; //۸ + + private String description; //Ʒ + + private File file; //ͼƬ + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + }*/ + + /*ģʽbug*/ + + public Product getUpdateproduct() { + return updateproduct; + } + + public void setUpdateproduct(Product updateproduct) { + this.updateproduct = updateproduct; + } + + public long getProductId() { + return productId; + } + + public void setProductId(long productId) { + this.productId = productId; + } + + public List getProductlist() { + return productlist; + } + + public void setProductlist(List productlist) { + this.productlist = productlist; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public int getMaxpage() { + return maxpage; + } + + public void setMaxpage(int maxpage) { + this.maxpage = maxpage; + } + + public ProductService getProductService() { + return productService; + } + + public void setProductService(ProductService productService) { + this.productService = productService; + } + + public String addProduct( ) + { + + + product = new Product( ); + + String imagepath = UpLoadUtil.upload( productDTO.getFile()); + + product.setImageSrc(imagepath); + + product.setName(productDTO.getName()); + + product.setPrice( productDTO.getPrice() ); + + product.setDescription( productDTO.getDescription() ); + + productService.addProduct(product); + + return "success"; + + } + + + //Ʒ 2014.8.29 + public String productlist( ) + { + this.request = ServletActionContext.getRequest(); + + int maxpage = this.productService.maxSize(); + + int pageNo =1; + + int pageSize = 5; + + if( page > 0 ) + { + pageNo = page; + } + + + productlist = this.productService.getByPage(pageNo , pageSize ); + + request.setAttribute("page", pageNo); + + request.setAttribute("maxpage", maxpage); + + return"list"; + } + + //޸ + public String updateProduct( ) + { + + updateproduct = this.productService.getProduct(productId ); + + + return "update"; + } + + + // ޸Ʒ + + public String saveProduct( ) + { + + + String imagepath = UpLoadUtil.upload(productDTO.getFile() ); + + updateproduct.setImageSrc(imagepath); + + updateproduct.setName( productDTO.getName() ); + + updateproduct.setPrice( productDTO.getPrice() ); + + updateproduct.setDescription( productDTO.getDescription() ); + + this.productService.UpdateProduct(updateproduct); + + return "save"; + } + + //ɾƷ + + public String deleteProduct( ) + { + + this.productService.deleteProduct(productId); + + return "delete"; + + } + + + + + + @Override + public Object getModel() { + // TODO Auto-generated method stub + return productDTO; + } + + +} diff --git a/Shop/src/com/cn/shop/action/RegisterAction.java b/Shop/src/com/cn/shop/action/RegisterAction.java new file mode 100644 index 0000000..4d775e4 --- /dev/null +++ b/Shop/src/com/cn/shop/action/RegisterAction.java @@ -0,0 +1,215 @@ +package com.cn.shop.action; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; + +import com.cn.shop.common.Constants; +import com.cn.shop.dto.UserDTO; +import com.cn.shop.model.User; +import com.cn.shop.service.UserService; +import com.cn.shop.util.EmailAttachmentSender; +import com.cn.shop.util.ProductCode; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.ModelDriven; + +public class RegisterAction extends ActionSupport implements ModelDriven { + + private UserDTO userDTO = new UserDTO( ); + + private User user = new User( ); + + private UserService userService; + + //session + private Map session; + + + + //ʼע + + private EmailAttachmentSender emailSender = new EmailAttachmentSender( ); + + private String username; + + //̬֤ + + private HttpServletRequest request; + + private HttpServletResponse response; + + + + + //ûע + + + public String userRegister( ) + { + + session = (Map)ActionContext.getContext().getSession(); + + //޸bug ޸sessionòȶ + + /*String rand = ""; + + rand = (String) request.getSession().getAttribute("rand"); + + if( rand == null ) + { + rand =" "; + } + + System.out.println("֤"+ rand); + + + + + String ret = ""; + + int p1 = 0+ userDTO.getPassword1(); + + int p2 = 0+ userDTO.getPassword2(); + + if(( p1 != p2 ) || ( p1 == 0 ) ) + { + ret = "reset"; //½עҳ + } + //else if( (!userDTO.getRand().equals(rand ) ) || userDTO.getRand() == null ) + + + //bug + + else if( ( !rand.equals(userDTO.getRand() ) ) || userDTO.getRand() == null ) + { + ret = "reset"; //½עҳ + }*/ + + + //session һֱbug ע 2014.8.30 + + String rand = (String) request.getSession().getAttribute("rand"); + + System.out.println("֤"+ rand); + + + String ret = ""; + + if(( userDTO.getPassword1() != userDTO.getPassword2() ) ) + { + ret = "reset"; //½עҳ + } + //else if( (!userDTO.getRand().equals(rand ) ) || userDTO.getRand() == null ) + + //޸bug 2014.8.29 + else if( (!rand.equals(userDTO.getRand())) || userDTO.getRand() == null ) + { + ret = "reset"; //½עҳ + } + else if( ( !rand.equals(userDTO.getRand() ) ) || userDTO.getRand() == null ) + { + ret = "reset"; //½עҳ + } + + + else if( ( userDTO.getEmail() != null ) && ( userDTO.getName() !=null ) ) + { + + user.set(userDTO); + + session.put(user.getName(), user ); + + + + //ʼ + + emailSender.send(user.getEmail(), user.getName() ); + + ret ="verify"; //¼֤ + + + } + else + { + ret = "reset"; //½עҳ + } + + + return ret; + + + + + } + + public String usersave( ) + { + + session = (Map)ActionContext.getContext().getSession(); + + + User u = (User) session.get( username ); + + + + + System.out.println( username + u.getEmail() ); + + + + userService.add(u); + + return "save"; + + + + } + + public void code( ) + { + request = ServletActionContext.getRequest(); + + response = ServletActionContext.getResponse(); + + ProductCode.productCode(request, response); + + + } + + + @Override + public Object getModel() { + // TODO Auto-generated method stub + return userDTO; + } + + + + public UserService getUserService() { + return userService; + } + + public void setUserService(UserService userService) { + this.userService = userService; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + + + + + + +} diff --git a/Shop/src/com/cn/shop/common/Constants.java b/Shop/src/com/cn/shop/common/Constants.java new file mode 100644 index 0000000..e70a1a8 --- /dev/null +++ b/Shop/src/com/cn/shop/common/Constants.java @@ -0,0 +1,58 @@ +package com.cn.shop.common; + +public class Constants { + + //order status + public static final int ORDER_STATUS_POST = 1; //Ѿύ + public static final int ORDER_STATUS_SEND = 2; //ѷ + public static final int ORDER_STATUS_RECEIVE = 3; //ûѾջ + public static final int ORDER_STATUS_END = 4; // + + //session attribute name + public static final String SESSION_CART = "cart"; //Sessionû + public static final String SESSION_USER = "user"; //SessionĹﳵ + + //request attribute name + public static final String REQ_PRODUCTS = "products"; //Ʒ + public static final String REQ_ORDER_NUMBER = "orderNum";//Ķ + public static final String REQ_ORDERS = "orders"; //ж + + public static String OrderStatus( int status ) { + + String text = null; + + switch( status ) + { + + case Constants.ORDER_STATUS_POST: + + text="ύ"; + + break; + case Constants.ORDER_STATUS_SEND: + + text="ѷ"; + + break; + + case Constants.ORDER_STATUS_RECEIVE: + + text="ûջ"; + + break; + + case Constants.ORDER_STATUS_END: + + text=""; + + break; + default: + + break; + + } + + + return text; + } +} diff --git a/Shop/src/com/cn/shop/dao/BaseDAO.java b/Shop/src/com/cn/shop/dao/BaseDAO.java new file mode 100644 index 0000000..0bb5d1f --- /dev/null +++ b/Shop/src/com/cn/shop/dao/BaseDAO.java @@ -0,0 +1,46 @@ +package com.cn.shop.dao; + +import java.io.Serializable; +import java.util.List; + + +//DAOʵɾIJ + +public interface BaseDAO { + + //һʵ + public void saveEntity( T entity ); + + //ɾһʵ + + public void deleteEntity( T entity ); + + //ʵͺIDɾһʵ + public void deleteEntityById( Class entityClass , Serializable id ); + + //޸һʵ + + public void updateEntity( T entity ); + + //ѯijʵȫʵ + + public List getAllEntity( String entityName ); + + //ͨһʵ + + public T getEntityById( Class entityClass , Serializable id ); + + //2014.8.29Ʒҳ + + //ҳ + + public List getbyPage(String hql, int pageNo, int pageSize ,int real ); + + //ҳ + + public int realPage( String hql ); + + + + +} diff --git a/Shop/src/com/cn/shop/dao/BaseDAOImpl.java b/Shop/src/com/cn/shop/dao/BaseDAOImpl.java new file mode 100644 index 0000000..29f2484 --- /dev/null +++ b/Shop/src/com/cn/shop/dao/BaseDAOImpl.java @@ -0,0 +1,142 @@ +package com.cn.shop.dao; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.springframework.orm.hibernate3.HibernateTemplate; + +public class BaseDAOImpl implements BaseDAO { + + private HibernateTemplate hibernateTemplate; + + // һLogger־ + protected Logger logger = Logger.getLogger(this.getClass()); + + + + public HibernateTemplate getHibernateTemplate() { + return hibernateTemplate; + } + + public void setHibernateTemplate(HibernateTemplate hibernateTemplate) { + this.hibernateTemplate = hibernateTemplate; + } + + @Override + public void saveEntity(T entity) { + // TODO Auto-generated method stub + + this.hibernateTemplate.saveOrUpdate(entity); + + } + + @Override + public void deleteEntity(T entity) { + // TODO Auto-generated method stub + + this.hibernateTemplate.delete(entity); + + + } + + + + @Override + public void updateEntity(T entity) { + // TODO Auto-generated method stub + + this.hibernateTemplate.saveOrUpdate(entity); + + + + + } + + @Override + public List getAllEntity( String entityName) { + // TODO Auto-generated method stub + + return (List)this.hibernateTemplate.find("from" + " "+ entityName ); + + //return (List)this.hibernateTemplate.find("from Product"); + } + + @Override + public T getEntityById(Class entityClass, Serializable id) { + // TODO Auto-generated method stub + return (T) this.hibernateTemplate.get(entityClass, id); + } + + @Override + public void deleteEntityById(Class entityClass, Serializable id) { + // TODO Auto-generated method stub + + this.hibernateTemplate.delete( this.getEntityById(entityClass, id) ); + + } + + //2014.8.29 Ʒҳ + + @Override + public List getbyPage(String hql, int pageNo, int pageSize ,int real ) { + // TODO Auto-generated method stub + + List list = new ArrayList(); + + int begin = (pageNo-1 )*pageSize; + + int end = (pageNo )*pageSize; + + //ҳʾܴbug + + /*if( real < 5 ) + { + end =real; + } + else + { + if(real < end ) + { + //end = real -1; + + end = real; + } + + }*/ + + //bug ޸ʾbug + if( end > real ) + { + end = real; + } + + + + + + list = this.hibernateTemplate.find(hql).subList( begin , end ); + + return list; + + + } + + //ʵҳ + @Override + public int realPage(String hql) { + // TODO Auto-generated method stub + + int count = 0; + + + + count = this.hibernateTemplate.find(hql).size(); + + + + return count; + } + +} diff --git a/Shop/src/com/cn/shop/dao/UserDAO.java b/Shop/src/com/cn/shop/dao/UserDAO.java new file mode 100644 index 0000000..49f7e8a --- /dev/null +++ b/Shop/src/com/cn/shop/dao/UserDAO.java @@ -0,0 +1,13 @@ +package com.cn.shop.dao; + +import com.cn.shop.model.User; + +public interface UserDAO extends BaseDAO { + + // ¼֤ʧܷnull + public User loginCheck(String name, String password); + + public void save( User user ); + + +} diff --git a/Shop/src/com/cn/shop/dao/UserDAOImpl.java b/Shop/src/com/cn/shop/dao/UserDAOImpl.java new file mode 100644 index 0000000..08d4e2f --- /dev/null +++ b/Shop/src/com/cn/shop/dao/UserDAOImpl.java @@ -0,0 +1,47 @@ +package com.cn.shop.dao; + +import java.io.Serializable; +import java.util.List; + +import com.cn.shop.model.User; + +public class UserDAOImpl extends BaseDAOImpl implements UserDAO { + + @Override + public User loginCheck(String name, String password) { + // TODO Auto-generated method stub + + /*String hql = "from com.cn.shop.model.User u where u.name = ? and u.password = ? "; + + List list = this.getHibernateTemplate().find( hql, new String []{"throne212", "123" });*/ + + String hql = "from com.cn.shop.model.User u where u.name = "+"'"+name +"'" + " " + "and u.password =" + " " + "'"+password +"'"; + + List list = this.getHibernateTemplate().find( hql); + + if( list != null && list.size() >0 ) + { + super.logger.info("login check succ, user.name=" + list.get(0).getName()); + + return list.get(0); + } + else + { + + return null; + } + + + } + + @Override + public void save(User user) { + // TODO Auto-generated method stub + + super.saveEntity(user); + + } + + + +} diff --git a/Shop/src/com/cn/shop/dto/ProductDTO.java b/Shop/src/com/cn/shop/dto/ProductDTO.java new file mode 100644 index 0000000..9b7096c --- /dev/null +++ b/Shop/src/com/cn/shop/dto/ProductDTO.java @@ -0,0 +1,53 @@ +package com.cn.shop.dto; + +import java.io.File; + +public class ProductDTO { + + private String name; //Ʒ + + private Double price; //۸ + + private String description; //Ʒ + + private File file; //ͼƬ + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + + + + + + +} diff --git a/Shop/src/com/cn/shop/dto/UserDTO.java b/Shop/src/com/cn/shop/dto/UserDTO.java new file mode 100644 index 0000000..9b58190 --- /dev/null +++ b/Shop/src/com/cn/shop/dto/UserDTO.java @@ -0,0 +1,119 @@ +package com.cn.shop.dto; + + +/*ûݴ*/ + +public class UserDTO { + + + private String name; //û + + private int password1; // + + private int password2; //ȷ + + private String address; //ַ + + private String postCode; //ʱ + + private String email; //emailַ + + private String homePhone;// ͥ绰 + + private String cellPhone; //ֻ + + private String officePhone; //칫ҵ绰 + + + private String rand; + + + + public String getRand() { + return rand; + } + + public void setRand(String rand) { + this.rand = rand; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPassword1() { + return password1; + } + + public void setPassword1(int password1) { + this.password1 = password1; + } + + public int getPassword2() { + return password2; + } + + public void setPassword2(int password2) { + this.password2 = password2; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPostCode() { + return postCode; + } + + public void setPostCode(String postCode) { + this.postCode = postCode; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getHomePhone() { + return homePhone; + } + + public void setHomePhone(String homePhone) { + this.homePhone = homePhone; + } + + public String getCellPhone() { + return cellPhone; + } + + public void setCellPhone(String cellPhone) { + this.cellPhone = cellPhone; + } + + public String getOfficePhone() { + return officePhone; + } + + public void setOfficePhone(String officePhone) { + this.officePhone = officePhone; + } + + + + + + + + +} diff --git a/Shop/src/com/cn/shop/filter/ManagerFilter.java b/Shop/src/com/cn/shop/filter/ManagerFilter.java new file mode 100644 index 0000000..28b6abe --- /dev/null +++ b/Shop/src/com/cn/shop/filter/ManagerFilter.java @@ -0,0 +1,114 @@ +package com.cn.shop.filter; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import com.cn.shop.common.Constants; +import com.cn.shop.model.Administrator; +import com.cn.shop.model.User; + +public class ManagerFilter implements Filter { + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + // TODO Auto-generated method stub + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + // TODO Auto-generated method stub + HttpServletRequest req = (HttpServletRequest) request ; + HttpServletResponse res = (HttpServletResponse) response; + HttpSession session = req.getSession(); + + String contextPath = req.getContentType(); + + /*if( session.isNew() || session.getAttribute(Constants.SESSION_USER) == null ) + { + User user = (User)session.getAttribute(Constants.SESSION_USER); + + if( !( user instanceof Administrator )) + { + + + res.sendRedirect("http://localhost:8080/Shop/login.jsp"); + + System.out.println(contextPath+"/login.jsp" ); + + return; + } + }*/ + + if( session.isNew() || session.getAttribute(Constants.SESSION_USER) == null ) + { + + res.sendRedirect("http://localhost:8080/Shop/login.jsp"); + + System.out.println(contextPath+"/login.jsp" ); + + return; + + } + + + else if( session.getAttribute(Constants.SESSION_USER) != null) + { + + User user = (User)session.getAttribute(Constants.SESSION_USER); + + //System.out.println( ( user instanceof Administrator ) ); + + //if( ( user instanceof Administrator )) + + System.out.println( user.getName() ); + + //bug޸ һֱ˺̨ 2014818 + + //if( (user.equals("throne212"))) + + //bug޸ һֱ˺̨ 2014830, getName Ƚ + + //if( (user.getName().equals("throne212")) == false ) + + //2014.9.1 ޸bug Administrator, + + if ( ( user instanceof Administrator ) == false ) + { + + + res.sendRedirect("http://localhost:8080/Shop/login.jsp"); + + System.out.println(contextPath+"/login.jsp" ); + + return; + } + + } + + + + + chain.doFilter(request, response); + + + + } + + @Override + public void destroy() { + // TODO Auto-generated method stub + + } + +} diff --git a/Shop/src/com/cn/shop/model/Administrator.java b/Shop/src/com/cn/shop/model/Administrator.java new file mode 100644 index 0000000..be4cf7f --- /dev/null +++ b/Shop/src/com/cn/shop/model/Administrator.java @@ -0,0 +1,19 @@ +package com.cn.shop.model; + +//Աû + +public class Administrator extends User { + + private String workNo; // + + public String getWorkNo() { + return workNo; + } + + public void setWorkNo(String workNo) { + this.workNo = workNo; + } + + + +} diff --git a/Shop/src/com/cn/shop/model/Cart.java b/Shop/src/com/cn/shop/model/Cart.java new file mode 100644 index 0000000..9f5c801 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Cart.java @@ -0,0 +1,121 @@ +package com.cn.shop.model; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; + +//ﳵ +public class Cart { + + //һ־ + private Logger logger = Logger.getLogger(this.getClass()); + + //Ʒid Ŀ¼ + private Map< Long, Item > items = new HashMap( ); + + //Ʒﳵ + + public void addItem( Product product , int number ) + { + if( items.containsKey(product.getId())) + { + return; + } + Item item = new Item( number, product ); + + items.put(product.getId(), item ); + + } + + //޸Ʒ + public void modifyNumberBYProductId( long productId, int number ) + { + Item item = items.get(productId); + + item.setNumber(number); + + } + + //ɾƷĿ + + public void deleteItemByProductId( long productId ) + { + items.remove(productId); + + } + + //ɾƷĿ + + public void deleteItemByProductId( Long [] productIds ) + { + for( Long id : productIds ) + { + items.remove(id ); + } + } + + + //չﳵ + + public void clear( ) + { + items.clear(); + + logger.info("Cart cleared. size="+ items.size() ); + + } + + //Ŀ + + + public Map getCartItems( ) + { + return items; + + } + + //ùﳵĿĿ + + public int getItemNumber( ) + { + return items.size(); + } + + //жϹﳵǷΪ + public boolean isEmpty( ) + { + return items.isEmpty(); + + } + + //ﳵƷܼ + + public Double getPrice( ) + { + double sum = 0; + + for( Long id : items.keySet() ) + { + Item item = items.get(id); + + sum+=item.getCost(); + + } + + return sum; + } + + public Map getItems() { + return items; + } + + public void setItems(Map items) { + this.items = items; + } + + + + +} + diff --git a/Shop/src/com/cn/shop/model/Item.hbm.xml b/Shop/src/com/cn/shop/model/Item.hbm.xml new file mode 100644 index 0000000..843a860 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Item.hbm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/src/com/cn/shop/model/Item.java b/Shop/src/com/cn/shop/model/Item.java new file mode 100644 index 0000000..e9ca4d6 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Item.java @@ -0,0 +1,69 @@ +package com.cn.shop.model; + +public class Item { + + private Long id; // + + private Integer number; //Ʒ + + private Product product; //Ʒ + + private Double cost; //ܼ + + private Order order; // + + public Item() { + super(); + // TODO Auto-generated constructor stub + } + + //ͲƷ + public Item(Integer number, Product product) { + super(); + this.number = number; + this.product = product; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Double getCost() { + return ( product.getPrice() * number ); + } + + public void setCost(Double cost) { + this.cost = cost; + } + + public Order getOrder() { + return order; + } + + public void setOrder(Order order) { + this.order = order; + } + + + +} diff --git a/Shop/src/com/cn/shop/model/Order.hbm.xml b/Shop/src/com/cn/shop/model/Order.hbm.xml new file mode 100644 index 0000000..1e9a219 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Order.hbm.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/src/com/cn/shop/model/Order.java b/Shop/src/com/cn/shop/model/Order.java new file mode 100644 index 0000000..ba0f147 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Order.java @@ -0,0 +1,133 @@ +package com.cn.shop.model; + +import java.util.HashMap; +import java.util.Map; + + + + +import com.cn.shop.common.Constants; + + +public class Order { + + private Long id; // + + private String orderNum; // + + private Integer status; //״̬ + + private User user; //û + + private Double cost; //ܼ + + private Map items = new HashMap( ); //ĶƷidΪkey + + public Order() { + super(); + // TODO Auto-generated constructor stub + } + + //״ֵ̬ûĹ췽 + public Order( Integer status , User user ) + { + super( ); + + this.status = status; + + this.user = user; + + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getOrderNum() { + return orderNum; + } + + public void setOrderNum(String orderNum) { + this.orderNum = orderNum; + } + + + + public Integer getStatus( ) { + return status; + } + +/* public String getStatus( ) { + + String text = null; + switch (status) { + case Constants.ORDER_STATUS_POST: + text = "ύ"; + break; + case Constants.ORDER_STATUS_SEND: + text = "ѷ"; + break; + case Constants.ORDER_STATUS_RECEIVE: + text = "ûջ"; + break; + case Constants.ORDER_STATUS_END: + text = ""; + break; + default: + break; + } + return text; + + } + */ + + + public void setStatus(Integer status) { + this.status = status; + } + + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Double getCost() { + + double sum = 0; + + for( Long id : items.keySet() ) + { + Item item = items.get(id); + + sum += item.getCost(); + } + + this.cost = sum; + return cost; + } + + public void setCost(Double cost) { + this.cost = cost; + } + + public Map getItems() { + return items; + } + + public void setItems(Map items) { + this.items = items; + } + + + + + +} diff --git a/Shop/src/com/cn/shop/model/Product.hbm.xml b/Shop/src/com/cn/shop/model/Product.hbm.xml new file mode 100644 index 0000000..0e524c4 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Product.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/src/com/cn/shop/model/Product.java b/Shop/src/com/cn/shop/model/Product.java new file mode 100644 index 0000000..db1b595 --- /dev/null +++ b/Shop/src/com/cn/shop/model/Product.java @@ -0,0 +1,80 @@ +package com.cn.shop.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + + + +public class Product { + + private Long id; // + + private String name; //Ʒ + + private String description; //Ʒ + + private String imageSrc; //ͼƬַ + + private Double price; //۸ + + //޲ι캯 + public Product() { + super(); + // TODO Auto-generated constructor stub + } + + //Ʒ + public Product(String name) { + super(); + this.name = name; + } + + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getImageSrc() { + return imageSrc; + } + + public void setImageSrc(String imageSrc) { + this.imageSrc = imageSrc; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + + + + + +} diff --git a/Shop/src/com/cn/shop/model/User.hbm.xml b/Shop/src/com/cn/shop/model/User.hbm.xml new file mode 100644 index 0000000..ddf9a4a --- /dev/null +++ b/Shop/src/com/cn/shop/model/User.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shop/src/com/cn/shop/model/User.java b/Shop/src/com/cn/shop/model/User.java new file mode 100644 index 0000000..e5af261 --- /dev/null +++ b/Shop/src/com/cn/shop/model/User.java @@ -0,0 +1,151 @@ +package com.cn.shop.model; + +import com.cn.shop.dto.UserDTO; + + + +/*û*/ + +public class User { + + private Long id; // manager + + private String name; //û + + private int password; // + + private String address; //ַ + + private String postCode; //ʱ + + private String email; //emailַ + + private String homePhone;// ͥ绰 + + private String cellPhone; //ֻ + + private String officePhone; //칫ҵ绰 + + /* + * + * manager + * private String type; + + private String workNo;*/ + + + public User() { + super(); + // TODO Auto-generated constructor stub + } + + //ûĹ췽 + public User(String name, int password) { + super(); + this.name = name; + this.password = password; + } + + //Idɲ + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPassword() { + return password; + } + + public void setPassword(int password) { + this.password = password; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPostCode() { + return postCode; + } + + public void setPostCode(String postCode) { + this.postCode = postCode; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + + public String getHomePhone() { + return homePhone; + } + + public void setHomePhone(String homePhone) { + this.homePhone = homePhone; + } + + public String getCellPhone() { + return cellPhone; + } + + public void setCellPhone(String cellPhone) { + this.cellPhone = cellPhone; + } + + public String getOfficePhone() { + return officePhone; + } + + public void setOfficePhone(String officePhone) { + this.officePhone = officePhone; + } + + + + + + public void set( UserDTO userDTO ) + { + this.name = userDTO.getName(); + + this.password = userDTO.getPassword1(); + + this.address = userDTO.getAddress(); + + + this.postCode = userDTO.getPostCode(); + + this.email = userDTO.getEmail(); + + this.homePhone = userDTO.getHomePhone(); + + this.cellPhone = userDTO.getCellPhone(); + + this.officePhone = userDTO.getOfficePhone(); + } + + + +} diff --git a/Shop/src/com/cn/shop/service/OrderService.java b/Shop/src/com/cn/shop/service/OrderService.java new file mode 100644 index 0000000..a58b500 --- /dev/null +++ b/Shop/src/com/cn/shop/service/OrderService.java @@ -0,0 +1,28 @@ +package com.cn.shop.service; + +import java.util.List; + +import com.cn.shop.model.Order; + +public interface OrderService { + + //ɶ + + public String generateOrder( Order order ); + + //ж + + public List getAllOrder( ); + + //ͨIDö + + public Order getOrderById( long id ); + + //״̬תһ + + public void nextOrderStatus( long id ); + + + + +} diff --git a/Shop/src/com/cn/shop/service/OrderServiceImpl.java b/Shop/src/com/cn/shop/service/OrderServiceImpl.java new file mode 100644 index 0000000..b463328 --- /dev/null +++ b/Shop/src/com/cn/shop/service/OrderServiceImpl.java @@ -0,0 +1,69 @@ +package com.cn.shop.service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import com.cn.shop.common.Constants; +import com.cn.shop.dao.BaseDAO; +import com.cn.shop.model.Order; + +public class OrderServiceImpl implements OrderService { + + private BaseDAO baseDAO; + + private SimpleDateFormat timeFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + + + + public BaseDAO getBaseDAO() { + return baseDAO; + } + + public void setBaseDAO(BaseDAO baseDAO) { + this.baseDAO = baseDAO; + } + + @Override + public String generateOrder(Order order) { + // TODO Auto-generated method stub + if( order == null ) + { + return null; + } + + order.setOrderNum(timeFormat.format( new Date())); + + baseDAO.saveEntity(order); + + return order.getOrderNum(); + } + + @Override + public List getAllOrder() { + // TODO Auto-generated method stub + return baseDAO.getAllEntity("Order"); + } + + @Override + public Order getOrderById(long id) { + // TODO Auto-generated method stub + return baseDAO.getEntityById(Order.class, id); + } + + @Override + public void nextOrderStatus(long id) { + // TODO Auto-generated method stub + + Order order = baseDAO.getEntityById(Order.class, id); + + if( order.getStatus() != Constants.ORDER_STATUS_END ) + { + order.setStatus(order.getStatus()+1 ); + + baseDAO.updateEntity(order); + } + + } + +} diff --git a/Shop/src/com/cn/shop/service/ProductService.java b/Shop/src/com/cn/shop/service/ProductService.java new file mode 100644 index 0000000..68672c7 --- /dev/null +++ b/Shop/src/com/cn/shop/service/ProductService.java @@ -0,0 +1,43 @@ +package com.cn.shop.service; + +import java.util.List; +import java.util.Map; + +import com.cn.shop.model.Product; + +public interface ProductService { + + //ͨƷidƷ + public Product getProduct( long productId ); + + //еƷ + + public List getALLProducts( ); + + //2014.8.28 ƷɾIJ + + public void addProduct( Product product ); + + public void deleteProduct( long productId ); + + public void UpdateProduct( Product product ); + + //ҳʾ 2014.8.29 + + public List getByPage( int pageNo, int pageSize ); + + public int maxSize( ); + + //ģѯ + + public List find ( Mapkeymap, int pageNo, int pageSize ); + + + //ѯ + + public int findnum( Mapkeymap ); + + + + +} diff --git a/Shop/src/com/cn/shop/service/ProductServiceImpl.java b/Shop/src/com/cn/shop/service/ProductServiceImpl.java new file mode 100644 index 0000000..c382a90 --- /dev/null +++ b/Shop/src/com/cn/shop/service/ProductServiceImpl.java @@ -0,0 +1,173 @@ +package com.cn.shop.service; + +import java.util.List; +import java.util.Map; + +import com.cn.shop.dao.BaseDAO; +import com.cn.shop.model.Product; + +public class ProductServiceImpl implements ProductService { + + private BaseDAO baseDAO; + + + + public BaseDAO getBaseDAO() { + return baseDAO; + } + + public void setBaseDAO(BaseDAO baseDAO) { + this.baseDAO = baseDAO; + } + + @Override + public Product getProduct(long productId) { + // TODO Auto-generated method stub + return baseDAO.getEntityById(Product.class, productId ); + } + + @Override + public List getALLProducts() { + // TODO Auto-generated method stub + return baseDAO.getAllEntity("Product"); + } + + //2014.8.28 ƷɾIJ + @Override + public void addProduct(Product product) { + // TODO Auto-generated method stub + + this.baseDAO.saveEntity(product); + + + } + + @Override + public void deleteProduct(long productId) { + // TODO Auto-generated method stub + + this.baseDAO.deleteEntityById(Product.class, productId ); + + } + + @Override + public void UpdateProduct(Product product) { + // TODO Auto-generated method stub + + this.baseDAO.updateEntity(product); + + } + + //2014.8.29 ʵַҳ + @Override + public List getByPage(int pageNo, int pageSize) { + // TODO Auto-generated method stub + String hql = "from Product"; + + int real = baseDAO.realPage(hql); + + return baseDAO.getbyPage(hql, pageNo, pageSize ,real ); + + } + + @Override + public int maxSize() { + // TODO Auto-generated method stub + + String hql = "from Product"; + + int count = 0; + + int maxpage = 0; + + + count = baseDAO.realPage(hql); + + maxpage = ( count + 4 )/5; + + return maxpage; + } + + //2014.8.31 ʵģѯ + + @Override + public List find(Map keymap, int pageNo, + int pageSize) { + + + String hql = "from Product as p where "; + + + int num = 1; + + for( String key : keymap.keySet() ) + { + + if( num > 1 ) + { + hql+= " and p.name like '%" + keymap.get(key) + "%'"; + } + else + { + hql+=" p.name like '%" + keymap.get(key) + "%'"; + } + + num++; + + } + + + + int real = baseDAO.realPage(hql); + + return baseDAO.getbyPage(hql, pageNo, pageSize ,real ); + + + + } + + //ѯ 2014.8.31 + + @Override + public int findnum(Map keymap) { + // TODO Auto-generated method stub + + String hql = "from Product as p where "; + + + int num = 1; + + for( String key : keymap.keySet() ) + { + + if( num > 1 ) + { + hql+= " and p.name like '%" + keymap.get(key) + "%'"; + } + else + { + hql+=" p.name like '%" + keymap.get(key) + "%'"; + } + + num++; + + } + + int count = 0; + + int maxpage = 0; + + count = baseDAO.realPage(hql); + + + maxpage = ( count + 4 )/5; + + return maxpage; + } + + + + + + +} diff --git a/Shop/src/com/cn/shop/service/UserService.java b/Shop/src/com/cn/shop/service/UserService.java new file mode 100644 index 0000000..7775e90 --- /dev/null +++ b/Shop/src/com/cn/shop/service/UserService.java @@ -0,0 +1,13 @@ +package com.cn.shop.service; + +import com.cn.shop.model.User; + +public interface UserService { + + public User login( String name, String password ); + + public void add( User user ); + + + +} diff --git a/Shop/src/com/cn/shop/service/UserServiceImpl.java b/Shop/src/com/cn/shop/service/UserServiceImpl.java new file mode 100644 index 0000000..8e5e5af --- /dev/null +++ b/Shop/src/com/cn/shop/service/UserServiceImpl.java @@ -0,0 +1,41 @@ +package com.cn.shop.service; + +import com.cn.shop.dao.UserDAO; +import com.cn.shop.model.User; + +public class UserServiceImpl implements UserService { + + private UserDAO userDAO; + + + + public UserDAO getUserDAO() { + return userDAO; + } + + + + public void setUserDAO(UserDAO userDAO) { + this.userDAO = userDAO; + } + + + + @Override + public User login(String name, String password) { + // TODO Auto-generated method stub + return userDAO.loginCheck(name, password); + } + + + + @Override + public void add(User user) { + // TODO Auto-generated method stub + + this.userDAO.save(user); + + } + + +} diff --git a/Shop/src/com/cn/shop/util/EmailAttachmentSender.java b/Shop/src/com/cn/shop/util/EmailAttachmentSender.java new file mode 100644 index 0000000..3c9489b --- /dev/null +++ b/Shop/src/com/cn/shop/util/EmailAttachmentSender.java @@ -0,0 +1,118 @@ +package com.cn.shop.util; + +import java.io.IOException; +import java.util.Date; +import java.util.Properties; + +import javax.mail.Authenticator; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + +public class EmailAttachmentSender { + + public static void sendEmailWithAttachments(String host, String port, + final String userName, final String password, String toAddress, + String subject, String message, String[] attachFiles) + throws AddressException, MessagingException { + // sets SMTP server properties + Properties properties = new Properties(); + properties.put("mail.smtp.host", host); + properties.put("mail.smtp.port", port); + properties.put("mail.smtp.auth", "true"); + properties.put("mail.smtp.starttls.enable", "true"); + properties.put("mail.user", userName); + properties.put("mail.password", password); + + // creates a new session with an authenticator + Authenticator auth = new Authenticator() { + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(userName, password); + } + }; + Session session = Session.getInstance(properties, auth); + + // creates a new e-mail message + Message msg = new MimeMessage(session); + + msg.setFrom(new InternetAddress(userName)); + InternetAddress[] toAddresses = { new InternetAddress(toAddress) }; + msg.setRecipients(Message.RecipientType.TO, toAddresses); + msg.setSubject(subject); + msg.setSentDate(new Date()); + + // creates message part + MimeBodyPart messageBodyPart = new MimeBodyPart(); + messageBodyPart.setContent(message, "text/html;charset=UTF-8"); + + // creates multi-part + Multipart multipart = new MimeMultipart(); + multipart.addBodyPart(messageBodyPart); + + // adds attachments + if (attachFiles != null && attachFiles.length > 0) { + for (String filePath : attachFiles) { + MimeBodyPart attachPart = new MimeBodyPart(); + + try { + attachPart.attachFile(filePath); + } catch (IOException ex) { + ex.printStackTrace(); + } + + multipart.addBodyPart(attachPart); + } + } + + // sets the multi-part as e-mail's content + msg.setContent(multipart); + + // sends the e-mail + Transport.send(msg); + + } + + /** + * Էʼ + */ + public void send(String toMail , String username ) { + // Ϣ + String host = "smtp.126.com"; + String port = "25"; + String mailFrom = "nietaooldman@126.com"; + String password = "tao8419552"; + + // ռϢ + String mailTo = toMail; + String subject = "ע֤"; + + // String message = "һjavaMailԶIJʼظٶһ"; + + String message = "һ̳Զ֤ʼ뾡֤ȷע"; + + + // + // String[] attachFiles = new String[1]; + // attachFiles[0] = "D:/JavaWeb/javamail/java-mail-1.4.4.jar"; + + String[] attachFiles = null; + + try { + sendEmailWithAttachments(host, port, mailFrom, password, mailTo, + subject, message, attachFiles); + System.out.println("ʼͳɹ."); + } catch (Exception ex) { + System.out.println("ʧ"); + ex.printStackTrace(); + } + } + +} diff --git a/Shop/src/com/cn/shop/util/FenciUtil.java b/Shop/src/com/cn/shop/util/FenciUtil.java new file mode 100644 index 0000000..6334325 --- /dev/null +++ b/Shop/src/com/cn/shop/util/FenciUtil.java @@ -0,0 +1,40 @@ +package com.cn.shop.util; + +import java.io.IOException; +import java.io.StringReader; +import java.util.List; + +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +import org.wltea.analyzer.lucene.IKAnalyzer; + +public class FenciUtil { + + //ִַ ַ + public static void fenci( String text, List keylist ) throws IOException + { + + String keyword = null; + + //ִʶ + Analyzer anal=new IKAnalyzer(true); + StringReader reader=new StringReader(text); + //ִ + TokenStream ts=anal.tokenStream("", reader); + CharTermAttribute term=ts.getAttribute(CharTermAttribute.class); + //ִ + while(ts.incrementToken()){ + // System.out.print(term.toString()+"|"); + + keyword =""+ term.toString(); + + keylist.add(keyword); + + } + reader.close(); + + + + } +} diff --git a/Shop/src/com/cn/shop/util/ProductCode.java b/Shop/src/com/cn/shop/util/ProductCode.java new file mode 100644 index 0000000..115cfa3 --- /dev/null +++ b/Shop/src/com/cn/shop/util/ProductCode.java @@ -0,0 +1,138 @@ +package com.cn.shop.util; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Date; +import java.util.Random; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ProductCode { + + public static void productCode( HttpServletRequest request, HttpServletResponse response ) + { + //JPEGͼƬ + response.setContentType("image/jpeg"); + + //֤붼µģָ֤ͼƬл + + response.setHeader("Cache-Control", "no-cache,must-revalidate"); + + response.setHeader("Pragma", "no-cache"); + + response.setHeader("Last-Modified", new Date().toLocaleString()); + + response.setDateHeader("Expires", 0 ); + + int width = 60, height = 20; + + BufferedImage image = new BufferedImage( width, height , BufferedImage.TYPE_INT_RGB ); + + Graphics g = image.getGraphics(); + + g.setColor(new Color( 0xDCDCDC )); + + g.fillRect(0, 0, width, height); + + //߿ + + g.setColor(Color.black ); + + Random r = new Random( ); + + int rst = 0; + + while( ( rst = r.nextInt(10000) ) < 0 ) + { + + + } + + String rand = rst+""; + + switch( rand.length() ) + { + case 1: + + rand ="000"+rand; + + break; + + case 2: + + rand ="00"+rand; + + break; + case 3: + + rand ="0"+rand; + + break; + + default: + + rand = rand.substring(0,4); + + break; + + + } + + //session + + request.getSession().setAttribute("rand", rand ); + + //֤ʾͼ + + g.setColor(Color.black); + + g.setFont(new Font( "Atlantic Inline", Font.PLAIN, 18 )); + + g.drawString(rand.charAt(0)+"", 8 , 17 ); + + g.drawString(rand.charAt(1)+"", 20 , 15 ); + + g.drawString(rand.charAt(2)+"", 35 , 18 ); + + g.drawString(rand.charAt(3)+"", 45 , 15 ); + + Random random = new Random( ); + + for( int i = 0 ; i< 5; i++ ) + { + int x = random.nextInt(width); + + int y = random.nextInt(height ); + + g.drawOval(0, 0, x, y); + + } + + g.dispose(); //ͼƬЧ + + //ͼƬ + + try { + ImageIO.write(image, "JPEG", response.getOutputStream() ); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + + + + + + + } + + +} diff --git a/Shop/src/com/cn/shop/util/UpLoadUtil.java b/Shop/src/com/cn/shop/util/UpLoadUtil.java new file mode 100644 index 0000000..4eab015 --- /dev/null +++ b/Shop/src/com/cn/shop/util/UpLoadUtil.java @@ -0,0 +1,82 @@ +package com.cn.shop.util; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.List; + +import org.apache.struts2.ServletActionContext; + +public class UpLoadUtil { + + private static final int BUFFER_SIZE = 16 * 1024; + + private static void copy(File src, File dst) { + try { + InputStream in = null; + OutputStream out = null; + try { + in = new BufferedInputStream(new FileInputStream(src), + BUFFER_SIZE); + out = new BufferedOutputStream(new FileOutputStream(dst), + BUFFER_SIZE); + byte[] buffer = new byte[BUFFER_SIZE]; + while (in.read(buffer) > 0) { + out.write(buffer); + } + } finally { + if (null != in) { + in.close(); + } + if (null != out) { + out.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + + private static String getExtention(String fileName) { + int pos = fileName.lastIndexOf("."); + return fileName.substring(pos); + } + + + public static String upload( File src ) { + if (src == null) + return ""; + + String tempName = new Date().getTime() + getExtention( src.getName() ); + + + File imageFile = new File(ServletActionContext.getServletContext() //õͼƬλ(rootõͼƬ·tomcatµĸù) + + .getRealPath("UploadImages") + + "/" + tempName ); + + System.out.println(imageFile.getAbsolutePath() ); + + copy( src , imageFile); //ͼƬд뵽õ· + + //2014.9.2 ļ + + // return imageFile.getAbsolutePath() ; + + //޸ĿͻʾͼƬbug ʹԵַ ֱӷļ mysql洢ļ + + return tempName ; + + + } + + + + +} diff --git a/Shop/src/com/cn/shop/util/WordFilter.java b/Shop/src/com/cn/shop/util/WordFilter.java new file mode 100644 index 0000000..90ef414 --- /dev/null +++ b/Shop/src/com/cn/shop/util/WordFilter.java @@ -0,0 +1,161 @@ +package com.cn.shop.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class WordFilter { + + //2014.8.31 ļļŵmap + + public static void readType( Map flitermap ) + { + + InputStream in= WordFilter.class.getClassLoader().getSystemResourceAsStream("filter.dic"); + + String text = null; + + String key = null; + + String value = null; + + BufferedReader br = new BufferedReader( new InputStreamReader( in )); + + + //·Ǹbug + // File file = new File( "C:/Users/Administrator/Documents/javaweb/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Shop/WEB-INF/classes/filter.dic"); + + try { + + //BufferedReader br = new BufferedReader( new FileReader( file ) ); + + while( ( text = br.readLine()) != null ) + { + System.out.println( text ); + + key = text.substring(0, 2); + + System.out.println(key); + + value = text.substring(3); + + System.out.println( value ); + + flitermap.put(key, value); + + + + + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } + + //ضļ ȡweb/classes/Ŀ¼ļ + + public static void readType( Map flitermap , String url ) + { + + + + + + String text = null; + + String key = null; + + String value = null; + + + + + //·Ǹbug + File file = new File( url ); + + try { + + BufferedReader br = new BufferedReader( new FileReader( file ) ); + + while( ( text = br.readLine()) != null ) + { + System.out.println( text ); + + key = text.substring(0, 2); + + System.out.println(key); + + value = text.substring(3); + + System.out.println( value ); + + flitermap.put(key, value); + + + + + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } + + //ִļеĹؼֽƥ䣬ɹtrue + + public static boolean match( String type, String text ) + { + + + + String regex =".*"+"("+type+")"+".*"; + + Pattern pattern = Pattern.compile(regex); + + Matcher matcher = pattern.matcher(text); + + return matcher.matches() ; + + } + + //˷ִʣȡؼ֣ѹؼִkeymap + public static void filterword( String keyword , Map filtermap, Map keymap ) + { + //1ļƥ + + for( String key : filtermap.keySet() ) + { + + if( match( keyword, filtermap.get(key))) + { + + + //ƥɹkeymap + keymap.put(key, keyword); + + break; + + + + } + + } + + } + + +} diff --git a/Shop/src/com/cn/shop/util/ZipImage.java b/Shop/src/com/cn/shop/util/ZipImage.java new file mode 100644 index 0000000..a29ca47 --- /dev/null +++ b/Shop/src/com/cn/shop/util/ZipImage.java @@ -0,0 +1,50 @@ +package com.cn.shop.util; + +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ZipImage { + + public static void zip( HttpServletRequest request, HttpServletResponse response, String url ) + { + response.setContentType("image/jpeg"); + + String path = Thread.currentThread().getContextClassLoader().getResource("").getPath(); + + FileInputStream fin; + try { + fin = new FileInputStream( url ); + + Image src = ImageIO.read(fin); + + int h = 60; + + int w =60; + + BufferedImage tag = new BufferedImage( w, h, BufferedImage.TYPE_INT_RGB ); + + tag.getGraphics().drawImage(src, 0, 0, w, h, null ); + + ImageIO.write(tag, "JPEG", response.getOutputStream() ); + + + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} diff --git a/Shop/src/filter.dic b/Shop/src/filter.dic new file mode 100644 index 0000000..be5aedc --- /dev/null +++ b/Shop/src/filter.dic @@ -0,0 +1,5 @@ +ͣ·Ьñӿȹ˿ +ԱŮ +Ը +룺кС +ɫɫɫҺɫõɫƷɫϺɫɫɫۻɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫɫ diff --git a/Shop/src/hibernate.cfg.xml b/Shop/src/hibernate.cfg.xml new file mode 100644 index 0000000..ae77684 --- /dev/null +++ b/Shop/src/hibernate.cfg.xml @@ -0,0 +1,69 @@ + + + + + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost/shop + root + 123456 + + + 1 + + + org.hibernate.dialect.MySQLDialect + + + thread + + + org.hibernate.cache.NoCacheProvider + + + true + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Shop/src/log4j.properties b/Shop/src/log4j.properties new file mode 100644 index 0000000..961e887 --- /dev/null +++ b/Shop/src/log4j.properties @@ -0,0 +1,44 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +log4j.rootLogger=warn, stdout + + log4j.appender.hfile = org.apache.log4j.DailyRollingFileAppender + log4j.appender.hfile.File = D\://data//log_bias.log + log4j.appender.hfile.layout = org.apache.log4j.PatternLayout + log4j.appender.hfile.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + +#log4j.logger.org.hibernate=debug +#log4j.logger.org.hibernate=debug + +#log4j.logger.org.hibernate.ejb=debug +#log4j.logger.org.hibernate.ejb.packaging=debug +#log4j.logger.org.hibernate.reflection=debug + +#log4j.logger.org.hibernate.engine.Cascades=debug +#log4j.logger.org.hibernate.hql=debug + +### log just the SQL +#log4j.logger.org.hibernate.SQL=debug + +### log JDBC bind parameters ### +#log4j.logger.org.hibernate.type=info +#log4j.logger.org.hibernate.type=trace + +### log schema export/update ### +log4j.logger.org.hibernate.tool.hbm2ddl=debug + +### log HQL parse trees +#log4j.logger.org.hibernate.hql=debug + +### log cache activity ### +#log4j.logger.org.hibernate.cache=debug + +### log JDBC resource acquisition +#log4j.logger.org.hibernate.jdbc=debug + +### enable the following line if you want to track down connection ### +### leakages when using DriverManagerConnectionProvider ### +#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace diff --git a/Shop/src/stopword.dic b/Shop/src/stopword.dic new file mode 100644 index 0000000..c1b994b --- /dev/null +++ b/Shop/src/stopword.dic @@ -0,0 +1,33 @@ +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with \ No newline at end of file diff --git a/Shop/src/struts.xml b/Shop/src/struts.xml new file mode 100644 index 0000000..b563503 --- /dev/null +++ b/Shop/src/struts.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + /cart.jsp + + + /login.jsp + + + + + /manager/index.jsp + + + + + + + /login.jsp + + + + + + + + /list.jsp + + + + + + + + /reflushlist.jsp + + + + + /reflushfind.jsp + + + + + + + + + + + + + /cart.jsp + + + + + + + /cart.jsp + + + + + + /cart.jsp + + + + + + /cart.jsp + + + + + + + + /login.jsp + + + /order.jsp + + + + + + /success.jsp + + + + + + + /userregister.jsp + + + + /registerreminder.jsp + + + + + + + + /login.jsp + + + + + + + + + + + + + + + /findlist.jsp + + + + + + + + + + + + + + + + + /manager/manager.jsp + + + + + + /manager/flush.jsp + + + + + + + /manager/index.jsp + + + + + + + /manager/productlist.jsp + + + + + + + + /manager/updateproduct.jsp + + + + + + + /manager/reflush.jsp + + + + + + + + /manager/reflush.jsp + + + + + + + + + diff --git a/Shop/test/com/cn/test/Keyword.java b/Shop/test/com/cn/test/Keyword.java new file mode 100644 index 0000000..e52ee4f --- /dev/null +++ b/Shop/test/com/cn/test/Keyword.java @@ -0,0 +1,98 @@ +package com.cn.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; + +import com.cn.shop.util.FenciUtil; +import com.cn.shop.util.WordFilter; + + + +public class Keyword { + + @Test + + public void fenci( ) + { + String text = "Ըе·ÿЬӺɫñ"; + + + //ִ + List keylist = new ArrayList(); + + //ļfiltermap + + Map filtermap = new HashMap( ); + + + //ȡؼֵkeymap + + Map keymap = new HashMap( ); + + //ؼ + + String word = null; + + + + try { + + //1зִ + FenciUtil.fenci(text, keylist ); + + for( int i = 0 ; i < keylist.size() ; i++ ) + + { + System.out.println( keylist.get(i) ); + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + //2ļ + + WordFilter.readType(filtermap); + + for( String key : filtermap.keySet() ) + { + + System.out.println("key" + key + "value" + filtermap.get(key)); + } + + //3ȡؼ + + for( int i = 0 ; i < keylist.size(); i++ ) + { + //ȡؼ + word = keylist.get(i); + + //ȡؼ + + WordFilter.filterword(word, filtermap, keymap); + + + + } + + //鿴 keymap + + System.out.println("====================="); + + for( String key : keymap.keySet() ) + { + + System.out.println("key" + key + "value" + keymap.get(key)); + } + + + } + +} diff --git a/Shop/test/com/cn/test/OrderTest.java b/Shop/test/com/cn/test/OrderTest.java new file mode 100644 index 0000000..9e0cd52 --- /dev/null +++ b/Shop/test/com/cn/test/OrderTest.java @@ -0,0 +1,87 @@ +package com.cn.test; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import com.cn.shop.model.Order; +import com.cn.shop.model.User; +import com.cn.shop.service.OrderService; +import com.cn.shop.service.UserService; + +public class OrderTest { + + @Test + public void test() { + fail("Not yet implemented"); + } + + @Test + public void get( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + OrderService Service = (OrderService)ctx.getBean("orderServiceTarget"); + + Order order = Service.getOrderById( ( long )1 ); + + System.out.println( order.getStatus() ); + + Service.nextOrderStatus( (long)1); + + order = Service.getOrderById( ( long )1 ); + + System.out.println( order.getStatus() ); + + } + + @Test + public void list( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + OrderService Service = (OrderService)ctx.getBean("orderServiceTarget"); + + List orders = Service.getAllOrder(); + + for( Order o : orders ) + { + System.out.println( o.getStatus() ); + } + } + @Test + public void gen( ) + { + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + OrderService Service = (OrderService)ctx.getBean("orderServiceTarget"); + + + UserService userService = (UserService)ctx.getBean("userServiceTarget"); + + + + User u1 = userService.login("throne212", "123" ); + + Order order = new Order( ); + + order.setStatus(1); + + order.setUser(u1); + + + + + + + Service.generateOrder(order); + + + + + } + + +} diff --git a/Shop/test/com/cn/test/ProductTest.java b/Shop/test/com/cn/test/ProductTest.java new file mode 100644 index 0000000..1f6dfd0 --- /dev/null +++ b/Shop/test/com/cn/test/ProductTest.java @@ -0,0 +1,144 @@ +package com.cn.test; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + + + + + +import com.cn.shop.model.Product; +import com.cn.shop.service.ProductService; +import com.cn.shop.service.UserService; + +public class ProductTest { + + @Test + public void test() { + fail("Not yet implemented"); + } + + @Test + + public void get( ) + { + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + Product p1 = Service.getProduct((long) 3); + + System.out.println( p1.getName() ); + + List ps = Service.getALLProducts(); + + for( Product p : ps ) + { + System.out.println( p.getName() ); + } + + + + + } + + @Test + public void add( ) + { + Product p = new Product( ); + + p.setName("ˮ"); + + p.setPrice(100.2); + + p.setImageSrc("D:/java.text"); + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + Service.addProduct(p); + + + + + } + + @Test + public void delete( ) + { + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + Service.deleteProduct(Long.valueOf(5)); + + + } + + @Test + public void Update( ) + { + + Product p = new Product( ); + + p.setId(Long.valueOf(4)); + + p.setName("С"); + + p.setPrice(88.8); + + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + Service.UpdateProduct(p); + + } + + @Test + + public void maxpage( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + + + int max = Service.maxSize(); + + System.out.println( max ); + + + } + + @Test + + public void bypage( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + + ProductService Service = (ProductService)ctx.getBean("productServiceTarget"); + + + + List list = new ArrayList(); + + list = Service.getByPage(1, 5); + + System.out.println( list.size() ); + + } + + +} diff --git a/Shop/test/com/cn/test/Test1.java b/Shop/test/com/cn/test/Test1.java new file mode 100644 index 0000000..61c31d2 --- /dev/null +++ b/Shop/test/com/cn/test/Test1.java @@ -0,0 +1,320 @@ +package com.cn.test; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + + + + + + + + +import com.cn.shop.common.Constants; +import com.cn.shop.dao.BaseDAO; +import com.cn.shop.dao.UserDAO; +import com.cn.shop.dao.UserDAOImpl; +import com.cn.shop.model.Administrator; +import com.cn.shop.model.Item; +import com.cn.shop.model.Order; +import com.cn.shop.model.Product; +import com.cn.shop.model.User; + +public class Test1 { + + + private static SessionFactory sf ; + + + + @BeforeClass + + public static void beforeClass( ) + { + + //new SchemaExport( new AnnotationConfiguration().configure()).create(false, true); + + sf = new AnnotationConfiguration().configure().buildSessionFactory(); + + } + + + @AfterClass + + public static void afterClass( ) + { + sf.close(); + + } + + @Test + + public void testSchemaExport( ) + { + new SchemaExport( new AnnotationConfiguration().configure()).create(false, true); + } + + @Test + public void test() { + fail("Not yet implemented"); + } + + + + @Test + public void SaveUser( ) + { + Session session = sf.getCurrentSession(); + + session.beginTransaction(); + + Integer s= new Integer(2); + + Long id = Long.parseLong(s.toString()); + + User user = ( User )session.get(User.class, id ); + + Product product = ( Product )session.get(Product.class , id ); + + System.out.println( user.getName() ); + + Item item = new Item( 2, product ); + + + + Order order =new Order ( 1 , user); + + order.setOrderNum("12211"); + + + + item.setOrder(order); + + order.getItems().put(item.getProduct().getId(), item ); + + + + session.save(item); + + + session.save(order); + + + + session.getTransaction().commit(); + + + + //System.out.println(order.getUser() ); + + for( Long id1 : order.getItems().keySet() ) + { + System.out.println( order.getItems().get(id1).getProduct().getName() ); + + } + + System.out.println( Constants.OrderStatus( order.getStatus() )); + + } + + @Test + + public void save( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + BaseDAO baseDAO = (BaseDAO)ctx.getBean("baseDAO"); + + /*Administrator u2 = baseDAO.getEntityById(Administrator.class, (long)2 ); + + System.out.println( u2.getName() ); + + + Order o1 = new Order( ); + + + + Item t1 = new Item( ); + + Product p1 = new Product( ); + + p1.setName("122"); + + p1.setPrice(12.6); + + t1.setProduct(p1); + + t1.setNumber(2); + + Mapitems = new HashMap( ); + + + + + t1.setOrder(o1); + + items.put(p1.getId(), t1 ); + + o1.setItems(items); + + o1.setOrderNum("444111"); + + o1.setStatus(1); + + o1.setUser(u2); + + + + + + + baseDAO.saveEntity(p1); + + baseDAO.saveEntity(t1); + + + + baseDAO.saveEntity(o1); + + */ + + + + User user = baseDAO.getEntityById(User.class, (long)1); + Product p1 = baseDAO.getEntityById(Product.class, (long)1); + Product p2 = baseDAO.getEntityById(Product.class, (long)2); + + Item item1 = new Item(); + item1.setProduct(p1); + item1.setNumber(2); + item1.setCost(item1.getNumber() * p1.getPrice()); + + Item item2 = new Item(); + item2.setProduct(p2); + item2.setNumber(1); + item2.setCost(item2.getNumber() * p2.getPrice()); + + Map items = new HashMap(); + items.put(p1.getId(), item1); + items.put(p2.getId(), item2); + + Order order = new Order(Constants.ORDER_STATUS_POST,user); + item1.setOrder(order); + item2.setOrder(order); + order.setItems(items); + + order.setOrderNum("89"); + + baseDAO.saveEntity(order); + + + + + } + + @Test + public void list( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + BaseDAO baseDAO = (BaseDAO)ctx.getBean("baseDAO"); + + + List orders = baseDAO.getAllEntity( "Order" ); + + for( Order o : orders ) + { + System.out.println( o.getStatus() ); + } + + } + + @Test + + public void test1( ) + { + + System.out.print(); + + } + + @Test + + public void query( ) + { + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + BaseDAO baseDAO = (BaseDAO)ctx.getBean("baseDAO"); + + /* Product p1 = baseDAO.getEntityById(Product.class, (long)1); + + System.out.println(p1.getName()); + + + + baseDAO.deleteEntity(p1);*/ + + /* baseDAO.deleteEntityById(Product.class, (long)2); + */ + + Product p1 = baseDAO.getEntityById(Product.class, (long)3); + + System.out.println( p1.getName() ); + + p1.setName("111"); + + baseDAO.updateEntity(p1); + + + + + } + + @Test + public void user( ) + { + + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + UserDAO userDAO = (UserDAO)ctx.getBean("userDAO"); + + User user = userDAO.getEntityById(User.class, (long)1 ); + + String name = user.getName(); + + String password = String.valueOf(user.getPassword() ); + + System.out.println(name); + + System.out.println( password); + + User u1 = userDAO.loginCheck("throne212", "123" ); + + System.out.println( u1); + + } + + @Test + public void test2( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + UserDAOImpl userDAO = (UserDAOImpl)ctx.getBean("userDAO"); + + String hql = "from com.cn.shop.model.User u where u.name = ? and u.password = ? "; + + List list = userDAO.getHibernateTemplate().find( hql, new String []{"throne212", "123" }); + + System.out.println( list.size() ); + } + +} diff --git a/Shop/test/com/cn/test/UserTest.java b/Shop/test/com/cn/test/UserTest.java new file mode 100644 index 0000000..a676c32 --- /dev/null +++ b/Shop/test/com/cn/test/UserTest.java @@ -0,0 +1,33 @@ +package com.cn.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import com.cn.shop.dao.UserDAO; +import com.cn.shop.model.User; +import com.cn.shop.service.UserService; + +public class UserTest { + + @Test + public void test() { + fail("Not yet implemented"); + } + @Test + public void login( ) + { + ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + UserService userService = (UserService)ctx.getBean("userServiceTarget"); + + + + User u1 = userService.login("throne212", "123" ); + + System.out.println( u1.getName() ); + + } + +} diff --git a/shop.txt b/shop.txt new file mode 100644 index 0000000..bda66fa --- /dev/null +++ b/shop.txt @@ -0,0 +1,28 @@ + ԱB2C̳Ŀ + +һĿܣ + ĿʹSSHܺMySQLݿ⡣ʵSpringHibernateStrutsϡĿǰʵֹܣ1ǰ̨ܣûעᡢƷչʾﳵ(Ʒӡɾ޸ġ鿴)ύ2̨ܣƷɾIJͶ3Ʒݽзִʣȡؼ֣ģѯ4QQѯܡĿʵB2CվĹܡ +Ŀ + ĿʹEclipse_EE + Tomcat7.0+ MySql5.6Ŀ +1װ Eclipse_EETomcatMySql +2MySqlݿдshopݿ⡣ +(1)CREATE DATABASE shop + CHARACTER SET utf8 + DEFAULT CHARACTER SET utf8 + COLLATE utf8_general_ci + DEFAULT COLLATE utf8_general_ci ; +(2Ŀsql/shop.sql,ִshop.sqlSQL䴴ֱĬϹԱû +ĬͨûԱûadmin,룺123.ͨûûthrone212, +123. +3վԴ뵼EclipseУվͿС ../Shop/manager/index.jspΪ̨档 +վ + + ǵӿƴоóվ̨̨ܻƣǰ̨ҳչʾ򵥣ȤͿԲ־Ƴҵ棬ϵ + + 䣺nietaooldman@126.com + + qqȺ330242176 + +ġκ + + ҷʼnietaooldman@126.com diff --git a/shopweb b/shopweb new file mode 160000 index 0000000..675c6b9 --- /dev/null +++ b/shopweb @@ -0,0 +1 @@ +Subproject commit 675c6b9851993e29736044e8b805794204ee9b26