コード例 #1
0
 @Override
 public List<Resource> find(FindResourceParameter parameter, String limit)
     throws BadRequestBusinessException {
   logger.debug("parameter=" + parameter);
   if (parameter.getOffset() == null || parameter.getOffset().trim().equals("")) {
     parameter.setOffset("0");
   }
   Pattern pattern = Pattern.compile("[0-9]*");
   if (!pattern.matcher(parameter.getOffset().trim()).matches()) {
     throw new BadRequestBusinessException("失败,offset不是数字");
   }
   if (limit == null || limit.trim().equals("")) {
     limit = "10";
   }
   if (!pattern.matcher(limit.trim()).matches()) {
     throw new BadRequestBusinessException("失败,limit不是大于0的数字");
   }
   int numLimit = Integer.parseInt(limit);
   if (numLimit == 0) {
     throw new BadRequestBusinessException("失败,limit必须大于0");
   }
   List<Resource> res = resourceDao.find(parameter, numLimit);
   for (Resource re : res) {
     re.setResourceUrl(Constant.IMAGE_URL_COM + re.getKeyWord());
   }
   return res;
 }
コード例 #2
0
 @Override
 public Resource findResById(String id) throws BadRequestBusinessException {
   if (id == null || "".equals(id.trim())) {
     throw new BadRequestBusinessException("失败,parameter为空");
   }
   Resource resource = resourceDao.findResById(id);
   resource.setResourceUrl(Constant.IMAGE_URL_COM + resource.getKeyWord());
   return resource;
 }
コード例 #3
0
 @Override
 public void delete(List<String> ids) throws BadRequestBusinessException {
   logger.debug("ids" + ids);
   if (ids == null || ids.isEmpty() || ids.size() == 0) {
     throw new BadRequestBusinessException("失败,parameter为空");
   }
   for (String id : ids) {
     Resource res = resourceDao.findResById(id);
     String key = res.getKeyWord();
     boolean deleteStatus = uploadService.deleteFile(key);
     if (deleteStatus) {
       resourceTagDao.deleteByResourceId(id);
       resourceDao.delete(id);
     }
   }
 }