1.1前端交互流程設計javascript
1.2 學習Restful接口設計css
2.1 SpringMvc理論html
藍色部分是須要咱們本身開發的前端
?表一個字符html5
*表任意個字符java
**表任意路徑node
{}中的字符以參數形式傳入mysql
2.2 整合配置springMVC框架jquery
首先在WEB-INF的web.xml中進行咱們前端控制器DispatcherServlet的配置,以下:web
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true">
<!--用maven建立的web-app須要修改servlet的版本爲3.0-->
<!--配置DispatcherServlet-->
<servlet>
<servlet-name>seckill-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置SpringMVC 須要配置的文件 spring-dao.xml,spring-service.xml,spring-web.xml 整合順序 Mybites -> spring -> springMvc spring和springMVC不須要整合,二者都出自spring -->
<init-param>
<param-name>contextConfigLocation</param-name> <!-- config配置文件的location -->
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>seckill-dispatcher</servlet-name>
<!-- 默認匹配全部的請求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
而後在spring容器中進行web層相關bean(即Controller)的配置,在spring包下建立一個spring-web.xml,內容以下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- 配置springMVC -->
<!--1.開啓springmvc註解模式 簡化配置: (1)自動註冊DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter (2)默認提供一系列的功能:數據綁定,數字和日期的format@NumberFormat,@DateTimeFormat xml,json的默認讀寫支持 -->
<mvc:annotation-driven />
<!-- servlet-mapping 映射路徑:「/」 -->
<!--2.靜態資源默認servlet配置 -->
<!-- 1).加入對靜態資源處理:js,gif,png 2).容許使用 "/" 作總體映射 -->
<mvc:default-servlet-handler />
<!--3:配置JSP 顯示ViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!--4:掃描web相關的bean -->
<context:component-scan base-package="org.myseckill.web" />
</beans>
這樣咱們便完成了Spring MVC的相關配置(即將Spring MVC框架整合到了咱們的項目中)
在org.myseckill下新建一個web文件夾,用於存放咱們的controller
在該包下建立一個SeckillController.java,內容以下:
controller即MVC中的C控制層,職責是接收參數,作跳轉的控制
/** * controller即MVC中的C控制層,職責是接收參數,作跳轉的控制 * Controller開發中的方法徹底是對照Service接口方法進行開發的,第一個方法用於訪問咱們商品的列表頁, * 第二個方法訪問商品的詳情頁,第三個方法用於返回一個json數據,數據中封裝了咱們商品的秒殺地址, * 第四個方法用於封裝用戶是否秒殺成功的信息,第五個方法用於返回系統當前時間。 * @author TwoHeads * */ @Controller @RequestMapping("/seckill") //一級映射,至關於二級映射前面都有"/seckill" url:模塊/資源/{}/細分
public class SeckillController { private Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private SeckillService seckillService; @RequestMapping(value="/list",method=RequestMethod.GET) //二級映射
public String list(Model model) { //model用於存放渲染list的數據 list.jsp是頁面的模板,model是數據 //list.jsp+mode=ModelAndView //獲取秒殺的列表頁
List<Seckill> list = seckillService.getSeckillList(); model.addAttribute("list",list); return "list"; //即WEB-INF/jsp/"list".jsp
} @RequestMapping(value="/{seckillId}/detail",method=RequestMethod.GET) public String detail(@PathVariable("seckillId") Long seckillId,Model model) { //判斷seckillId有沒有傳
if(seckillId == null) { //以前把Long seckillId寫爲了long seckillId,不是一個對象,致使沒法判斷null
return "redirect:/seckill/list"; } Seckill seckill = seckillService.getById(seckillId); //若是傳的id不存在
if(seckill == null) { return "forward:/seckill/list"; } model.addAttribute("seckill",seckill); return "detail"; } //ajax接口 返回類型是json 暴露秒殺接口的方法 //只接受post方式,即直接在瀏覽器中輸入這個地址是無效的,地址欄回車屬於get方式。post方式只能設計一個表單,一個提交按鈕,才能夠。 //produces告訴瀏覽器咱們的contentType是json
@RequestMapping(value="/{seckillId}/exposer", method=RequestMethod.POST, produces= {"application/json;charset=UTF-8"}) //@ResponseBody這個註解告訴springMVC返回的是一個json類型的數據
@ResponseBody public SeckillResult<Exposer> exposer(Long seckillId) { SeckillResult<Exposer> result; try { Exposer exposer = seckillService.exportSeckillUrl(seckillId); result = new SeckillResult<Exposer>(true,exposer); } catch (Exception e) { logger.error(e.getMessage(),e); //出現異常則調用SeckillResult的另外一個構造方法
result = new SeckillResult<Exposer>(false,e.getMessage()); } return result; } //全部的ajax請求都統一的返回SeckillResult,dto用於web層和service層的數據傳遞,SeckillResult和Exposer,SeckillExecution全都是dto包下的類
@RequestMapping(value="/{seckillId}/{md5}/execution", method=RequestMethod.POST, produces= {"application/json;charset=UTF-8"}) @ResponseBody //參數seckillId和md5均可以從url映射的請求參數中{seckillId},{md5}取得,而用戶標識killPhone在url中並無,從用戶瀏覽器request請求的cookie中取得 //required = false使當cookie沒有killPhone參數時springMVC不報錯,把killphone的驗證邏輯放到程序中來
public SeckillResult<SeckillExecution> execute(@PathVariable("seckillId") Long seckillId, @PathVariable("md5")String md5, @CookieValue(value = "killPhone",required = false)Long phone){ if(phone == null) { return new SeckillResult<SeckillExecution>(false,"未註冊"); } SeckillResult<SeckillExecution> result; try { SeckillExecution execution = seckillService.executeSeckill(seckillId, phone, md5); return new SeckillResult<SeckillExecution>(true, execution); } catch (SeckillCloseException e) { //SeckillCloseException和RepeatKillException是容許的異常
SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.END); return new SeckillResult<SeckillExecution>(false, execution); } catch (RepeatKillException e) { SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.REPEAT_KILL); return new SeckillResult<SeckillExecution>(false, execution); } catch (Exception e) { logger.error(e.getMessage(), e); //其餘全部未知異常算做INNER_ERROR
SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.INNER_ERROR); return new SeckillResult<SeckillExecution>(false, execution); } } @RequestMapping(value="/time/now",method=RequestMethod.GET) public SeckillResult<Long> time(){ Date now = new Date(); return new SeckillResult<Long>(true, now.getTime()); } }
全部的ajax請求都統一的返回SeckillResult,
dto用於web層和service層的數據傳遞,SeckillResult和Exposer,SeckillExecution全都是dto包下的類
@ResposeBody註解的使用
一、
@responseBody註解的做用是將controller的方法返回的對象經過適當的轉換器轉換爲指定的格式以後,寫入到response對象的body區,一般用來返回JSON數據或者是XML
數據,須要注意的呢,在使用此註解以後不會再走試圖處理器,而是直接將數據寫入到輸入流中,他的效果等同於經過response對象輸出指定格式的數據。
二、
@RequestMapping("/login")
@ResponseBody
public User login(User user){
return user;
}
User字段:userName pwd
那麼在前臺接收到的數據爲:'{"userName":"xxx","pwd":"xxx"}'
效果等同於以下代碼:
@RequestMapping("/login")
public void login(User user, HttpServletResponse response){
response.getWriter.write(JSONObject.fromObject(user).toString());
}
Controller開發中的方法徹底是對照Service接口方法進行開發的,第一個方法用於訪問咱們商品的列表頁,第二個方法訪問商品的詳情頁,第三個方法用於返回一個json數據,數據中封裝了咱們商品的秒殺地址,第四個方法用於封裝用戶是否秒殺成功的信息,第五個方法用於返回系統當前時間。代碼中涉及到一個將返回秒殺商品地址封裝爲json數據的一個Vo類,即SeckillResult.java,在dto包中建立它,內容以下:
//封裝json數據結果,將全部的ajax請求返回類型,所有封裝成json數據
//泛型SeckillResult<T>能夠爲SeckillResult<Exposer>也能夠爲SeckillResult<SeckillExecution>
public class SeckillResult<T> { private boolean success; //標識,判斷請求是否成功
private T data; //泛型類型的數據
private String error; //錯誤信息 //若是success是true則有數據
public SeckillResult(boolean success, T data) { super(); this.success = success; this.data = data; } //若是success是false則傳遞錯誤信息
public SeckillResult(boolean success, String error) { super(); this.success = success; this.error = error; } //getter和setter
}
在WEB-INF下新建jsp文件夾和list.jsp和detail.jsp
直接在http://www.runoob.com/bootstrap/bootstrap-environment-setup.html中找到bootstrap模板,拷貝到list.jsp和detail.jsp中並進行修改
在jsp文件夾下建立common文件夾用於存放公用的的jsp,在其下建立head.jsp以下:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 Shiv 和 Respond.js 用於讓 IE8 支持 HTML5元素和媒體查詢 -->
<!-- 注意: 若是經過 file:// 引入 Respond.js 文件,則該文件沒法起效果 -->
<!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <![endif]-->
list.jsp和detail.jsp中便不須要以上內容了
剩下前端的內容暫時先複製了代碼
list.jsp:
<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@include file="common/tag.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>秒殺商品列表</title>
<%@include file="common/head.jsp" %>
</head>
<body>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading text-center">
<h2>秒殺列表</h2>
</div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名稱</th>
<th>庫存</th>
<th>開始時間</th>
<th>結束時間</th>
<th>建立時間</th>
<th>詳情頁</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="sk">
<tr>
<td>${sk.name}</td>
<td>${sk.number}</td>
<td>
<fmt:formatDate value="${sk.startTime}" pattern="yyyy-MM-dd HH:mm:ss" />
</td>
<td>
<fmt:formatDate value="${sk.endTime}" pattern="yyyy-MM-dd HH:mm:ss" />
</td>
<td>
<fmt:formatDate value="${sk.createTime}" pattern="yyyy-MM-dd HH:mm:ss" />
</td>
<td><a class="btn btn-info" href="/seckill/${sk.seckillId}/detail" target="_blank">詳情</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
<!-- jQuery文件。務必在bootstrap.min.js 以前引入 -->
<script src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</body>
</html>
detail.jsp:
<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@include file="common/tag.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>秒殺詳情頁</title>
<%@include file="common/head.jsp" %>
</head>
<body>
<div class="container">
<div class="panel panel-default text-center">
<div class="pannel-heading">
<h1>${seckill.name}</h1>
</div>
<div class="panel-body">
<h2 class="text-danger">
<%--顯示time圖標--%>
<span class="glyphicon glyphicon-time"></span>
<%--展現倒計時--%>
<span class="glyphicon" id="seckill-box"></span>
</h2>
</div>
</div>
</div>
<%--登陸彈出層 輸入電話--%>
<div id="killPhoneModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title text-center">
<span class="glyphicon glyphicon-phone"> </span>秒殺電話: </h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-8 col-xs-offset-2">
<input type="text" name="killPhone" id="killPhoneKey" placeholder="填寫手機號^o^" class="form-control">
</div>
</div>
</div>
<div class="modal-footer">
<%--驗證信息--%>
<span id="killPhoneMessage" class="glyphicon"> </span>
<button type="button" id="killPhoneBtn" class="btn btn-success">
<span class="glyphicon glyphicon-phone"></span> Submit </button>
</div>
</div>
</div>
</div>
</body>
<%--jQery文件,務必在bootstrap.min.js以前引入--%>
<script src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<%--使用CDN 獲取公共js http://www.bootcdn.cn/--%>
<%--jQuery Cookie操做插件--%>
<script src="http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<%--jQuery countDown倒計時插件--%>
<script src="http://cdn.bootcss.com/jquery.countdown/2.1.0/jquery.countdown.min.js"></script>
<script src="/resource/script/seckill.js" type="text/javascript"></script>
<script type="text/javascript"> $(function () { //使用EL表達式傳入參數 seckill.detail.init({ seckillId:${seckill.seckillId}, startTime:${seckill.startTime.time},//毫秒 endTime:${seckill.endTime.time} }); }) </script>
</html>
common文件夾下head.jsp:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<!-- æ° Bootstrap æ ¸å¿ CSS æ件 -->
<link href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<!-- å¯éçBootstrap主é¢æ件ï¼ä¸è¬ä¸ä½¿ç¨ï¼ -->
<link href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap-theme.min.css" rel="stylesheet">
<!-- HTML5 Shim å Respond.js ç¨äºè®© IE8 æ¯æ HTML5å
ç´ ååªä½æ¥è¯¢ -->
<!-- 注æï¼ å¦æéè¿ file:// å¼å
¥ Respond.js æ件ï¼å该æ件æ æ³èµ·ææ -->
<!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <![endif]-->
common文件夾下tag.jsp:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
運行時出現404錯誤,緣由以下:
我用的Eclipse,和老師用的IDEA不同,個人項目跑起來的路徑是:http://localhost:8080/myseckill/
http://localhost:8080/myseckill/seckill/list 就是列表頁。
http://localhost:8080/myseckill/seckill/1000/detail 就是詳情頁。
老師的http://localhost:8080/seckill/list 纔是詳情頁,不包含項目名稱
將詳情頁超連接href="/seckill/${sk.seckillId}/detail"改成href="/myseckill/seckill/${sk.seckillId}/detail"
運行成功頁面以下
在webapp下新建/resource/script/seckill.js
41//存放主要交互邏輯的js代碼 // javascript 模塊化(package.類.方法)
var seckill = { //封裝秒殺相關ajax的url
URL: { now: function () { return '/myseckill/seckill/time/now'; }, exposer: function (seckillId) { return '/myseckill/seckill/' + seckillId + '/exposer'; }, execution: function (seckillId, md5) { return '/myseckill/seckill/' + seckillId + '/' + md5 + '/execution'; } }, //驗證手機號
validatePhone: function (phone) { if (phone && phone.length == 11 && !isNaN(phone)) { return true;//直接判斷對象會看對象是否爲空,空就是undefine就是false; isNaN 非數字返回true
} else { return false; } }, //詳情頁秒殺邏輯
detail: { //詳情頁初始化
init: function (params) { //手機驗證和登陸,計時交互
//規劃咱們的交互流程
//在cookie中查找手機號
var userPhone = $.cookie('killPhone'); //驗證手機號
if (!seckill.validatePhone(userPhone)) { //綁定手機 控制輸出
var killPhoneModal = $('#killPhoneModal'); killPhoneModal.modal({ show: true,//顯示彈出層
backdrop: 'static',//禁止位置關閉
keyboard: false//關閉鍵盤事件
}); $('#killPhoneBtn').click(function () { var inputPhone = $('#killPhoneKey').val(); console.log("inputPhone: " + inputPhone); if (seckill.validatePhone(inputPhone)) { //電話寫入cookie(7天過時)
$.cookie('killPhone', inputPhone, {expires: 7, path: '/myseckill/seckill'}); //驗證經過 刷新頁面
window.location.reload(); } else { //todo 錯誤文案信息抽取到前端字典裏
$('#killPhoneMessage').hide().html('<label class="label label-danger">手機號錯誤!</label>').show(300); } }); } //已經登陸
//計時交互
var startTime = params['startTime']; var endTime = params['endTime']; var seckillId = params['seckillId']; $.get(seckill.URL.now(), {}, function (result) { if (result && result['success']) { var nowTime = result['data']; //時間判斷 計時交互
seckill.countDown(seckillId, nowTime, startTime, endTime); } else { console.log('result: ' + result); alert('result: ' + result); } }); } }, handlerSeckill: function (seckillId, node) { //獲取秒殺地址,控制顯示器,執行秒殺
node.hide().html('<button class="btn btn-primary btn-lg" id="killBtn">開始秒殺</button>'); $.get(seckill.URL.exposer(seckillId), {}, function (result) { //在回調函數種執行交互流程
if (result && result['success']) { var exposer = result['data']; if (exposer['exposed']) { //開啓秒殺
//獲取秒殺地址
var md5 = exposer['md5']; var killUrl = seckill.URL.execution(seckillId, md5); console.log("killUrl: " + killUrl); //綁定一次點擊事件
$('#killBtn').one('click', function () { //執行秒殺請求
//1.先禁用按鈕
$(this).addClass('disabled');//,<-$(this)===('#killBtn')->
//2.發送秒殺請求執行秒殺
$.post(killUrl, {}, function (result) { if (result && result['success']) { var killResult = result['data']; var state = killResult['state']; var stateInfo = killResult['stateInfo']; //顯示秒殺結果
node.html('<span class="label label-success">' + stateInfo + '</span>'); } }); }); node.show(); } else { //未開啓秒殺(瀏覽器計時誤差)
var now = exposer['now']; var start = exposer['start']; var end = exposer['end']; seckill.countDown(seckillId, now, start, end); } } else { console.log('result: ' + result); } }); }, countDown: function (seckillId, nowTime, startTime, endTime) { console.log(seckillId + '_' + nowTime + '_' + startTime + '_' + endTime); var seckillBox = $('#seckill-box'); if (nowTime > endTime) { //秒殺結束
seckillBox.html('秒殺結束!'); } else if (nowTime < startTime) { //秒殺未開始,計時事件綁定
var killTime = new Date(startTime + 1000);//todo 防止時間偏移
seckillBox.countdown(killTime, function (event) { //時間格式
var format = event.strftime('秒殺倒計時: %D天 %H時 %M分 %S秒 '); seckillBox.html(format); }).on('finish.countdown', function () { //時間完成後回調事件
//獲取秒殺地址,控制現實邏輯,執行秒殺
console.log('______fininsh.countdown'); seckill.handlerSeckill(seckillId, seckillBox); }); } else { //秒殺開始
seckill.handlerSeckill(seckillId, seckillBox); } } }
遇到的問題:
1.沒法彈出手機號輸入框
發現seckill.js加載失敗,但程序並未報錯
把<script src="/resource/script/seckill.js" type="text/javascript"></script>修改成
<script src="/myseckill/resource/script/seckill.js" type="text/javascript"></script>
老師使用的IDEA與eclipse的路徑不一樣
2.輸入手機號後仍是一直彈出手機號輸入框
seckill.js邏輯中登入成功會刷新頁面,猜測應該是cookie寫入失敗,刷新後認爲是新用戶
將seckill.js中$.cookie('userPhone', inputPhone, {expires: 7, path: '/seckill'});修改成
$.cookie('userPhone', inputPhone, {expires: 7, path: '/myseckill/seckill'});
path中加入項目名,否則寫不進去cookie
cookie寫入成功,再也不重複要求登陸(輸入手機號)
3./time/now 404錯誤
修改路徑無效
發現緣由是web層SeckillController中沒有加入@ResponseBody註解
@RequestMapping(value="/time/now",method=RequestMethod.GET) @ResponseBody public SeckillResult<Long> time(){ Date now = new Date(); return new SeckillResult<Long>(true, now.getTime()); }
測試成功:
但不能顯示重複秒殺結果
將SeckillController中execute方法中的false都改成true,由於seckill.js中當success的值爲true時才輸出結果
public class SeckillResult<T> { private boolean success; //標識,判斷請求是否成功而不是秒殺是否成功
if (result && result['success']) { var killResult = result['data']; var state = killResult['state']; var stateInfo = killResult['stateInfo']; //顯示秒殺結果
node.html('<span class="label label-success">' + stateInfo + '</span>');
這樣,當出現異常(包括咱們容許的異常)時,也算請求成功
public SeckillResult<SeckillExecution> execute(@PathVariable("seckillId") Long seckillId, @PathVariable("md5")String md5, @CookieValue(value = "killPhone",required = false)Long phone){ if(phone == null) { return new SeckillResult<SeckillExecution>(false,"未註冊"); } SeckillResult<SeckillExecution> result; try { SeckillExecution execution = seckillService.executeSeckill(seckillId, phone, md5); return new SeckillResult<SeckillExecution>(true, execution); } catch (SeckillCloseException e) { //SeckillCloseException和RepeatKillException是容許的異常
SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.END); return new SeckillResult<SeckillExecution>(true, execution); } catch (RepeatKillException e) { SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.REPEAT_KILL); return new SeckillResult<SeckillExecution>(true, execution); } catch (Exception e) { logger.error(e.getMessage(), e); //其餘全部未知異常算做INNER_ERROR
SeckillExecution execution = new SeckillExecution(seckillId, SeckillStatEnum.INNER_ERROR); return new SeckillResult<SeckillExecution>(true, execution); } }
成功顯示結果
mysql中也相應進行了減庫存操做
success_killed成功秒殺明細: