예제 #1
0
 @Override
 public boolean add(ImageInfo imageInfo) {
   if (StringUtils.isEmpty(imageInfo.getUrl()) || StringUtils.isEmpty(imageInfo.getRefId())) {
     log.error("添加图片信息失败!" + imageInfo.toString(), null);
     return false;
   }
   List<ImageInfo> list = queryByComapny(imageInfo.getRefId());
   if (list != null && list.size() >= MAX_IMAGE) {
     log.error("添加图片信息失败!图片总数已经大于等于" + MAX_IMAGE, null);
     return false;
   }
   CompanyInfo companyInfo = companyInfoService.getObjectById(imageInfo.getRefId());
   StringBuffer str = new StringBuffer();
   str.append("INSERT INTO baiduad.image_info                ");
   str.append("(title,url,order_num,link,create_date,remark,ref_id,company_name) ");
   str.append("VALUES                                        ");
   str.append("(?,?,?,?,?,?,?,?)                                 ");
   imageInfo.setCreateDate(new Date());
   return super.add(
       str.toString(),
       imageInfo.getTitle(),
       imageInfo.getUrl(),
       Integer.valueOf(imageInfo.getOrderNum()),
       imageInfo.getLink(),
       imageInfo.getCreateDate(),
       imageInfo.getRemark(),
       imageInfo.getRefId(),
       companyInfo.getCompanyName());
 }
예제 #2
0
 @Override
 public boolean update(ImageInfo imageInfo) {
   if (StringUtils.isEmpty(imageInfo.getUrl())
       || StringUtils.isEmpty(imageInfo.getLink())
       || imageInfo.getPkId() <= 0) {
     log.error("更新图片信息失败!" + imageInfo.toString(), null);
     return false;
   }
   StringBuffer str = new StringBuffer();
   str.append("UPDATE baiduad.image_info                  ");
   str.append("SET                                        ");
   str.append("title=?,url=?,order_num=?,link=?,remark=?  ");
   str.append("WHERE                                      ");
   str.append("pk_id=?                                    ");
   return super.update(
       str.toString(),
       imageInfo.getTitle(),
       imageInfo.getUrl(),
       Integer.valueOf(imageInfo.getOrderNum()),
       imageInfo.getLink(),
       imageInfo.getRemark(),
       Integer.valueOf(imageInfo.getPkId()));
 }