Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7e04226
Showing
86 changed files
with
15,847 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Shopping | ||
## 简单介绍 | ||
本项目使用Spring+SpringMVC+Hibernate来实现了一个网上商城系统。 | ||
## 运行 | ||
```shell | ||
# 1.执行下面命令将代码下载到本地(需安装git客户端,如果没有安装则在此页面选择Download as zip 方式下载到本地) | ||
git clone https://github.com/IcedSoul/Shopping.git | ||
|
||
# 2.在本地或者远程MySQL数据库中执行Shopping/src/main/resources/properties/路径下的Shooping SQL语句以创建数据库。(需本机安装MySQL,版本建议在5.7或以下,高版本连接会出问题。执行SQL语句可使用命令行或者Navicat等工具。) | ||
|
||
# 3.打开Shopping/src/main/resources/properties/路径下的database.properties配置文件,把数据库连接地址,用户名和密码改成自己的 | ||
|
||
# 4.执行以下maven命令(需本地安装Maven) | ||
mvn clean | ||
mvn package | ||
|
||
# 5.在生成的target目录下即可找到对应的Shopping.war包 | ||
|
||
# 6.将war包复制到Tomcat目录下的webapps文件夹下,重启Tomcat服务器(需要下载Tomcat,建议版本在7.0以上) | ||
|
||
# 7.访问 http://localhost:8080/Shopping 来查看效果。(没有任何商品,需要自己手动去添加。注册普通用户,然后在数据库中将用户role字段改为1即可访问控制台页面,进行商品的增加和删除。) | ||
``` | ||
## 主要技术 | ||
JavaEE框架:Spring+SpringMVC+Hibernate<br/> | ||
前端框架:Bootstrap<br/> | ||
插件:Layer.js,ajaxfileupload.js<br/> | ||
数据库:MySQL<br/> | ||
## 主要功能 | ||
1. 普通用户 | ||
* 登录、注册功能 | ||
* 浏览商品功能 | ||
* 搜索商品功能 | ||
* 查看商品详情 | ||
* 添加购物车 | ||
* 购买功能(在商品详情页单独购买或在购物车批量购买) | ||
* 查看订单状态 | ||
* 确认收货功能 | ||
* 评价已购买商品功能 | ||
2. 管理员: | ||
* 拥有普通用户所有功能 | ||
* 查看、删除所有用户功能 | ||
* 查看、删除所有商品功能 | ||
* 添加新的商品功能 | ||
* 处理订单功能 | ||
* 发货功能 | ||
## 运行截图 | ||
|
||
![主页](http://ou7jocypf.bkt.clouddn.com/18-1-7/34246424.jpg) | ||
![商品详情页](http://ou7jocypf.bkt.clouddn.com/18-1-19/72836398.jpg) | ||
![购物车](http://ou7jocypf.bkt.clouddn.com/18-1-19/17885375.jpg) | ||
![订单状态](http://ou7jocypf.bkt.clouddn.com/18-1-7/2705633.jpg) | ||
![订单处理](http://ou7jocypf.bkt.clouddn.com/18-1-7/59511728.jpg) | ||
![控制台1](http://ou7jocypf.bkt.clouddn.com/18-1-7/54419726.jpg) | ||
![控制台2](http://ou7jocypf.bkt.clouddn.com/18-1-7/98806938.jpg) | ||
|
||
## 演示地址 | ||
演示网址:http://120.79.92.126/Shopping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.shopping</groupId> | ||
<artifactId>shopping</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>Shopping</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!--JavaEE 7.0--> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>7.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- 这个必须要加,不然连jsp页面都打不开 jsp页面第一行引入了这个--> | ||
<dependency> | ||
<groupId>org.glassfish.web</groupId> | ||
<artifactId>javax.servlet.jsp.jstl</artifactId> | ||
<version>1.2.2</version> | ||
</dependency> | ||
|
||
<!--MySQL 5.1.38 换数据库需要替换为与你数据库对应的依赖--> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.38</version> | ||
</dependency> | ||
|
||
<!--SpringMVC 4.3.5.RELEASE --> | ||
<!--配置第一个之后会自动导入一些spring mvc相关的依赖包,但是有可能我们需要包的没有被自动导入 | ||
因此,之后的第二个及以后是根据项目需要添加需要导入的spring mvc相关的包--> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webmvc</artifactId> | ||
<version>4.3.5.RELEASE</version> | ||
</dependency> | ||
|
||
<!--这个包不会随spring-webmvc导入,这个包作用是管理Hibernate资源--> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-orm</artifactId> | ||
<version>4.3.5.RELEASE</version> | ||
</dependency> | ||
|
||
<!--这个也不会随spring-webmvc导入,作用是为spring-aop提供支持--> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-aspects</artifactId> | ||
<version>4.3.5.RELEASE</version> | ||
</dependency> | ||
|
||
<!--Apache Commons dbcp 2.1.1 Apache提供的一些组件,dbcp配置数据源时需要使用--> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-dbcp2</artifactId> | ||
<version>2.1.1</version> | ||
</dependency> | ||
|
||
<!--支持SpringMVC文件上传功能--> | ||
<dependency> | ||
<groupId>commons-fileupload</groupId> | ||
<artifactId>commons-fileupload</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
|
||
|
||
<!--Hibernate 4.3.8.Final--> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>4.3.8.Final</version> | ||
</dependency> | ||
|
||
<!-- FastJson 1.2.24 --> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.24</version> | ||
</dependency> | ||
|
||
<!-- jackson-core Spring MVC配置RequestMappingHandlerAdapter时用到了--> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.9.7</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.9.6</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<finalName>Shopping</finalName> | ||
<plugins> | ||
<!--这个插件作用是指定编译这个项目的Java版本和Project Language Level ,针对Intellij IDEA--> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/shopping/controller/EvaluationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.shopping.controller; | ||
|
||
import com.alibaba.fastjson.JSONArray; | ||
import com.shopping.entity.Evaluation; | ||
import com.shopping.service.EvaluationService; | ||
import com.shopping.service.ShoppingRecordService; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.annotation.Resource; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by 14437 on 2017/3/7. | ||
*/ | ||
@Controller | ||
public class EvaluationController { | ||
@Resource | ||
private EvaluationService evaluationService; | ||
|
||
@Resource | ||
private ShoppingRecordService shoppingRecordService; | ||
|
||
@RequestMapping(value = "/addShoppingEvaluation",method = RequestMethod.POST) | ||
@ResponseBody | ||
public Map<String,Object> addShoppingEvaluation(int userId, int productId, String content){ | ||
System.out.println("我添加了"+userId+" "+productId); | ||
String result = null; | ||
if(shoppingRecordService.getUserProductRecord(userId,productId)){ | ||
Evaluation evaluation = new Evaluation(); | ||
evaluation.setUserId(userId); | ||
evaluation.setProductId(productId); | ||
Date date = new Date(); | ||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); | ||
evaluation.setTime(sf.format(date)); | ||
evaluation.setContent(content); | ||
evaluationService.addEvaluation(evaluation); | ||
result = "success"; | ||
} | ||
else{ | ||
result="noneRecord"; | ||
} | ||
|
||
Map<String,Object> resultMap = new HashMap<String,Object>(); | ||
resultMap.put("result",result); | ||
return resultMap; | ||
} | ||
|
||
@RequestMapping(value = "/getShoppingEvaluations",method = RequestMethod.POST) | ||
@ResponseBody | ||
public Map<String,Object> getShoppingEvaluations(int productId){ | ||
List<Evaluation> evaluationList = evaluationService.getProductEvaluation(productId); | ||
String evaluations = JSONArray.toJSONString(evaluationList); | ||
Map<String,Object> resultMap = new HashMap<String,Object>(); | ||
resultMap.put("result",evaluations); | ||
return resultMap; | ||
} | ||
} |
Oops, something went wrong.