1.在pom.xml中添加依赖 没有用java自带的util类
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.1</version>
</dependency>
2.增加数据库promo表
3.创建秒杀营销模型 PromoModel.java
public class PromoModel {
private Integer id;
//秒杀活动名称
private String promoName;
//秒杀活动的开始时间 这时可以开始抢购
private DateTime startDate;
//秒杀活动的适用商品 同一个秒杀活动只能用同一个itemid
private Integer itemId;
//秒杀活动的商品价格
private BigDecimal promoItemPrice;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getPromoName() {
return promoName;
}
public void setPromoName(String promoName) {
this.promoName = promoName;
}
public DateTime getStartDate() {
return startDate;
}
public void setStartDate(DateTime startDate) {
this.startDate = startDate;
}
public Integer getItemId() {
return itemId;
}
public void setItemId(Integer itemId) {
this.itemId = itemId;
}
public BigDecimal getPromoItemPrice() {
return promoItemPrice;
}
public void setPromoItemPrice(BigDecimal promoItemPrice) {
this.promoItemPrice = promoItemPrice;
}
}
4.使用mybatis-generator添加对应表的信息
<table tableName="promo" domainObjectName="PromoDO"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"></table>