Skip to content

Commit 6a62d0c

Browse files
committed
Maven+ssm进行秒杀系统的开发
1 parent 0ded638 commit 6a62d0c

File tree

114 files changed

+3436
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3436
-2
lines changed

README.md

+808-2
Large diffs are not rendered by default.

pom.xml

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>cn.codingxiaxw.seckill</groupId>
5+
<artifactId>seckill</artifactId>
6+
<packaging>war</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>seckill Maven Webapp</name>
9+
<url>http://maven.apache.org</url>
10+
<dependencies>
11+
<dependency>
12+
<!--3.0的junit是使用编程的方式来进行测试,而junit4是使用注解的方式来运行junit-->
13+
<groupId>junit</groupId>
14+
<artifactId>junit</artifactId>
15+
<version>4.11</version>
16+
<scope>test</scope>
17+
</dependency>
18+
19+
20+
<!--补全项目依赖-->
21+
<!--1.日志 java日志有:slf4j,log4j,logback,common-logging
22+
slf4j:是规范/接口
23+
日志实现:log4j,logback,common-logging
24+
使用:slf4j+logback
25+
-->
26+
<dependency>
27+
<groupId>org.slf4j</groupId>
28+
<artifactId>slf4j-api</artifactId>
29+
<version>1.7.12</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>ch.qos.logback</groupId>
33+
<artifactId>logback-core</artifactId>
34+
<version>1.1.1</version>
35+
</dependency>
36+
<!--实现slf4j接口并整合-->
37+
<dependency>
38+
<groupId>ch.qos.logback</groupId>
39+
<artifactId>logback-classic</artifactId>
40+
<version>1.1.1</version>
41+
</dependency>
42+
43+
44+
<!--1.数据库相关依赖-->
45+
<dependency>
46+
<groupId>mysql</groupId>
47+
<artifactId>mysql-connector-java</artifactId>
48+
<version>5.1.35</version>
49+
<scope>runtime</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>c3p0</groupId>
53+
<artifactId>c3p0</artifactId>
54+
<version>0.9.1.1</version>
55+
</dependency>
56+
57+
<!--2.dao框架:MyBatis依赖-->
58+
<dependency>
59+
<groupId>org.mybatis</groupId>
60+
<artifactId>mybatis</artifactId>
61+
<version>3.3.0</version>
62+
</dependency>
63+
<!--mybatis自身实现的spring整合依赖-->
64+
<dependency>
65+
<groupId>org.mybatis</groupId>
66+
<artifactId>mybatis-spring</artifactId>
67+
<version>1.2.3</version>
68+
</dependency>
69+
70+
<!--3.Servlet web相关依赖-->
71+
<dependency>
72+
<groupId>taglibs</groupId>
73+
<artifactId>standard</artifactId>
74+
<version>1.1.2</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>jstl</groupId>
78+
<artifactId>jstl</artifactId>
79+
<version>1.2</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>com.fasterxml.jackson.core</groupId>
83+
<artifactId>jackson-databind</artifactId>
84+
<version>2.5.4</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>javax.servlet</groupId>
88+
<artifactId>javax.servlet-api</artifactId>
89+
<version>3.1.0</version>
90+
</dependency>
91+
92+
<!--4:spring依赖-->
93+
<!--1)spring核心依赖-->
94+
<dependency>
95+
<groupId>org.springframework</groupId>
96+
<artifactId>spring-core</artifactId>
97+
<version>4.1.7.RELEASE</version>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.springframework</groupId>
101+
<artifactId>spring-beans</artifactId>
102+
<version>4.1.7.RELEASE</version>
103+
</dependency>
104+
<dependency>
105+
<groupId>org.springframework</groupId>
106+
<artifactId>spring-context</artifactId>
107+
<version>4.1.7.RELEASE</version>
108+
</dependency>
109+
<!--2)spring dao层依赖-->
110+
<dependency>
111+
<groupId>org.springframework</groupId>
112+
<artifactId>spring-jdbc</artifactId>
113+
<version>4.1.7.RELEASE</version>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.springframework</groupId>
117+
<artifactId>spring-tx</artifactId>
118+
<version>4.1.7.RELEASE</version>
119+
</dependency>
120+
<!--3)springweb相关依赖-->
121+
<dependency>
122+
<groupId>org.springframework</groupId>
123+
<artifactId>spring-web</artifactId>
124+
<version>4.1.7.RELEASE</version>
125+
</dependency>
126+
<dependency>
127+
<groupId>org.springframework</groupId>
128+
<artifactId>spring-webmvc</artifactId>
129+
<version>4.1.7.RELEASE</version>
130+
</dependency>
131+
<!--4)spring test相关依赖-->
132+
<dependency>
133+
<groupId>org.springframework</groupId>
134+
<artifactId>spring-test</artifactId>
135+
<version>4.1.7.RELEASE</version>
136+
</dependency>
137+
138+
</dependencies>
139+
140+
<build>
141+
<finalName>seckill</finalName>
142+
</build>
143+
</project>

