RemoteFileService.java
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.bs.fileservice.feign;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.FileEntity;
import com.bs.common.core.domain.model.ScreenshotRequest;
import com.bs.common.core.domain.model.ScreenshotResponse;
import com.bs.fileservice.feign.factory.RemoteFileServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
/**
* 文件服务远程调用接口
* <p>
* 对应 bs-fileservice 的 FileController 对外接口。
* 调用方使用方式:
* <pre>
* @Resource
* private RemoteFileService remoteFileService;
* </pre>
* 启动类需确保扫描到本包:@EnableFeignClients(basePackages = "com.bs.**")
*
* @author system
*/
@FeignClient(
name = "bs-fileservice",
contextId = "remoteFileService",
path = "/fileservice",
fallbackFactory = RemoteFileServiceFallbackFactory.class
)
public interface RemoteFileService {
/**
* 文件上传
*
* @param file 文件
* @return 上传结果,data 为文件信息
*/
@PostMapping(value = "upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
AjaxResult<FileEntity> upload(@RequestPart("file") MultipartFile file);
/**
* 视频抽帧(获取视频第一帧图片)
*
* @param url 视频地址
* @return 抽帧结果,data 包含 name/url/height/width/memorySize/pixelSize
*/
@GetMapping("getVideoFirstImg")
AjaxResult<Map<String, Object>> getVideoFirstImg(@RequestParam("url") String url);
/**
* 获取腾讯云/阿里云 OSS 上传参数
*
* @return 配置信息(加密后返回)
*/
@GetMapping("/get/config")
AjaxResult<Map<String, Object>> getCosConfig();
/**
* 获取 STS 临时授权凭证
*
* @return STS 凭证信息(加密后返回)
*/
@GetMapping("/get/stsConfig")
AjaxResult<Map<String, Object>> getCosStsConfig();
/**
* 网页截图
*
* @param request 截图请求
* @return 截图结果
*/
@PostMapping("/screenshot")
AjaxResult<ScreenshotResponse> screenshot(@RequestBody ScreenshotRequest request);
/**
* 网页转 PDF
*
* @param request 请求
* @return 转换结果
*/
@PostMapping("/pdf")
AjaxResult<ScreenshotResponse> pdf(@RequestBody ScreenshotRequest request);
}