@Override public int delete(Long id) { return flashPromotionMapper.deleteByPrimaryKey(id); }
@Override public SmsFlashPromotion getItem(Long id) { return flashPromotionMapper.selectByPrimaryKey(id); }
@Override public int update(Long id, SmsFlashPromotion flashPromotion) { flashPromotion.setId(id); return flashPromotionMapper.updateByPrimaryKey(flashPromotion); }
@Override public List<SmsFlashPromotion> list(String keyword, Integer pageSize, Integer pageNum) { PageHelper.startPage(pageNum, pageSize); SmsFlashPromotionExample example = new SmsFlashPromotionExample(); if (!StringUtils.isEmpty(keyword)) { example.createCriteria().andTitleLike("%" + keyword + "%"); } return flashPromotionMapper.selectByExample(example); } }
@Override public int create(SmsFlashPromotion flashPromotion) { flashPromotion.setCreateTime(new Date()); return flashPromotionMapper.insert(flashPromotion); }
@Override public int updateStatus(Long id, Integer status) { SmsFlashPromotion flashPromotion = new SmsFlashPromotion(); flashPromotion.setId(id); flashPromotion.setStatus(status); return flashPromotionMapper.updateByPrimaryKeySelective(flashPromotion); }
private SmsFlashPromotion getFlashPromotion(Date date) { Date currDate = DateUtil.getDate(date); SmsFlashPromotionExample example = new SmsFlashPromotionExample(); example.createCriteria() .andStatusEqualTo(1) .andStartDateLessThanOrEqualTo(currDate) .andEndDateGreaterThanOrEqualTo(currDate); List<SmsFlashPromotion> flashPromotionList = flashPromotionMapper.selectByExample(example); if (!CollectionUtils.isEmpty(flashPromotionList)) { return flashPromotionList.get(0); } return null; }