Commit 4b55c08b by Your Name

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

parent 139e0f44
...@@ -31,7 +31,7 @@ public class OSSController { ...@@ -31,7 +31,7 @@ public class OSSController {
private OSSService ossService; private OSSService ossService;
/** /**
* 上传普通文 * 上传
* *
* @param userBean * @param userBean
* @param moudle * @param moudle
...@@ -39,11 +39,26 @@ public class OSSController { ...@@ -39,11 +39,26 @@ public class OSSController {
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
@ResponseBody @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); Result<String> data = ossService.upload(userBean.getOrgCode(), moudle, file);
return data; 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; ...@@ -13,6 +13,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/** /**
* 上传文件的实现层 * 上传文件的实现层
...@@ -23,6 +24,8 @@ public class OSSService implements OSSServiceImpl { ...@@ -23,6 +24,8 @@ public class OSSService implements OSSServiceImpl {
@Autowired @Autowired
private OSSUtil oss; private OSSUtil oss;
private static ReentrantLock lock= new ReentrantLock();
/** /**
* *
* @param orgCode * @param orgCode
...@@ -32,6 +35,7 @@ public class OSSService implements OSSServiceImpl { ...@@ -32,6 +35,7 @@ public class OSSService implements OSSServiceImpl {
*/ */
@Override @Override
public Result<String> upload(int orgCode, String moudle, MultipartFile file) { public Result<String> upload(int orgCode, String moudle, MultipartFile file) {
lock.lock();
String url = null; String url = null;
String randomNickname = RandomNum.getRandomNickname(); String randomNickname = RandomNum.getRandomNickname();
File filePath = filePathUpload(orgCode, moudle, randomNickname, file.getOriginalFilename()); File filePath = filePathUpload(orgCode, moudle, randomNickname, file.getOriginalFilename());
...@@ -41,6 +45,7 @@ public class OSSService implements OSSServiceImpl { ...@@ -41,6 +45,7 @@ public class OSSService implements OSSServiceImpl {
i++; i++;
} }
if (file == null || file.getSize() <= 0) { if (file == null || file.getSize() <= 0) {
lock.unlock();
return ResultUtil.error("上传的文件为空,请重新选择!"); return ResultUtil.error("上传的文件为空,请重新选择!");
} else { } else {
try { try {
...@@ -48,6 +53,7 @@ public class OSSService implements OSSServiceImpl { ...@@ -48,6 +53,7 @@ public class OSSService implements OSSServiceImpl {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
lock.unlock();
return ResultUtil.data(url, "上传成功!"); 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