Skip to content

Commit 403d9c5

Browse files
authored
🆕 #2665【企业微信】增加微盘文件权限相关接口
1 parent f83c55c commit 403d9c5

File tree

6 files changed

+101
-1
lines changed

6 files changed

+101
-1
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,36 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
249249
*/
250250
WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException;
251251

252+
/**
253+
* 分享设置
254+
* 该接口用于文件的分享设置。
255+
* <p>
256+
* 请求方式:POST(HTTPS)
257+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN
258+
*
259+
* @param userId
260+
* @param fileId
261+
* @param authScope
262+
* @param auth
263+
* @return
264+
* @throws WxErrorException
265+
*/
266+
WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException;
267+
268+
/**
269+
* 获取分享链接
270+
* 该接口用于获取文件的分享链接。
271+
* <p>
272+
* 请求方式:POST(HTTPS)
273+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN
274+
*
275+
* @param userId
276+
* @param fileId
277+
* @return
278+
* @throws WxErrorException
279+
*/
280+
WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException;
281+
252282
/**
253283
* 文件信息
254284
* 该接口用于获取指定文件的信息。

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ public WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws Wx
167167
return WxCpBaseResp.fromJson(responseContent);
168168
}
169169

170+
@Override
171+
public WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException {
172+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SETTING);
173+
JsonObject jsonObject = new JsonObject();
174+
jsonObject.addProperty("userid", userId);
175+
jsonObject.addProperty("fileid", fileId);
176+
jsonObject.addProperty("auth_scope", authScope);
177+
if (auth != null) {
178+
jsonObject.addProperty("auth", auth);
179+
}
180+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
181+
return WxCpBaseResp.fromJson(responseContent);
182+
}
183+
184+
@Override
185+
public WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
186+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SHARE);
187+
JsonObject jsonObject = new JsonObject();
188+
jsonObject.addProperty("userid", userId);
189+
jsonObject.addProperty("fileid", fileId);
190+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
191+
return WxCpFileShare.fromJson(responseContent);
192+
}
193+
170194
@Override
171195
public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
172196
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.chanjar.weixin.cp.bean.oa.wedrive;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* 获取分享链接返回信息.
12+
*
13+
* @author Wang_Wong
14+
*/
15+
@Data
16+
public class WxCpFileShare extends WxCpBaseResp implements Serializable {
17+
private static final long serialVersionUID = -5028321625142879581L;
18+
19+
@SerializedName("share_url")
20+
private String shareUrl;
21+
22+
public static WxCpFileShare fromJson(String json) {
23+
return WxCpGsonBuilder.create().fromJson(json, WxCpFileShare.class);
24+
}
25+
26+
public String toJson() {
27+
return WxCpGsonBuilder.create().toJson(this);
28+
}
29+
30+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ interface Oa {
163163
String FILE_INFO = "/cgi-bin/wedrive/file_info";
164164
String FILE_ACL_ADD = "/cgi-bin/wedrive/file_acl_add";
165165
String FILE_ACL_DEL = "/cgi-bin/wedrive/file_acl_del";
166+
String FILE_SETTING = "/cgi-bin/wedrive/file_setting";
167+
String FILE_SHARE = "/cgi-bin/wedrive/file_share";
166168

167169
/**
168170
* 审批流程引擎

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ public void test() throws Exception {
4949
String fileId = "s.ww45d3e188865aca30.652091685u4h_f.652344507ysDL";
5050
String fileId2 = "s.ww45d3e188865aca30.652091685u4h_f.652696024TU4P";
5151

52+
53+
/**
54+
* 获取分享链接
55+
*/
56+
WxCpFileShare fileShare = cpService.getOaWeDriveService().fileShare(uId, fileId2);
57+
log.info("获取分享链接返回结果为:{}", fileShare.toJson());
58+
59+
/**
60+
* 分享设置
61+
*/
62+
WxCpBaseResp fileSetting = cpService.getOaWeDriveService().fileSetting(uId, fileId2, 2, 1);
63+
log.info("分享设置返回结果为:{}", fileSetting.toJson());
64+
5265
/**
5366
* 删除指定人
5467
*/

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
*
1212
* 接口A(createWxaCode)加上接口C(createQrcode),总共生成的码数量限制为100,000,请谨慎调用。
1313
*
14-
* 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
14+
* 文档地址1:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
15+
* 文档地址2:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
1516
* </pre>
1617
*
1718
* @author <a href="https://github.com/binarywang">Binary Wang</a>

0 commit comments

Comments
 (0)