Commit d64e9ab8 by Your Name Committed by chenzg

更新讯息列表文件不能下载问题

parent 9bc1ac79
......@@ -31,7 +31,7 @@ public class OSSController {
private OSSService ossService;
/**
* 上传普通文
* 上传
*
* @param userBean
* @param moudle
......@@ -39,11 +39,26 @@ public class OSSController {
@PostMapping(value = "/upload")
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
@ResponseBody
public Result<String> upload(@CurrentUser UserBean userBean, @RequestParam(required = false) String moudle,@RequestParam("filename") MultipartFile file) throws Exception {
public Result<String> upload(@CurrentUser UserBean userBean, @RequestParam(required = false) String moudle,@Param("file") MultipartFile file) throws Exception {
Result<String> data = ossService.upload(userBean.getOrgCode(), moudle, file);
return data;
}
/**
* 上传审批文件
*
* @param userBean
* @param moudle
*/
@PostMapping(value = "/approveUpload")
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
@ResponseBody
public Result<String> approveUpload(@CurrentUser UserBean userBean, @RequestParam(required = false) String moudle,@RequestParam("filename") MultipartFile file) throws Exception {
Result<String> data = ossService.upload(userBean.getOrgCode(), moudle, file);
return data;
}
/**
* 批量上传普通文件
......
......@@ -13,6 +13,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* 上传文件的实现层
......@@ -23,6 +24,8 @@ public class OSSService implements OSSServiceImpl {
@Autowired
private OSSUtil oss;
private static ReentrantLock lock= new ReentrantLock();
/**
*
* @param orgCode
......@@ -32,6 +35,7 @@ public class OSSService implements OSSServiceImpl {
*/
@Override
public Result<String> upload(int orgCode, String moudle, MultipartFile file) {
lock.lock();
String url = null;
String randomNickname = RandomNum.getRandomNickname();
File filePath = filePathUpload(orgCode, moudle, randomNickname, file.getOriginalFilename());
......@@ -41,6 +45,7 @@ public class OSSService implements OSSServiceImpl {
i++;
}
if (file == null || file.getSize() <= 0) {
lock.unlock();
return ResultUtil.error("上传的文件为空,请重新选择!");
} else {
try {
......@@ -48,6 +53,7 @@ public class OSSService implements OSSServiceImpl {
} catch (IOException e) {
e.printStackTrace();
}
lock.unlock();
return ResultUtil.data(url, "上传成功!");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment