Skip to content

Commit

Permalink
dao!
Browse files Browse the repository at this point in the history
  • Loading branch information
wchb2015 committed May 14, 2016
1 parent a6e98c3 commit 01f8217
Show file tree
Hide file tree
Showing 13 changed files with 588 additions and 13 deletions.
16 changes: 5 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<version>4.12</version>
</dependency>


<!--common end-->

<!--spring start-->
Expand Down Expand Up @@ -107,13 +106,13 @@
<!--spring end-->

<!--springmvc start-->

<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<!--<scope>provided</scope>-->
<version>1.2</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -137,9 +136,6 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>



<!--springmvc end-->

<!--mybatis start-->
Expand Down Expand Up @@ -186,20 +182,18 @@
<spring.version>4.2.0.RELEASE</spring.version>
</properties>



<!-- Build Settings -->
<!--http://maven.apache.org/pom.html#Build_Settings-->
<!-- <build>
<build>
<finalName>${artifactId}-${version}</finalName>
<resources>
<resource>
&lt;!&ndash;directory: 资源所在的位置&ndash;&gt;
<!--directory: 资源所在的位置-->
<directory>src/main/resources</directory>
&lt;!&ndash;filtering: 是否替换资源中的属性placehold&ndash;&gt;
<!--filtering: 是否替换资源中的属性placehold-->
<filtering>true</filtering>
</resource>
</resources>
</build>-->
</build>

</project>
106 changes: 106 additions & 0 deletions src/main/java/org/seckill/dto/Exposer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package org.seckill.dto;

/**
* 暴露秒杀地址DTO
* Created by wchb7 on 16-5-13.
*/
public class Exposer {

/**
* 秒杀是否开启
*/
private boolean exposed;


private String md5;

private long seckillId;

/**
* 系统时间(毫秒)
*/
private long now;

private long start;

private long end;

public Exposer(boolean exposed, String md5, long seckillId) {
this.exposed = exposed;
this.md5 = md5;
this.seckillId = seckillId;
}

public Exposer(boolean exposed, long seckillId, long now, long start, long end) {
this.exposed = exposed;
this.seckillId = seckillId;
this.now = now;
this.start = start;
this.end = end;
}

public Exposer(boolean exposed, long seckillId) {
this.exposed = exposed;
this.seckillId = seckillId;
}

public boolean isExposed() {
return exposed;
}

public void setExposed(boolean exposed) {
this.exposed = exposed;
}

public String getMd5() {
return md5;
}

public void setMd5(String md5) {
this.md5 = md5;
}

public long getSeckillId() {
return seckillId;
}

public void setSeckillId(long seckillId) {
this.seckillId = seckillId;
}

public long getNow() {
return now;
}

public void setNow(long now) {
this.now = now;
}

public long getStart() {
return start;
}

public void setStart(long start) {
this.start = start;
}

public long getEnd() {
return end;
}

public void setEnd(long end) {
this.end = end;
}

@Override
public String toString() {
return "Exposer{" +
"exposed=" + exposed +
", md5='" + md5 + '\'' +
", seckillId=" + seckillId +
", now=" + now +
", start=" + start +
", end=" + end +
'}';
}
}
83 changes: 83 additions & 0 deletions src/main/java/org/seckill/dto/SeckillExecution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.seckill.dto;

import org.seckill.entity.SuccessKilled;
import org.seckill.enums.SeckillStatEnum;

/**
* 封装秒杀执行后的结果
* Created by wchb7 on 16-5-13.
*/
public class SeckillExecution {


private long seckillId;

/**
* 秒杀执行结果状态
*/
private int state;

/**
* 状态表示
*/
private String stateInfo;

private SuccessKilled successKilled;

public long getSeckillId() {
return seckillId;
}

public void setSeckillId(long seckillId) {
this.seckillId = seckillId;
}

public int getState() {
return state;
}

public void setState(int state) {
this.state = state;
}

public String getStateInfo() {
return stateInfo;
}

public void setStateInfo(String stateInfo) {
this.stateInfo = stateInfo;
}

public SuccessKilled getSuccessKilled() {
return successKilled;
}

public void setSuccessKilled(SuccessKilled successKilled) {
this.successKilled = successKilled;
}


public SeckillExecution(long seckillId, SeckillStatEnum statEnum, String stateInfo) {
this.seckillId = seckillId;
this.state = statEnum.getState();
this.stateInfo = statEnum.getStateInfo();
this.stateInfo = stateInfo;
}

public SeckillExecution(long seckillId, SeckillStatEnum statEnum, SuccessKilled successKilled) {
this.seckillId = seckillId;
this.state = statEnum.getState();
this.stateInfo = statEnum.getStateInfo();
this.successKilled = successKilled;
}

@Override
public String toString() {
return "SeckillExecution{" +
"seckillId=" + seckillId +
", state=" + state +
", stateInfo='" + stateInfo + '\'' +
", successKilled=" + successKilled +
'}';
}
}
39 changes: 39 additions & 0 deletions src/main/java/org/seckill/enums/SeckillStatEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.seckill.enums;

/**
* Created by wchb7 on 16-5-14.
*/
public enum SeckillStatEnum {
SUCCESS(1, "秒杀成功"),
END(0, "秒杀结束"),
REPEAT_KILL(-1, "重复秒杀"),
INNER_ERROR(-2, "系统异常"),
DATA_REWRITE(-3, "数据篡改");

private int state;

private String stateInfo;

SeckillStatEnum(int state, String stateInfo) {
this.state = state;
this.stateInfo = stateInfo;
}

public int getState() {
return state;
}

public String getStateInfo() {
return stateInfo;
}

public static SeckillStatEnum stateOf(int index) {
for (SeckillStatEnum state : values()) {
if (state.getState() == index) {
return state;
}
}
return null;
}

}
18 changes: 18 additions & 0 deletions src/main/java/org/seckill/exception/RepeatKillException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.seckill.exception;

/**
* 重复秒杀异常(运行期异常)
* RuntimeException 不需要try/catch 而且Spring 的声明式事务只接收RuntimeException回滚策略.
* Created by wchb7 on 16-5-14.
*/
public class RepeatKillException extends SeckillException {

public RepeatKillException(String message) {
super(message);
}

public RepeatKillException(String message, Throwable cause) {
super(message, cause);
}

}
16 changes: 16 additions & 0 deletions src/main/java/org/seckill/exception/SeckillCloseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.seckill.exception;

/**
* Created by wchb7 on 16-5-14.
*/
public class SeckillCloseException extends SeckillException {

public SeckillCloseException(String message) {
super(message);
}

public SeckillCloseException(String message, Throwable cause) {
super(message, cause);
}

}
16 changes: 16 additions & 0 deletions src/main/java/org/seckill/exception/SeckillException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.seckill.exception;

/**
* 秒杀相关业务异常
* Created by wchb7 on 16-5-14.
*/
public class SeckillException extends RuntimeException {

public SeckillException(String message) {
super(message);
}

public SeckillException(String message, Throwable cause) {
super(message, cause);
}
}
Loading

0 comments on commit 01f8217

Please sign in to comment.