示例#1
0
 @Override
 public List<Act> getActByRawAd(long rawAdId) {
   List<Act> list = new ArrayList<Act>();
   RawAd rawAd = rawAdService.getRawAd(rawAdId);
   if (rawAd == null) {
     return null;
   }
   String actIds = rawAd.getActIds();
   if (StringUtils.isEmpty(actIds)) {
     return null;
   }
   String[] ids = actIds.split(",");
   for (String id : ids) {
     long actId = 0;
     try {
       actId = Long.valueOf(id);
     } catch (Exception e) {
     }
     Act act = actService.getActById(actId);
     if (act != null) {
       list.add(act);
     }
   }
   return list;
 }
示例#2
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);
   }
 }