WeMediaClient.java
2.01 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
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;
import com.linkwechat.wecom.domain.dto.GroupWelcomeTplDto;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.interceptor.WeAccessTokenFileInterceptor;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
/**
* 素材管理
* @Author: Robin
* @Description:
* @Date: create in 2020/9/24 0024 0:14
*/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenFileInterceptor.class)
public interface WeMediaClient {
/**
* 上传图片
* @param multipartFile
* @return
*/
@Post(url="/media/uploadimg")
WeMediaDto uploadimg(@DataFile(value = "fieldNameHere") MultipartFile multipartFile);
/**
* 上传临时素材
* Inputstream 对象
* 使用byte数组和Inputstream对象时一定要定义fileName属性
*/
@Post(url = "/media/upload")
WeMediaDto upload(@DataFile(value = "media", fileName = "${1}") InputStream file, String filename, @Query("type") String type);
/**
* 上传附件资源
* Inputstream 对象
* 使用byte数组和Inputstream对象时一定要定义fileName属性
*/
@Post(url = "/media/upload_attachment")
WeMediaDto uploadAttachment(@DataFile(value = "media", fileName = "${1}") InputStream file, String filename, @Query("media_type") String mediaType, @Query("attachment_type") Integer attachmentType);
/**
* 获取临时素材
*
* @param mediaId 素材id
* @return
*/
@GetRequest(url = "/media/get")
ForestResponse getMediaToResponse(@Query("media_id") String mediaId);
/**
* 下载临时素材
* Inputstream 对象
*
*/
@Get(url = "/media/get")
InputStream mediaGet(@Query("media_id") String media_id);
}