forked from liyifeng1994/ssm
-
Notifications
You must be signed in to change notification settings - Fork 0
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
李奕锋
committed
Jun 18, 2016
1 parent
831ce68
commit 1af9426
Showing
29 changed files
with
2,294 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,146 @@ | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.soecode.ssm</groupId> | ||
<artifactId>ssm</artifactId> | ||
<packaging>war</packaging> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>ssm Maven Webapp</name> | ||
<url>http:https://github.com/liyifeng1994/ssm</url> | ||
<dependencies> | ||
<!-- 单元测试 --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
</dependency> | ||
|
||
<!-- 1.日志 --> | ||
<!-- 实现slf4j接口并整合 --> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
|
||
<!-- 2.数据库 --> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.37</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>c3p0</groupId> | ||
<artifactId>c3p0</artifactId> | ||
<version>0.9.1.2</version> | ||
</dependency> | ||
|
||
<!-- DAO: MyBatis --> | ||
<dependency> | ||
<groupId>org.mybatis</groupId> | ||
<artifactId>mybatis</artifactId> | ||
<version>3.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mybatis</groupId> | ||
<artifactId>mybatis-spring</artifactId> | ||
<version>1.2.3</version> | ||
</dependency> | ||
|
||
<!-- 3.Servlet web --> | ||
<dependency> | ||
<groupId>taglibs</groupId> | ||
<artifactId>standard</artifactId> | ||
<version>1.1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jstl</groupId> | ||
<artifactId>jstl</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.5.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.1.0</version> | ||
</dependency> | ||
|
||
<!-- 4.Spring --> | ||
<!-- 1)Spring核心 --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<!-- 2)Spring DAO层 --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-jdbc</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-tx</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<!-- 3)Spring web --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webmvc</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
<!-- 4)Spring test --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<version>4.1.7.RELEASE</version> | ||
</dependency> | ||
|
||
<!-- redis客户端:Jedis --> | ||
<dependency> | ||
<groupId>redis.clients</groupId> | ||
<artifactId>jedis</artifactId> | ||
<version>2.7.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.dyuproject.protostuff</groupId> | ||
<artifactId>protostuff-core</artifactId> | ||
<version>1.0.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.dyuproject.protostuff</groupId> | ||
<artifactId>protostuff-runtime</artifactId> | ||
<version>1.0.8</version> | ||
</dependency> | ||
|
||
<!-- Map工具类 --> | ||
<dependency> | ||
<groupId>commons-collections</groupId> | ||
<artifactId>commons-collections</artifactId> | ||
<version>3.2</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>ssm</finalName> | ||
</build> | ||
</project> |
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,27 @@ | ||
package com.soecode.lyf.dao; | ||
|
||
import org.apache.ibatis.annotations.Param; | ||
|
||
import com.soecode.lyf.entity.Appointment; | ||
|
||
public interface AppointmentDao { | ||
|
||
/** | ||
* 插入预约图书记录 | ||
* | ||
* @param bookId | ||
* @param studentId | ||
* @return 插入的行数 | ||
*/ | ||
int insertAppointment(@Param("bookId") long bookId, @Param("studentId") long studentId); | ||
|
||
/** | ||
* 通过主键查询预约图书记录,并且携带图书实体 | ||
* | ||
* @param bookId | ||
* @param studentId | ||
* @return | ||
*/ | ||
Appointment queryByKeyWithBook(@Param("bookId") long bookId, @Param("studentId") long studentId); | ||
|
||
} |
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,37 @@ | ||
package com.soecode.lyf.dao; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.apache.ibatis.annotations.Param; | ||
|
||
import com.soecode.lyf.entity.Book; | ||
|
||
public interface BookDao { | ||
|
||
/** | ||
* 通过ID查询单本图书 | ||
* | ||
* @param id | ||
* @return | ||
*/ | ||
Book queryById(long id); | ||
|
||
/** | ||
* 查询所有图书 | ||
* | ||
* @param offset 查询起始位置 | ||
* @param limit 查询条数 | ||
* @return | ||
*/ | ||
List<Book> queryAll(@Param("offset") int offset, @Param("limit") int limit); | ||
|
||
/** | ||
* 减少馆藏数量 | ||
* | ||
* @param bookId | ||
* @return 如果影响行数等于>1,表示更新的记录行数 | ||
*/ | ||
int reduceNumber(long bookId); | ||
|
||
} |
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,79 @@ | ||
package com.soecode.lyf.dto; | ||
|
||
import com.soecode.lyf.entity.Appointment; | ||
import com.soecode.lyf.enums.AppointStateEnum; | ||
|
||
/** | ||
* 封装预约执行后结果 | ||
*/ | ||
public class AppointExecution { | ||
|
||
// 图书ID | ||
private long bookId; | ||
|
||
// 秒杀预约结果状态 | ||
private int state; | ||
|
||
// 状态标识 | ||
private String stateInfo; | ||
|
||
// 预约成功对象 | ||
private Appointment appointment; | ||
|
||
public AppointExecution() { | ||
} | ||
|
||
// 预约失败的构造器 | ||
public AppointExecution(long bookId, AppointStateEnum stateEnum) { | ||
this.bookId = bookId; | ||
this.state = stateEnum.getState(); | ||
this.stateInfo = stateEnum.getStateInfo(); | ||
} | ||
|
||
// 预约成功的构造器 | ||
public AppointExecution(long bookId, AppointStateEnum stateEnum, Appointment appointment) { | ||
this.bookId = bookId; | ||
this.state = stateEnum.getState(); | ||
this.stateInfo = stateEnum.getStateInfo(); | ||
this.appointment = appointment; | ||
} | ||
|
||
public long getBookId() { | ||
return bookId; | ||
} | ||
|
||
public void setBookId(long bookId) { | ||
this.bookId = bookId; | ||
} | ||
|
||
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 Appointment getAppointment() { | ||
return appointment; | ||
} | ||
|
||
public void setAppointment(Appointment appointment) { | ||
this.appointment = appointment; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AppointExecution [bookId=" + bookId + ", state=" + state + ", stateInfo=" + stateInfo + ", appointment=" | ||
+ appointment + "]"; | ||
} | ||
|
||
} |
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,58 @@ | ||
package com.soecode.lyf.dto; | ||
|
||
/** | ||
* 封装json对象,所有返回结果都使用它 | ||
*/ | ||
public class Result<T> { | ||
|
||
private boolean success;// 是否成功标志 | ||
|
||
private T data;// 成功时返回的数据 | ||
|
||
private String error;// 错误信息 | ||
|
||
public Result() { | ||
} | ||
|
||
// 成功时的构造器 | ||
public Result(boolean success, T data) { | ||
this.success = success; | ||
this.data = data; | ||
} | ||
|
||
// 错误时的构造器 | ||
public Result(boolean success, String error) { | ||
this.success = success; | ||
this.error = error; | ||
} | ||
|
||
public boolean isSuccess() { | ||
return success; | ||
} | ||
|
||
public void setSuccess(boolean success) { | ||
this.success = success; | ||
} | ||
|
||
public T getData() { | ||
return data; | ||
} | ||
|
||
public void setData(T data) { | ||
this.data = data; | ||
} | ||
|
||
public String getError() { | ||
return error; | ||
} | ||
|
||
public void setError(String error) { | ||
this.error = error; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "JsonResult [success=" + success + ", data=" + data + ", error=" + error + "]"; | ||
} | ||
|
||
} |
Oops, something went wrong.