@Log(message="删除了{0}条资源。")
@RequiresPermissions("Resource:delete")
@RequestMapping(value="/delete", method=RequestMethod.POST)
public @ResponseBody String deleteMany(Long[] ids, HttpServletRequest request) {
AjaxObject ajaxObject = new AjaxObject("删除资源成功!");
for (Long id : ids) {
Resource resource = resourceService.get(id);
if (resource.getStoreType().equals(StoreType.FILE)) {
String storePath = getFileStorePath(request);
String filePath = storePath + File.separator + resource.getRealStoreName();
File file = new File(filePath);
if (file.exists()) {
try {
org.apache.commons.io.FileUtils.forceDelete(file);
} catch (IOException e) {
//LOG.error("强制删除文件:" + resource.getName() + "失败。");
return AjaxObject.newError(resource.getName() + "文件删除失败,请稍后再试。")
.setCallbackType("").toString();
}
}
}
resourceService.delete(id);
}
LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{ids.length}));
ajaxObject.setCallbackType("");
return ajaxObject.toString();
}