|
@@ -6,8 +6,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.dmp.common.utils.ResourceUtil;
|
|
|
import com.persagy.dmp.common.utils.ResultHelper;
|
|
|
import com.persagy.dmp.file.service.CompatibleOldFileService;
|
|
|
+import com.persagy.dmp.file.utils.FileStorageHelper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -15,6 +17,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.Charset;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/***
|
|
|
* Description: 兼容旧的文件服务接口
|
|
@@ -22,7 +25,7 @@ import java.nio.charset.Charset;
|
|
|
* @date :2021/11/18 10:06
|
|
|
* Update By lijie 2021/11/18 10:06
|
|
|
*/
|
|
|
-@RestController
|
|
|
+@Controller
|
|
|
@RequiredArgsConstructor
|
|
|
public class CompatibleOldFileController {
|
|
|
|
|
@@ -67,9 +70,10 @@ public class CompatibleOldFileController {
|
|
|
* @date :2021/11/19 9:58
|
|
|
* Update By lijie 2021/11/19 9:58
|
|
|
*/
|
|
|
- @PostMapping(value = "/common/file_upload",produces = {MediaType.APPLICATION_JSON})
|
|
|
- public void fileUpload(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- response.getWriter().write(compatibleOldFileService.uploadFile(request.getInputStream(),response));
|
|
|
+ @PostMapping(value = "/common/file_upload")
|
|
|
+ @ResponseBody
|
|
|
+ public String fileUpload(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ return compatibleOldFileService.uploadFile(request.getInputStream(),response);
|
|
|
}
|
|
|
/***
|
|
|
* Description: 图片上传
|
|
@@ -78,9 +82,10 @@ public class CompatibleOldFileController {
|
|
|
* @date :2021/11/19 9:58
|
|
|
* Update By lijie 2021/11/19 9:58
|
|
|
*/
|
|
|
- @PostMapping(value = "/common/image_upload",produces = {MediaType.APPLICATION_JSON},consumes = {"image/jpg"})
|
|
|
- public void imageUpload(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- response.getWriter().write(compatibleOldFileService.uploadFile(request.getInputStream(),response));
|
|
|
+ @PostMapping(value = "/common/image_upload",consumes = {"image/jpg"})
|
|
|
+ @ResponseBody
|
|
|
+ public String imageUpload(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ return compatibleOldFileService.uploadFile(request.getInputStream(),response);
|
|
|
}
|
|
|
/***
|
|
|
* Description: 图片下载
|
|
@@ -89,9 +94,10 @@ public class CompatibleOldFileController {
|
|
|
* @date :2021/11/19 9:58
|
|
|
* Update By lijie 2021/11/19 9:58
|
|
|
*/
|
|
|
- @GetMapping(value = "/common/image_get",produces = {"image/jpg"})
|
|
|
+ @GetMapping(value = "/common/image_get")
|
|
|
public void imageGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
compatibleOldFileService.getFile(request,response);
|
|
|
+ response.setContentType("image/jpg");
|
|
|
}
|
|
|
/***
|
|
|
* Description: 图片下载
|
|
@@ -100,9 +106,10 @@ public class CompatibleOldFileController {
|
|
|
* @date :2021/11/19 9:58
|
|
|
* Update By lijie 2021/11/19 9:58
|
|
|
*/
|
|
|
- @GetMapping(value = "/common/svg_get",produces = {"image/svg+xml"})
|
|
|
+ @GetMapping(value = "/common/svg_get")
|
|
|
public void imageSvgGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
compatibleOldFileService.getFile(request,response);
|
|
|
+ response.setContentType("image/svg+xml");
|
|
|
}
|
|
|
/***
|
|
|
* Description: 图片下载
|
|
@@ -111,9 +118,16 @@ public class CompatibleOldFileController {
|
|
|
* @date :2021/11/19 9:58
|
|
|
* Update By lijie 2021/11/19 9:58
|
|
|
*/
|
|
|
- @GetMapping(value = "/common/images_list",produces = {MediaType.APPLICATION_JSON})
|
|
|
- public void imagesList(@RequestBody(required = false) JSONObject param, HttpServletResponse response) throws IOException {
|
|
|
- compatibleOldFileService.listFiles(param,response);
|
|
|
+ @PostMapping(value = "/common/images_list")
|
|
|
+ @ResponseBody
|
|
|
+ public JSONObject imagesList(@RequestBody(required = false) JSONObject param) throws IOException {
|
|
|
+ List<String> fileIds = compatibleOldFileService.listFiles(param);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("result", "success");
|
|
|
+ result.put("Count", (long)fileIds.size());
|
|
|
+ result.put("Content", fileIds);
|
|
|
+ result.put("ResultMsg", "");
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|