Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【企业微信】增加支持微盘文件权限接口 #2665

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,36 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
*/
WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException;

/**
* 分享设置
* 该接口用于文件的分享设置。
* <p>
* 请求方式:POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN
*
* @param userId
* @param fileId
* @param authScope
* @param auth
* @return
* @throws WxErrorException
*/
WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException;

/**
* 获取分享链接
* 该接口用于获取文件的分享链接。
* <p>
* 请求方式:POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN
*
* @param userId
* @param fileId
* @return
* @throws WxErrorException
*/
WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException;

/**
* 文件信息
* 该接口用于获取指定文件的信息。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ public WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws Wx
return WxCpBaseResp.fromJson(responseContent);
}

@Override
public WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SETTING);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("userid", userId);
jsonObject.addProperty("fileid", fileId);
jsonObject.addProperty("auth_scope", authScope);
if (auth != null) {
jsonObject.addProperty("auth", auth);
}
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
return WxCpBaseResp.fromJson(responseContent);
}

@Override
public WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_SHARE);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("userid", userId);
jsonObject.addProperty("fileid", fileId);
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
return WxCpFileShare.fromJson(responseContent);
}

@Override
public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package me.chanjar.weixin.cp.bean.oa.wedrive;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;

/**
* 获取分享链接返回信息.
*
* @author Wang_Wong
*/
@Data
public class WxCpFileShare extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = -5028321625142879581L;

@SerializedName("share_url")
private String shareUrl;

public static WxCpFileShare fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpFileShare.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ interface Oa {
String FILE_INFO = "/cgi-bin/wedrive/file_info";
String FILE_ACL_ADD = "/cgi-bin/wedrive/file_acl_add";
String FILE_ACL_DEL = "/cgi-bin/wedrive/file_acl_del";
String FILE_SETTING = "/cgi-bin/wedrive/file_setting";
String FILE_SHARE = "/cgi-bin/wedrive/file_share";

/**
* 审批流程引擎
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public void test() throws Exception {
String fileId = "s.ww45d3e188865aca30.652091685u4h_f.652344507ysDL";
String fileId2 = "s.ww45d3e188865aca30.652091685u4h_f.652696024TU4P";


/**
* 获取分享链接
*/
WxCpFileShare fileShare = cpService.getOaWeDriveService().fileShare(uId, fileId2);
log.info("获取分享链接返回结果为:{}", fileShare.toJson());

/**
* 分享设置
*/
WxCpBaseResp fileSetting = cpService.getOaWeDriveService().fileSetting(uId, fileId2, 2, 1);
log.info("分享设置返回结果为:{}", fileSetting.toJson());

/**
* 删除指定人
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*
* 接口A(createWxaCode)加上接口C(createQrcode),总共生成的码数量限制为100,000,请谨慎调用。
*
* 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
* 文档地址1:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
* 文档地址2:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
Expand Down