|
|
|
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
|
|
|
|
package com.cloud.kicc.system.bigscreen.controller; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
|
import cn.hutool.core.util.BooleanUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
@ -12,6 +13,8 @@ import com.cloud.kicc.system.api.bigscreen.dto.VisualProxyDto;
@@ -12,6 +13,8 @@ import com.cloud.kicc.system.api.bigscreen.dto.VisualProxyDto;
|
|
|
|
|
import com.cloud.kicc.system.api.entity.OssFile; |
|
|
|
|
import com.cloud.kicc.system.bigscreen.util.RequestUtil; |
|
|
|
|
import com.cloud.kicc.system.service.FileService; |
|
|
|
|
import com.pig4cloud.plugin.oss.OssProperties; |
|
|
|
|
import com.pig4cloud.plugin.oss.service.OssTemplate; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
@ -20,7 +23,7 @@ import org.springframework.web.bind.annotation.*;
@@ -20,7 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -40,6 +43,8 @@ import java.util.Map;
@@ -40,6 +43,8 @@ import java.util.Map;
|
|
|
|
|
public class VisualProxyController { |
|
|
|
|
|
|
|
|
|
private final FileService fileService; |
|
|
|
|
private final OssProperties ossProperties; |
|
|
|
|
private final OssTemplate ossTemplate; |
|
|
|
|
|
|
|
|
|
@RequestMapping("/proxy") |
|
|
|
|
@ApiOperation(value = "接口代理", notes = "接口代理") |
|
|
|
@ -74,16 +79,16 @@ public class VisualProxyController {
@@ -74,16 +79,16 @@ public class VisualProxyController {
|
|
|
|
|
|
|
|
|
|
@Inner(false) |
|
|
|
|
@PostMapping("/put-file") |
|
|
|
|
public R upload(@RequestPart("file") MultipartFile file) {; |
|
|
|
|
public R upload(@RequestPart("file") MultipartFile file) throws Exception { |
|
|
|
|
Map result = MapUtil.builder().build(); |
|
|
|
|
OssFile ossFile = fileService.uploadFile(file, null); |
|
|
|
|
ossFile.setAvailablePath(String.format("/visual/getFile/%s/%s", ossFile.getBucketName(), ossFile.getFileName())); |
|
|
|
|
return R.ok(ossFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Inner(false) |
|
|
|
|
@GetMapping("/getFile/{bucket}/{fileName}") |
|
|
|
|
public void getById(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) { |
|
|
|
|
fileService.getFile(bucket, fileName, response); |
|
|
|
|
String accessUrl = ossTemplate.getObjectURL(ossProperties.getBucketName(), ossFile.getFileName()); |
|
|
|
|
URL url = new URL(accessUrl); |
|
|
|
|
result.put("domain", url.getHost()); |
|
|
|
|
result.put("link", accessUrl); |
|
|
|
|
result.put("name", url.getPath()); |
|
|
|
|
result.put("originalName", ossFile.getOriginal()); |
|
|
|
|
return R.ok(url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|