seckill.iml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="web" name="Web">
5+
<configuration>
6+
<descriptors>
7+
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
8+
</descriptors>
9+
<webroots>
10+
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
11+
</webroots>
12+
<sourceRoots>
13+
<root url="file://$MODULE_DIR$/src/main/java" />
14+
<root url="file://$MODULE_DIR$/src/main/resources" />
15+
</sourceRoots>
16+
</configuration>
17+
</facet>
18+
</component>
19+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
20+
<output url="file://$MODULE_DIR$/target/classes" />
21+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
22+
<content url="file://$MODULE_DIR$">
23+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
24+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
25+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
26+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
27+
<excludeFolder url="file://$MODULE_DIR$/target" />
28+
</content>
29+
<orderEntry type="inheritedJdk" />
30+
<orderEntry type="sourceFolder" forTests="false" />
31+
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
32+
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
33+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
34+
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.1" level="project" />
35+
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.1" level="project" />
36+
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:5.1.35" level="project" />
37+
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
38+
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.3.0" level="project" />
39+
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.2.3" level="project" />
40+
<orderEntry type="library" name="Maven: taglibs:standard:1.1.2" level="project" />
41+
<orderEntry type="library" name="Maven: jstl:jstl:1.2" level="project" />
42+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.4" level="project" />
43+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.0" level="project" />
44+
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.4" level="project" />
45+
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
46+
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.1.7.RELEASE" level="project" />
47+
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
48+
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.1.7.RELEASE" level="project" />
49+
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.1.7.RELEASE" level="project" />
50+
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.7.RELEASE" level="project" />
51+
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
52+
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.1.7.RELEASE" level="project" />
53+
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.1.7.RELEASE" level="project" />
54+
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.1.7.RELEASE" level="project" />
55+
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.1.7.RELEASE" level="project" />
56+
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.1.7.RELEASE" level="project" />
57+
<orderEntry type="library" name="Maven: org.springframework:spring-test:4.1.7.RELEASE" level="project" />
58+
</component>
59+
</module>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cn.codingxiaxw.dao;
2+
3+
import cn.codingxiaxw.entity.Seckill;
4+
import org.apache.ibatis.annotations.Param;
5+
import org.springframework.web.bind.annotation.PathVariable;
6+
7+
import java.util.Date;
8+
import java.util.List;
9+
10+
/**
11+
* Created by codingBoy on 16/11/26.
12+
*/
13+
public interface SeckillDao
14+
{
15+
16+
/**
17+
* 减库存
18+
* @param seckillId
19+
* @param killTime
20+
* @return 如果影响行数>1,表示更新库存的记录行数
21+
*/
22+
int reduceNumber(@Param("seckillId") long seckillId, @Param("killTime") Date killTime);
23+
24+
/**
25+
* 根据id查询秒杀的商品信息
26+
* @param seckillId
27+
* @return
28+
*/
29+
Seckill queryById(long seckillId);
30+
31+
/**
32+
* 根据偏移量查询秒杀商品列表
33+
* @param offset
34+
* @param limit
35+
* @return
36+
*/
37+
List<Seckill> queryAll(@Param("offset") int offset,@Param("limit") int limit);
38+
39+
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cn.codingxiaxw.dao;
2+
3+
import cn.codingxiaxw.entity.SuccessKilled;
4+
import org.apache.ibatis.annotations.Param;
5+
6+
/**
7+
* Created by codingBoy on 16/11/27.
8+
*/
9+
public interface SuccessKilledDao {
10+
11+
/**
12+
* 插入购买明细,可过滤重复
13+
* @param seckillId
14+
* @param userPhone
15+
* @return插入的行数
16+
*/
17+
int insertSuccessKilled(@Param("seckillId") long seckillId, @Param("userPhone") long userPhone);
18+
19+
20+
/**
21+
* 根据秒杀商品的id查询明细SuccessKilled对象(该对象携带了Seckill秒杀产品对象)
22+
* @param seckillId
23+
* @return
24+
*/
25+
SuccessKilled queryByIdWithSeckill(@Param("seckillId") long seckillId,@Param("userPhone") long userPhone);
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package cn.codingxiaxw.dto;
2+
3+
import java.util.Date;
4+
5+
/**
6+
* Created by codingBoy on 16/11/27.
7+
* 暴露秒杀地址(接口)DTO
8+
*/
9+
public class Exposer {
10+
11+
//是否开启秒杀
12+
private boolean exposed;
13+
14+
//加密措施
15+
private String md5;
16+
17+
private long seckillId;
18+
19+
//系统当前时间(毫秒)
20+
private long now;
21+
22+
//秒杀的开启时间
23+
private long start;
24+
25+
//秒杀的结束时间
26+
private long end;
27+
28+
public Exposer(boolean exposed, String md5, long seckillId) {
29+
this.exposed = exposed;
30+
this.md5 = md5;
31+
this.seckillId = seckillId;
32+
}
33+
34+
public Exposer(boolean exposed, long seckillId,long now, long start, long end) {
35+
this.exposed = exposed;
36+
this.seckillId=seckillId;
37+
this.now = now;
38+
this.start = start;
39+
this.end = end;
40+
}
41+
42+
public Exposer(boolean exposed, long seckillId) {
43+
this.exposed = exposed;
44+
this.seckillId = seckillId;
45+
}
46+
47+
public boolean isExposed() {
48+
return exposed;
49+
}
50+
51+
public void setExposed(boolean exposed) {
52+
this.exposed = exposed;
53+
}
54+
55+
public String getMd5() {
56+
return md5;
57+
}
58+
59+
public void setMd5(String md5) {
60+
this.md5 = md5;
61+
}
62+
63+
public long getSeckillId() {
64+
return seckillId;
65+
}
66+
67+
public void setSeckillId(long seckillId) {
68+
this.seckillId = seckillId;
69+
}
70+
71+
public long getNow() {
72+
return now;
73+
}
74+
75+
public void setNow(long now) {
76+
this.now = now;
77+
}
78+
79+
public long getStart() {
80+
return start;
81+
}
82+
83+
public void setStart(long start) {
84+
this.start = start;
85+
}
86+
87+
public long getEnd() {
88+
return end;
89+
}
90+
91+
public void setEnd(long end) {
92+
this.end = end;
93+
}
94+
95+
@Override
96+
public String toString() {
97+
return "Exposer{" +
98+
"exposed=" + exposed +
99+
", md5='" + md5 + '\'' +
100+
", seckillId=" + seckillId +
101+
", now=" + now +
102+
", start=" + start +
103+
", end=" + end +
104+
'}';
105+
}
106+
}

0 commit comments

Comments
 (0)