Commit 177d78ee by zhanghj

V1.4.0--增加批量删除照片功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@23341 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 42acbc08
...@@ -64,4 +64,8 @@ public class Constants { ...@@ -64,4 +64,8 @@ public class Constants {
* 验证码短信source * 验证码短信source
*/ */
public static final String SMS_VERIFY_CODE_SOURCE = "sms.verify.code.source"; public static final String SMS_VERIFY_CODE_SOURCE = "sms.verify.code.source";
/**
* 分隔符
*/
public static final String SEPARATOR = ",";
} }
...@@ -11,6 +11,7 @@ import org.slf4j.Logger; ...@@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.github.pagehelper.util.StringUtil; import com.github.pagehelper.util.StringUtil;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultCodeEnum; import com.glsx.common.constants.ResultCodeEnum;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.PropertiesUtil; import com.glsx.common.utils.PropertiesUtil;
...@@ -74,7 +76,6 @@ public class CommonController { ...@@ -74,7 +76,6 @@ public class CommonController {
} }
} }
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST) @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public ResultObject uploadImage(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException { public ResultObject uploadImage(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
String path = FastDFSClientWrapper.uploadFile(file); String path = FastDFSClientWrapper.uploadFile(file);
...@@ -86,10 +87,30 @@ public class CommonController { ...@@ -86,10 +87,30 @@ public class CommonController {
@RequestMapping(value = "/deleteFile", method = RequestMethod.POST) @RequestMapping(value = "/deleteFile", method = RequestMethod.POST)
public ResultObject deleteFile(@RequestParam("fileUrl") String fileUrl, HttpServletRequest request) throws IOException { public ResultObject deleteFile(@RequestParam("fileUrl") String fileUrl, HttpServletRequest request) throws IOException {
logger.info("删除文件路径==" + fileUrl); logger.info("删除文件路径==" + fileUrl);
if (StringUtils.isEmpty(fileUrl)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
FastDFSClientWrapper.deleteFile(fileUrl); FastDFSClientWrapper.deleteFile(fileUrl);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} }
@RequestMapping(value = "/deleteFiles", method = RequestMethod.POST)
public ResultObject deleteFiles(@RequestParam("fileUrls") String fileUrls, HttpServletRequest request){
logger.info("删除文件路径==" + fileUrls);
if (StringUtils.isEmpty(fileUrls)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
String[] fileArray = fileUrls.split(Constants.SEPARATOR);
for (String fileUrl : fileArray) {
try {
FastDFSClientWrapper.deleteFile(fileUrl);
} catch (Exception e) {
logger.error("批量删除文件失败,fileUrl=" + fileUrl, e);
}
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@RequestMapping(value = "/uploadQRImage", method = RequestMethod.POST) @RequestMapping(value = "/uploadQRImage", method = RequestMethod.POST)
public ResultObject uploadQRImage(@RequestBody byte[] bytes) throws IOException { public ResultObject uploadQRImage(@RequestBody byte[] bytes) throws IOException {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!