|
|
@@ -4,6 +4,7 @@ import com.sckw.core.model.file.FileInfo;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.core.web.response.Result;
|
|
|
+import com.sckw.core.web.response.Status;
|
|
|
import com.sckw.file.api.dto.FileInfoDTO;
|
|
|
import com.sckw.file.service.FileService;
|
|
|
import com.sckw.file.service.dubbo.FileDubboApiServiceImpl;
|
|
|
@@ -27,7 +28,6 @@ import java.util.Map;
|
|
|
* @version 1.0
|
|
|
* @className FileApiController
|
|
|
* @description alibaba-oss测试用例
|
|
|
- *
|
|
|
* @company sckw
|
|
|
* @date 2023-06-02 16:06:43
|
|
|
*/
|
|
|
@@ -55,14 +55,15 @@ public class FileApiController {
|
|
|
//获取上传文件
|
|
|
return fileService.uploadFile(file);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("文件上传失败:{}",e.getMessage(),e);
|
|
|
- return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE,e.getMessage());
|
|
|
+ log.error("文件上传失败:{}", e.getMessage(), e);
|
|
|
+ return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量上传文件至OSS
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -75,29 +76,31 @@ public class FileApiController {
|
|
|
|
|
|
/**
|
|
|
* OSS下载文件/获取文件地址
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/fileDownload",method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/fileDownload", method = RequestMethod.GET)
|
|
|
public HttpResult fileDownload(@NotBlank @RequestParam("fileName") String fileName) {
|
|
|
try {
|
|
|
fileService.fileDownload(fileName);
|
|
|
return HttpResult.ok();
|
|
|
} catch (Exception e) {
|
|
|
- log.error("文件下载失败:{}",e.getMessage(),e);
|
|
|
- return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE,e.getMessage());
|
|
|
+ log.error("文件下载失败:{}", e.getMessage(), e);
|
|
|
+ return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* oss删除文件
|
|
|
- * @param fileName https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230621/07ccbec381a011d121a215719199ac49.html
|
|
|
+ *
|
|
|
+ * @param fileName https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/kll/uploads/20230621/07ccbec381a011d121a215719199ac49.html
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/remove",method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/remove", method = RequestMethod.GET)
|
|
|
public HttpResult remove(String fileName) {
|
|
|
//获取上传文件
|
|
|
fileService.remove(fileName);
|
|
|
- return HttpResult.ok(HttpStatus.SUCCESS_CODE,HttpStatus.SUCCESS_MESSAGE);
|
|
|
+ return HttpResult.ok(HttpStatus.SUCCESS_CODE, HttpStatus.SUCCESS_MESSAGE);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
@@ -110,32 +113,45 @@ public class FileApiController {
|
|
|
@RequestMapping("downAllOssFile")
|
|
|
@ResponseBody
|
|
|
public HttpResult downAllOssFile(@RequestParam("fileAllName") String fileAllName, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- return fileService.downAllOssFile(fileAllName,request,response);
|
|
|
+ return fileService.downAllOssFile(fileAllName, request, response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 前端调用接口获取oss信息-使用中
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/uploadFileInfo", method = RequestMethod.POST)
|
|
|
public HttpResult uploadFileInfo(@RequestParam("file") MultipartFile file) {
|
|
|
- return fileService.uploadFileInfo(file);
|
|
|
+ try {
|
|
|
+ return fileService.uploadFileInfo(file);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("上传文件失败:{}",e.getMessage(),e);
|
|
|
+ return HttpResult.error("上传文件失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* app-前端调用接口上传oss
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/appUploadFileInfo", method = RequestMethod.POST)
|
|
|
public Result appUploadFileInfo(@RequestParam("file") MultipartFile file) {
|
|
|
- return fileService.appUploadFileInfo(file);
|
|
|
+ try {
|
|
|
+ return fileService.appUploadFileInfo(file);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("上传文件失败:{}",e.getMessage(),e);
|
|
|
+ return Result.build(Status.FAILURE,"上传文件失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* dubbo接收文件信息保存至数据库
|
|
|
+ *
|
|
|
* @param fileInfo
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -151,13 +167,14 @@ public class FileApiController {
|
|
|
|
|
|
/**
|
|
|
* dubbo接收上传文件至OSS
|
|
|
+ *
|
|
|
* @param inputStream
|
|
|
* @param FileInfoDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/fileDubboUpload", method = RequestMethod.POST)
|
|
|
public HttpResult fileDubboUpload(InputStream inputStream, FileInfoDTO FileInfoDTO) {
|
|
|
- return fileService.fileDubboUpload(inputStream,FileInfoDTO);
|
|
|
+ return fileService.fileDubboUpload(inputStream, FileInfoDTO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -173,6 +190,7 @@ public class FileApiController {
|
|
|
|
|
|
/**
|
|
|
* file-feign-demo
|
|
|
+ *
|
|
|
* @param userName
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -184,10 +202,11 @@ public class FileApiController {
|
|
|
|
|
|
/**
|
|
|
* file-feign-demo1
|
|
|
+ *
|
|
|
* @param map
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "fileFeignDemo1",method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "fileFeignDemo1", method = RequestMethod.POST)
|
|
|
public HttpResult fileFeignDemo1(@RequestBody Map<String, String> map) {
|
|
|
return HttpResult.ok(map);
|
|
|
}
|