Esempio n. 1
0
 @Override
 public void remove(long actAdId) throws ActAdInputException {
   if (actAdId == 0) {
     throw new ActAdInputException(ActAdInputException.REMOVE_ACT_AD_IS_NOT_EXIST);
   }
   try {
     actAdMapper.deleteByPrimaryKey(actAdId);
   } catch (Exception e) {
     throw new ActAdInputException(ActAdInputException.REMOVE_ACT_AD_IS_ERROR);
   }
 }
Esempio n. 2
0
 @Override
 public List<ActAd> listActAdByActId(long actId, long cityId, int count) {
   ActAdExample example = new ActAdExample();
   com.juzhai.act.model.ActAdExample.Criteria criteria = example.createCriteria();
   criteria.andActIdEqualTo(actId);
   criteria.andEndTimeGreaterThan(new Date());
   if (cityId > 0) {
     criteria.andCityEqualTo(cityId);
   }
   example.setLimit(new Limit(0, count));
   example.setOrderByClause("sequence asc, last_modify_time desc");
   return actAdMapper.selectByExample(example);
 }
Esempio n. 3
0
 @Override
 // @Transactional
 public void createActAd(String actName, long rawAdId) throws ActAdInputException {
   Act act = actService.getActByName(actName);
   if (act == null) {
     throw new ActAdInputException(ActAdInputException.ACT_AD_NAME_IS_NOT_EXIST);
   }
   RawAd rawAd = rawAdService.getRawAd(rawAdId);
   if (rawAd == null) {
     throw new ActAdInputException(ActAdInputException.ACT_AD_RAW_AD_ID_IS_NULL);
   }
   if (isUrlExist(rawAd.getTargetUrl(), act.getId())) {
     throw new ActAdInputException(ActAdInputException.ACT_AD_URL_IS_EXIST);
   }
   try {
     ActAd actAd = rawAdIntoActAd(rawAd);
     int sequence = getAdCount(act.getId());
     actAd.setSequence((sequence + 1));
     actAd.setActId(act.getId());
     actAdMapper.insert(actAd);
     String actIds = rawAd.getActIds();
     if (StringUtils.isEmpty(actIds)) {
       rawAd.setActIds(String.valueOf(act.getId()));
     } else {
       String[] ids = actIds.split(",");
       List<String> list = new ArrayList<String>();
       for (String id : ids) {
         list.add(id);
       }
       list.add(String.valueOf(act.getId()));
       rawAd.setActIds(StringUtils.join(list, ","));
     }
     rawAd.setStatus(1);
     rawAdService.updateRawAd(rawAd);
   } catch (Exception e) {
     throw new ActAdInputException(ActAdInputException.CREATE_ACT_AD_IS_ERROR);
   }
 }
Esempio n. 4
0
 private int getAdCount(long actId) {
   ActAdExample example = new ActAdExample();
   example.createCriteria().andActIdEqualTo(actId);
   return actAdMapper.countByExample(example);
 }
Esempio n. 5
0
 @Override
 public List<ActAd> getActAds(long actId) {
   ActAdExample example = new ActAdExample();
   example.createCriteria().andActIdEqualTo(actId);
   return actAdMapper.selectByExample(example);
 }
Esempio n. 6
0
 @Override
 public boolean isUrlExist(String url, long actId) {
   ActAdExample example = new ActAdExample();
   example.createCriteria().andLinkEqualTo(url).andActIdEqualTo(actId);
   return actAdMapper.countByExample(example) > 0 ? true : false;
 }