mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-02-04 07:10:29 +08:00
抢购3
This commit is contained in:
parent
90cbb3d430
commit
e77065df5d
@ -76,6 +76,15 @@ public class ItemController extends BaseController {
|
|||||||
}
|
}
|
||||||
ItemVO itemVO = new ItemVO();
|
ItemVO itemVO = new ItemVO();
|
||||||
BeanUtils.copyProperties(itemModel, itemVO);
|
BeanUtils.copyProperties(itemModel, itemVO);
|
||||||
|
if (itemModel.getPromoModel() != null) {
|
||||||
|
// 有正在进行或即将进行的秒杀活动
|
||||||
|
itemVO.setPromoStatus(itemModel.getPromoModel().getStatus());
|
||||||
|
itemVO.setPromoId(itemModel.getId());
|
||||||
|
itemVO.setStartDate(itemModel.getPromoModel().getStartDate());
|
||||||
|
itemVO.setPromoPrice(itemModel.getPromoModel().getPromoPrice());
|
||||||
|
} else {
|
||||||
|
itemVO.setPromoStatus(0);
|
||||||
|
}
|
||||||
return itemVO;
|
return itemVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.cxyxiaomo.flashsale.controller.viewobject;
|
package com.cxyxiaomo.flashsale.controller.viewobject;
|
||||||
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class ItemVO {
|
public class ItemVO {
|
||||||
@ -24,6 +26,19 @@ public class ItemVO {
|
|||||||
// 商品描述图片的URL
|
// 商品描述图片的URL
|
||||||
private String imgUrl;
|
private String imgUrl;
|
||||||
|
|
||||||
|
// 记录商品是否在秒杀活动中,以及对应的状态
|
||||||
|
// 0:没有秒杀活动 2:秒杀活动待开始 3:秒杀活动进行中
|
||||||
|
private Integer promoStatus;
|
||||||
|
|
||||||
|
// 秒杀活动价格
|
||||||
|
private BigDecimal promoPrice;
|
||||||
|
|
||||||
|
// 秒杀活动Id
|
||||||
|
private Integer promoId;
|
||||||
|
|
||||||
|
// 秒杀活动开始时间
|
||||||
|
private DateTime startDate;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -79,4 +94,36 @@ public class ItemVO {
|
|||||||
public void setImgUrl(String imgUrl) {
|
public void setImgUrl(String imgUrl) {
|
||||||
this.imgUrl = imgUrl;
|
this.imgUrl = imgUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getPromoStatus() {
|
||||||
|
return promoStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromoStatus(Integer promoStatus) {
|
||||||
|
this.promoStatus = promoStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPromoPrice() {
|
||||||
|
return promoPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromoPrice(BigDecimal promoPrice) {
|
||||||
|
this.promoPrice = promoPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPromoId() {
|
||||||
|
return promoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromoId(Integer promoId) {
|
||||||
|
this.promoId = promoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(DateTime startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
int deleteByPrimaryKey(Integer id);
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
int insert(PromoDO record);
|
int insert(PromoDO record);
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
int insertSelective(PromoDO record);
|
int insertSelective(PromoDO record);
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
PromoDO selectByPrimaryKey(Integer id);
|
PromoDO selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
int updateByPrimaryKeySelective(PromoDO record);
|
int updateByPrimaryKeySelective(PromoDO record);
|
||||||
|
|
||||||
@ -47,7 +47,9 @@ public interface PromoDOMapper {
|
|||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method corresponds to the database table promo_info
|
* This method corresponds to the database table promo_info
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
int updateByPrimaryKey(PromoDO record);
|
int updateByPrimaryKey(PromoDO record);
|
||||||
|
|
||||||
|
PromoDO selectByItemId(Integer itemId);
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ public class PromoDO {
|
|||||||
* This field was generated by MyBatis Generator.
|
* This field was generated by MyBatis Generator.
|
||||||
* This field corresponds to the database column promo_info.id
|
* This field corresponds to the database column promo_info.id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public class PromoDO {
|
|||||||
* This field was generated by MyBatis Generator.
|
* This field was generated by MyBatis Generator.
|
||||||
* This field corresponds to the database column promo_info.promo_name
|
* This field corresponds to the database column promo_info.promo_name
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
private String promoName;
|
private String promoName;
|
||||||
|
|
||||||
@ -27,16 +27,25 @@ public class PromoDO {
|
|||||||
* This field was generated by MyBatis Generator.
|
* This field was generated by MyBatis Generator.
|
||||||
* This field corresponds to the database column promo_info.start_date
|
* This field corresponds to the database column promo_info.start_date
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This field was generated by MyBatis Generator.
|
||||||
|
* This field corresponds to the database column promo_info.end_date
|
||||||
|
*
|
||||||
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
|
*/
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This field was generated by MyBatis Generator.
|
* This field was generated by MyBatis Generator.
|
||||||
* This field corresponds to the database column promo_info.item_id
|
* This field corresponds to the database column promo_info.item_id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
private Integer itemId;
|
private Integer itemId;
|
||||||
|
|
||||||
@ -45,7 +54,7 @@ public class PromoDO {
|
|||||||
* This field was generated by MyBatis Generator.
|
* This field was generated by MyBatis Generator.
|
||||||
* This field corresponds to the database column promo_info.prome_item_price
|
* This field corresponds to the database column promo_info.prome_item_price
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
private BigDecimal promeItemPrice;
|
private BigDecimal promeItemPrice;
|
||||||
|
|
||||||
@ -55,7 +64,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @return the value of promo_info.id
|
* @return the value of promo_info.id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -67,7 +76,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @param id the value for promo_info.id
|
* @param id the value for promo_info.id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -79,7 +88,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @return the value of promo_info.promo_name
|
* @return the value of promo_info.promo_name
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public String getPromoName() {
|
public String getPromoName() {
|
||||||
return promoName;
|
return promoName;
|
||||||
@ -91,7 +100,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @param promoName the value for promo_info.promo_name
|
* @param promoName the value for promo_info.promo_name
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public void setPromoName(String promoName) {
|
public void setPromoName(String promoName) {
|
||||||
this.promoName = promoName == null ? null : promoName.trim();
|
this.promoName = promoName == null ? null : promoName.trim();
|
||||||
@ -103,7 +112,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @return the value of promo_info.start_date
|
* @return the value of promo_info.start_date
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public Date getStartDate() {
|
public Date getStartDate() {
|
||||||
return startDate;
|
return startDate;
|
||||||
@ -115,19 +124,43 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @param startDate the value for promo_info.start_date
|
* @param startDate the value for promo_info.start_date
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public void setStartDate(Date startDate) {
|
public void setStartDate(Date startDate) {
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method was generated by MyBatis Generator.
|
||||||
|
* This method returns the value of the database column promo_info.end_date
|
||||||
|
*
|
||||||
|
* @return the value of promo_info.end_date
|
||||||
|
*
|
||||||
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
|
*/
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method was generated by MyBatis Generator.
|
||||||
|
* This method sets the value of the database column promo_info.end_date
|
||||||
|
*
|
||||||
|
* @param endDate the value for promo_info.end_date
|
||||||
|
*
|
||||||
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
|
*/
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method was generated by MyBatis Generator.
|
* This method was generated by MyBatis Generator.
|
||||||
* This method returns the value of the database column promo_info.item_id
|
* This method returns the value of the database column promo_info.item_id
|
||||||
*
|
*
|
||||||
* @return the value of promo_info.item_id
|
* @return the value of promo_info.item_id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public Integer getItemId() {
|
public Integer getItemId() {
|
||||||
return itemId;
|
return itemId;
|
||||||
@ -139,7 +172,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @param itemId the value for promo_info.item_id
|
* @param itemId the value for promo_info.item_id
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public void setItemId(Integer itemId) {
|
public void setItemId(Integer itemId) {
|
||||||
this.itemId = itemId;
|
this.itemId = itemId;
|
||||||
@ -151,7 +184,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @return the value of promo_info.prome_item_price
|
* @return the value of promo_info.prome_item_price
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public BigDecimal getPromeItemPrice() {
|
public BigDecimal getPromeItemPrice() {
|
||||||
return promeItemPrice;
|
return promeItemPrice;
|
||||||
@ -163,7 +196,7 @@ public class PromoDO {
|
|||||||
*
|
*
|
||||||
* @param promeItemPrice the value for promo_info.prome_item_price
|
* @param promeItemPrice the value for promo_info.prome_item_price
|
||||||
*
|
*
|
||||||
* @mbg.generated Sat Mar 05 12:40:27 CST 2022
|
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||||
*/
|
*/
|
||||||
public void setPromeItemPrice(BigDecimal promeItemPrice) {
|
public void setPromeItemPrice(BigDecimal promeItemPrice) {
|
||||||
this.promeItemPrice = promeItemPrice;
|
this.promeItemPrice = promeItemPrice;
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.cxyxiaomo.flashsale.service;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.flashsale.service.model.PromoModel;
|
||||||
|
|
||||||
|
public interface PromoService {
|
||||||
|
// 根据itemId获取即将进行的或正在进行的秒杀活动
|
||||||
|
PromoModel getPromoByItemId(Integer itemId);
|
||||||
|
}
|
@ -7,7 +7,9 @@ import com.cxyxiaomo.flashsale.dataobject.ItemStockDO;
|
|||||||
import com.cxyxiaomo.flashsale.error.BusinessException;
|
import com.cxyxiaomo.flashsale.error.BusinessException;
|
||||||
import com.cxyxiaomo.flashsale.error.EmBusinessError;
|
import com.cxyxiaomo.flashsale.error.EmBusinessError;
|
||||||
import com.cxyxiaomo.flashsale.service.ItemService;
|
import com.cxyxiaomo.flashsale.service.ItemService;
|
||||||
|
import com.cxyxiaomo.flashsale.service.PromoService;
|
||||||
import com.cxyxiaomo.flashsale.service.model.ItemModel;
|
import com.cxyxiaomo.flashsale.service.model.ItemModel;
|
||||||
|
import com.cxyxiaomo.flashsale.service.model.PromoModel;
|
||||||
import com.cxyxiaomo.flashsale.validator.ValidationResult;
|
import com.cxyxiaomo.flashsale.validator.ValidationResult;
|
||||||
import com.cxyxiaomo.flashsale.validator.ValidatorImpl;
|
import com.cxyxiaomo.flashsale.validator.ValidatorImpl;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -30,6 +32,9 @@ public class ItemServiceImpl implements ItemService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ItemStockDOMapper itemStockDOMapper;
|
private ItemStockDOMapper itemStockDOMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PromoService promoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ItemModel createItem(ItemModel itemModel) throws BusinessException {
|
public ItemModel createItem(ItemModel itemModel) throws BusinessException {
|
||||||
@ -100,6 +105,13 @@ public class ItemServiceImpl implements ItemService {
|
|||||||
|
|
||||||
// 将Data Object -> Model
|
// 将Data Object -> Model
|
||||||
ItemModel itemModel = convertModelFromDataObject(itemDO, itemStockDO);
|
ItemModel itemModel = convertModelFromDataObject(itemDO, itemStockDO);
|
||||||
|
|
||||||
|
// 获取活动商品信息
|
||||||
|
PromoModel promoModel = promoService.getPromoByItemId(itemModel.getId());
|
||||||
|
if (promoModel != null && promoModel.getStatus() != 3) {
|
||||||
|
itemModel.setPromoModel(promoModel);
|
||||||
|
}
|
||||||
|
|
||||||
return itemModel;
|
return itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.cxyxiaomo.flashsale.service.impl;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.flashsale.dao.PromoDOMapper;
|
||||||
|
import com.cxyxiaomo.flashsale.dataobject.PromoDO;
|
||||||
|
import com.cxyxiaomo.flashsale.service.PromoService;
|
||||||
|
import com.cxyxiaomo.flashsale.service.model.PromoModel;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class PromoServiceImpl implements PromoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PromoDOMapper promoDOMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PromoModel getPromoByItemId(Integer itemId) {
|
||||||
|
// 获取对应商品的秒杀活动信息
|
||||||
|
PromoDO promoDO = promoDOMapper.selectByPrimaryKey(itemId);
|
||||||
|
|
||||||
|
// Data Object -> Model
|
||||||
|
PromoModel promoModel = convertFromDataObject(promoDO);
|
||||||
|
|
||||||
|
// 判断秒杀活动是否即将开始或正在进行
|
||||||
|
if (promoModel.getStartDate().isAfterNow()) {
|
||||||
|
promoModel.setStatus(1); // 还未开始
|
||||||
|
} else if (promoModel.getEndDate().isBeforeNow()) {
|
||||||
|
promoModel.setStatus(3); // 已经结束
|
||||||
|
} else {
|
||||||
|
promoModel.setStatus(2); // 正在进行中
|
||||||
|
}
|
||||||
|
|
||||||
|
return promoModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PromoModel convertFromDataObject(PromoDO promoDO) {
|
||||||
|
if (promoDO == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PromoModel promoModel = new PromoModel();
|
||||||
|
BeanUtils.copyProperties(promoDO, promoModel);
|
||||||
|
promoModel.setStartDate(new DateTime(promoDO.getStartDate()));
|
||||||
|
promoModel.setEndDate(new DateTime(promoDO.getEndDate()));
|
||||||
|
|
||||||
|
return promoModel;
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,10 @@ public class ItemModel {
|
|||||||
@NotBlank(message = "商品描述图片不能为空")
|
@NotBlank(message = "商品描述图片不能为空")
|
||||||
private String imgUrl;
|
private String imgUrl;
|
||||||
|
|
||||||
|
// 使用聚合模型
|
||||||
|
// 如果promoModel不为空,则表示其还有未结束的秒杀活动
|
||||||
|
private PromoModel promoModel;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -88,4 +92,12 @@ public class ItemModel {
|
|||||||
public void setImgUrl(String imgUrl) {
|
public void setImgUrl(String imgUrl) {
|
||||||
this.imgUrl = imgUrl;
|
this.imgUrl = imgUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PromoModel getPromoModel() {
|
||||||
|
return promoModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromoModel(PromoModel promoModel) {
|
||||||
|
this.promoModel = promoModel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.cxyxiaomo.flashsale.service.model;
|
|||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class PromoModel {
|
public class PromoModel {
|
||||||
|
|
||||||
@ -15,12 +14,19 @@ public class PromoModel {
|
|||||||
// 活动开始时间
|
// 活动开始时间
|
||||||
private DateTime startDate;
|
private DateTime startDate;
|
||||||
|
|
||||||
|
// 活动结束时间
|
||||||
|
private DateTime endDate;
|
||||||
|
|
||||||
// 秒杀活动适用商品
|
// 秒杀活动适用商品
|
||||||
private Integer itemId;
|
private Integer itemId;
|
||||||
|
|
||||||
// 秒杀活动的价格
|
// 秒杀活动的价格
|
||||||
private BigDecimal promoPrice;
|
private BigDecimal promoPrice;
|
||||||
|
|
||||||
|
// 秒杀活动状态
|
||||||
|
// 1:还未开始 2:进行中 3:已结束
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -45,6 +51,14 @@ public class PromoModel {
|
|||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(DateTime endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getItemId() {
|
public Integer getItemId() {
|
||||||
return itemId;
|
return itemId;
|
||||||
}
|
}
|
||||||
@ -60,4 +74,12 @@ public class PromoModel {
|
|||||||
public void setPromoPrice(BigDecimal promoPrice) {
|
public void setPromoPrice(BigDecimal promoPrice) {
|
||||||
this.promoPrice = promoPrice;
|
this.promoPrice = promoPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
<result column="promo_name" jdbcType="VARCHAR" property="promoName" />
|
<result column="promo_name" jdbcType="VARCHAR" property="promoName" />
|
||||||
<result column="start_date" jdbcType="TIMESTAMP" property="startDate" />
|
<result column="start_date" jdbcType="TIMESTAMP" property="startDate" />
|
||||||
|
<result column="end_date" jdbcType="TIMESTAMP" property="endDate" />
|
||||||
<result column="item_id" jdbcType="INTEGER" property="itemId" />
|
<result column="item_id" jdbcType="INTEGER" property="itemId" />
|
||||||
<result column="prome_item_price" jdbcType="DECIMAL" property="promeItemPrice" />
|
<result column="prome_item_price" jdbcType="DECIMAL" property="promeItemPrice" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@ -17,15 +18,15 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
id, promo_name, start_date, item_id, prome_item_price
|
id, promo_name, start_date, end_date, item_id, prome_item_price
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
@ -36,7 +37,7 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
delete from promo_info
|
delete from promo_info
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
@ -45,18 +46,20 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
insert into promo_info (id, promo_name, start_date,
|
insert into promo_info (id, promo_name, start_date,
|
||||||
item_id, prome_item_price)
|
end_date, item_id, prome_item_price
|
||||||
|
)
|
||||||
values (#{id,jdbcType=INTEGER}, #{promoName,jdbcType=VARCHAR}, #{startDate,jdbcType=TIMESTAMP},
|
values (#{id,jdbcType=INTEGER}, #{promoName,jdbcType=VARCHAR}, #{startDate,jdbcType=TIMESTAMP},
|
||||||
#{itemId,jdbcType=INTEGER}, #{promeItemPrice,jdbcType=DECIMAL})
|
#{endDate,jdbcType=TIMESTAMP}, #{itemId,jdbcType=INTEGER}, #{promeItemPrice,jdbcType=DECIMAL}
|
||||||
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="com.cxyxiaomo.flashsale.dataobject.PromoDO">
|
<insert id="insertSelective" parameterType="com.cxyxiaomo.flashsale.dataobject.PromoDO">
|
||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
insert into promo_info
|
insert into promo_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
@ -69,6 +72,9 @@
|
|||||||
<if test="startDate != null">
|
<if test="startDate != null">
|
||||||
start_date,
|
start_date,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="endDate != null">
|
||||||
|
end_date,
|
||||||
|
</if>
|
||||||
<if test="itemId != null">
|
<if test="itemId != null">
|
||||||
item_id,
|
item_id,
|
||||||
</if>
|
</if>
|
||||||
@ -86,6 +92,9 @@
|
|||||||
<if test="startDate != null">
|
<if test="startDate != null">
|
||||||
#{startDate,jdbcType=TIMESTAMP},
|
#{startDate,jdbcType=TIMESTAMP},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="endDate != null">
|
||||||
|
#{endDate,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
<if test="itemId != null">
|
<if test="itemId != null">
|
||||||
#{itemId,jdbcType=INTEGER},
|
#{itemId,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
@ -98,7 +107,7 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
update promo_info
|
update promo_info
|
||||||
<set>
|
<set>
|
||||||
@ -108,6 +117,9 @@
|
|||||||
<if test="startDate != null">
|
<if test="startDate != null">
|
||||||
start_date = #{startDate,jdbcType=TIMESTAMP},
|
start_date = #{startDate,jdbcType=TIMESTAMP},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="endDate != null">
|
||||||
|
end_date = #{endDate,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
<if test="itemId != null">
|
<if test="itemId != null">
|
||||||
item_id = #{itemId,jdbcType=INTEGER},
|
item_id = #{itemId,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
@ -121,13 +133,20 @@
|
|||||||
<!--
|
<!--
|
||||||
WARNING - @mbg.generated
|
WARNING - @mbg.generated
|
||||||
This element is automatically generated by MyBatis Generator, do not modify.
|
This element is automatically generated by MyBatis Generator, do not modify.
|
||||||
This element was generated on Sat Mar 05 12:40:27 CST 2022.
|
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||||
-->
|
-->
|
||||||
update promo_info
|
update promo_info
|
||||||
set promo_name = #{promoName,jdbcType=VARCHAR},
|
set promo_name = #{promoName,jdbcType=VARCHAR},
|
||||||
start_date = #{startDate,jdbcType=TIMESTAMP},
|
start_date = #{startDate,jdbcType=TIMESTAMP},
|
||||||
|
end_date = #{endDate,jdbcType=TIMESTAMP},
|
||||||
item_id = #{itemId,jdbcType=INTEGER},
|
item_id = #{itemId,jdbcType=INTEGER},
|
||||||
prome_item_price = #{promeItemPrice,jdbcType=DECIMAL}
|
prome_item_price = #{promeItemPrice,jdbcType=DECIMAL}
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="selectByItemId" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from promo_info
|
||||||
|
where item_id = #{itemId,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -59,9 +59,9 @@
|
|||||||
<!--<table tableName="sequence_info" domainObjectName="SequenceDO" enableCountByExample="false"-->
|
<!--<table tableName="sequence_info" domainObjectName="SequenceDO" enableCountByExample="false"-->
|
||||||
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
|
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
|
||||||
<!-- selectByExampleQueryId="false"></table>-->
|
<!-- selectByExampleQueryId="false"></table>-->
|
||||||
<table tableName="promo_info" domainObjectName="PromoDO" enableCountByExample="false"
|
<!--<table tableName="promo_info" domainObjectName="PromoDO" enableCountByExample="false"-->
|
||||||
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
|
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
|
||||||
selectByExampleQueryId="false"></table>
|
<!-- selectByExampleQueryId="false"></table>-->
|
||||||
|
|
||||||
</context>
|
</context>
|
||||||
</generatorConfiguration>
|
</generatorConfiguration>
|
Loading…
x
Reference in New Issue
Block a user