package com.ryan.miaosha.domain;
public class Goods {
private Long id;
private String goodsName;
private String goodsTitle;
private String goodsImg;
private String goodsDetail;
private Double goodsPrice;
private Integer goodsStock;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsTitle() {
return goodsTitle;
}
public void setGoodsTitle(String goodsTitle) {
this.goodsTitle = goodsTitle;
}
public String getGoodsImg() {
return goodsImg;
}
public void setGoodsImg(String goodsImg) {
this.goodsImg = goodsImg;
}
public String getGoodsDetail() {
return goodsDetail;
}
public void setGoodsDetail(String goodsDetail) {
this.goodsDetail = goodsDetail;
}
public Double getGoodsPrice() {
return goodsPrice;
}
public void setGoodsPrice(Double goodsPrice) {
this.goodsPrice = goodsPrice;
}
public Integer getGoodsStock() {
return goodsStock;
}
public void setGoodsStock(Integer goodsStock) {
this.goodsStock = goodsStock;
}
}
1.MiaoshaGoods类
1.1
package com.ryan.miaosha.domain;
import java.util.Date;
public class MiaoshaGoods {
private Long id;
private Long goodsId;
private Integer stockCount;
private Date startDate;
private Date endDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
public Integer getStockCount() {
return stockCount;
}
public void setStockCount(Integer stockCount) {
this.stockCount = stockCount;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}
1.订单详情
1.1
package com.ryan.miaosha.domain;
import java.util.Date;
public class OrderInfo {
private Long id;
private Long userId;
private Long goodsId;
private Long deliveryAddrId;
private String goodsName;
private Integer goodsCount;
private Double goodsPrice;
private Integer orderChannel;
private Integer status;
private Date createDate;
private Date payDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
public Long getDeliveryAddrId() {
return deliveryAddrId;
}
public void setDeliveryAddrId(Long deliveryAddrId) {
this.deliveryAddrId = deliveryAddrId;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public Integer getGoodsCount() {
return goodsCount;
}
public void setGoodsCount(Integer goodsCount) {
this.goodsCount = goodsCount;
}
public Double getGoodsPrice() {
return goodsPrice;
}
public void setGoodsPrice(Double goodsPrice) {
this.goodsPrice = goodsPrice;
}
public Integer getOrderChannel() {
return orderChannel;
}
public void setOrderChannel(Integer orderChannel) {
this.orderChannel = orderChannel;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getPayDate() {
return payDate;
}
public void setPayDate(Date payDate) {
this.payDate = payDate;
}
}
1.MiaoshaOrder
1.1
package com.ryan.miaosha.domain;
public class MiaoshaOrder {
private Long id;
private Long userId;
private Long orderId;
private Long goodsId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
}
1.GoodsVo 它包含了Goods和秒杀商品 联合查询
1.1
package com.ryan.miaosha.vo;
import java.util.Date;
import com.ryan.miaosha.domain.Goods;
public class GoodsVo extends Goods {
private Integer stockCount;
private Date startDate;
private Date endDate;
public Integer getStockCount() {
return stockCount;
}
public void setStockCount(Integer stockCount) {
this.stockCount = stockCount;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}
package com.ryan.miaosha.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import com.ryan.miaosha.vo.GoodsVo;
@Mapper
public interface GoodsDao {
@Select("select g.*,mg.stock_count,mg.start_date,mg.end_date,mg.miaosha_price from miaosha_goods mg left join goods g on mg.goods_id=g.id")
public List listGoodsVo();
}
1.service层
1.1
package com.ryan.miaosha.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ryan.miaosha.dao.GoodsDao;
import com.ryan.miaosha.dao.User;
import com.ryan.miaosha.dao.UserDao;
import com.ryan.miaosha.vo.GoodsVo;
@Service
public class GoodsService {
@Autowired
GoodsDao goodsDao;
public List listGoodsVo() {
return goodsDao.listGoodsVo();
}
}
JSR-303是一个数据验证的规范,但是spring并没有对其进行实现,Hibernate Validator是实现了这一规范的,通过此这个实现来讲SpringMVC对JSR-303的支持。
JSR-303的校验是基于注解的,首先要把这些注解标记在需要验证的实体类的属性上或是其对应的get方法上。
登录需要验证类
public class Login {
@NotEmpty
引言:有时候需要在项目初始化的时候进行一系列工作,比如初始化一个线程池,初始化配置文件,初始化缓存等等,这时候就需要用到启动监听器,下面分别介绍一下两种常用的项目启动监听器
ServletContextListener
特点: 依赖于sevlet容器,需要配置web.xml
使用方法:
public class StartListener implements
The next group of methods has to do with rounding decimal values into integers. Three methods — Math.ceil(), Math.floor(), and Math.round() — handle rounding in differen