秒杀Servlce接口设计
秒杀Servlce接口设计
1、创建service包,创建SecKillServlce业务接口
SecKillServlce.Java
package org.secKill.service; import java.util.List; /** |
建立dto包,创建暴露秒杀接口dto(数据传输层)
Exposer.java
package org.secKill.dto; /** public Exposer(boolean exposed, String md5, long secKillId) { public Exposer(boolean exposed, String md5, long start, long secKillId, long end) { public Exposer(boolean exposed, long secKillId) { public boolean isExposed() { public void setExposed(boolean exposed) { public String getMd5() { public void setMd5(String md5) { public long getSecKillId() { public void setSecKillId(long secKillId) { public long getStart() { public void setStart(long start) { public long getEnd() { public void setEnd(long end) { @Override |
创建包enums,创建枚举类型SecKillStateEnum.java使用枚举表述数据常量字典
SecKillStateEnum.java
package org.secKill.enums; /** SUCCESS(1, "秒杀成功"), END(0, "秒杀结束"), REPEAT_KILL(-1, "重复秒杀"), INNER_ERROR(-2, "系统异常"), DATA_REWRITE(-3, "数据篡改"); private int state; private String stateInfo; private SecKillStateEnum(int state, String stateInfo) { public int getState() { public String getStateInfo() { public static SecKillStateEnum stateOf(int index) { } |
在dto包内创建封装秒杀执行后结果类SecKillExecution.java
package org.secKill.dto; import org.secKill.entity.SuccessKilled; /** public SecKillExecution(long secKillId, SecKillStateEnum stateEnum , SuccessKilled successKilled) { } public SecKillExecution(long secKillId,SecKillStateEnum stateEnum) { public long getSecKillId() { public void setSecKillId(long secKillId) { public int getState() { public void setState(int state) { public String getStateInfo() { public void setStateInfo(String stateInfo) { public SuccessKilled getSuccessKilled() { public void setSuccessKilled(SuccessKilled successKilled) { |
创建包exception创建三个异常
创建SecKillException.java 秒杀执行异常
package org.secKill.exception; /** |
重复秒杀异常RepeatKillException.继承SecKillException.java
package org.secKill.exception; import org.secKill.dto.SecKillExecution; /** public RepeatKillException(String message, Throwable cause) { |
创建SecKillException.java,表示秒杀关闭异常
package org.secKill.exception; /** public SecKillCloseException(String message, Throwable cause) { |
最新文章
- StartUML 破解
- Qt Creator 快捷键
- java数组初始化的三种方式
- Drawable(4)LevelListDrawable
- 基于百度定位SDK的定位服务的实现
- centOS6 php 编 imap 模
- linux截取字符串之sort、uniq、cut用法
- Request.Params
- bootstrap 解决弹出窗口(modal) 常见问题
- BZOJ4836 [Lydsy1704月赛]二元运算 分治 多项式 FFT
- Scrapy基础(五) ------css选择器基础
- Gson全解析(中)-TypeAdapter的使用
- mysql用户创建与授权
- Server.MapPath 出现未将对象引用设置到对象的实例
- Oracle体系结构之参数文件管理
- C/C++基础----函数
- UVAlive4255_Guess
- [JSOI2009]瓶子和燃料
- js 作用域链&;内存回收&;变量&;闭包
- oracle 手动 备份 恢复
热门文章
- Net的网络层的构建(源码分析)
- 16/7/7_PHP-Static静态关键字
- Java课堂笔记(三):抽象类和接口
- 信息收集【采集点OWASP CHINA】网址http://www.owasp.org.cn/
- ElasticSearch 基础 2
- STL 迭代器适配器(iterator adapter)
- quartz任务调度的详解
- C#异步:AsyncCallback和IAsyncResult
- Java数据结构之链表(Linked List)
- <;每日一题>; Day1:CodeForces.1140D.MinimumTriangulation(思维题)