🆕 #2656【企业微信】增加微盘文件管理部分接口

This commit is contained in:
0katekate0 2022-05-22 21:16:10 +08:00 committed by GitHub
parent 9517292a0e
commit 1fdfd5c5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 208 additions and 0 deletions

View File

@ -223,6 +223,32 @@ public interface WxCpOaWeDriveService {
*/
WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List<String> fileId) throws WxErrorException;
/**
* 新增指定人
* 该接口用于对指定文件添加指定人/部门
* <p>
* 请求方式POSTHTTPS
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN
*
* @param request 新增指定人请求参数
* @return
* @throws WxErrorException
*/
WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException;
/**
* 删除指定人
* 该接口用于删除指定文件的指定人/部门
* <p>
* 请求方式POSTHTTPS
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN
*
* @param request 请求参数
* @return
* @throws WxErrorException
*/
WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException;
/**
* 文件信息
* 该接口用于获取指定文件的信息

View File

@ -153,6 +153,20 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService {
return WxCpBaseResp.fromJson(responseContent);
}
@Override
public WxCpBaseResp fileAclAdd(@NonNull WxCpFileAclAddRequest request) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_ADD);
String responseContent = this.cpService.post(apiUrl, request.toJson());
return WxCpBaseResp.fromJson(responseContent);
}
@Override
public WxCpBaseResp fileAclDel(@NonNull WxCpFileAclDelRequest request) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_ACL_DEL);
String responseContent = this.cpService.post(apiUrl, request.toJson());
return WxCpBaseResp.fromJson(responseContent);
}
@Override
public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO);

View File

@ -0,0 +1,66 @@
package me.chanjar.weixin.cp.bean.oa.wedrive;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import lombok.experimental.Accessors;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 新增指定人请求参数.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxCpFileAclAddRequest implements Serializable {
private static final long serialVersionUID = -4960239393895754138L;
@SerializedName("userid")
private String userId;
@SerializedName("fileid")
private String fileId;
@SerializedName("auth_info")
private List<AuthInfo> authInfo;
@Getter
@Setter
public static class AuthInfo implements Serializable {
private static final long serialVersionUID = -4960239393895754598L;
@SerializedName("type")
private Integer type;
@SerializedName("departmentid")
private Integer departmentId;
@SerializedName("auth")
private Integer auth;
@SerializedName("userid")
private String userId;
public static AuthInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, AuthInfo.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
public static WxCpFileAclAddRequest fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpFileAclAddRequest.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@ -0,0 +1,63 @@
package me.chanjar.weixin.cp.bean.oa.wedrive;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import lombok.experimental.Accessors;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 删除指定人请求参数.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxCpFileAclDelRequest implements Serializable {
private static final long serialVersionUID = -4960239393895754138L;
@SerializedName("userid")
private String userId;
@SerializedName("fileid")
private String fileId;
@SerializedName("auth_info")
private List<AuthInfo> authInfo;
@Getter
@Setter
public static class AuthInfo implements Serializable {
private static final long serialVersionUID = -4960239393895754598L;
@SerializedName("type")
private Integer type;
@SerializedName("departmentid")
private Integer departmentId;
@SerializedName("userid")
private String userId;
public static AuthInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, AuthInfo.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
public static WxCpFileAclDelRequest fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpFileAclDelRequest.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@ -161,6 +161,8 @@ public interface WxCpApiPathConsts {
String FILE_MOVE = "/cgi-bin/wedrive/file_move";
String FILE_DELETE = "/cgi-bin/wedrive/file_delete";
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";
/**
* 审批流程引擎

View File

@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.api;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.oa.wedrive.*;
@ -48,6 +49,42 @@ public class WxCpOaWeDriveServiceTest {
String fileId = "s.ww45d3e188865aca30.652091685u4h_f.652344507ysDL";
String fileId2 = "s.ww45d3e188865aca30.652091685u4h_f.652696024TU4P";
/**
* 删除指定人
*/
WxCpFileAclDelRequest aclDelRequest = new WxCpFileAclDelRequest();
aclDelRequest.setUserId(uId);
aclDelRequest.setFileId(fileId2);
ArrayList<WxCpFileAclDelRequest.AuthInfo> aclDelList = Lists.newArrayList();
WxCpFileAclDelRequest.AuthInfo aclDelAuthInfo = new WxCpFileAclDelRequest.AuthInfo();
aclDelAuthInfo.setType(1);
aclDelAuthInfo.setUserId(uId);
aclDelList.add(aclDelAuthInfo);
aclDelRequest.setAuthInfo(aclDelList);
WxCpBaseResp aclDel = cpService.getOaWeDriveService().fileAclDel(aclDelRequest);
log.info("删除指定人返回结果为:{}", aclDel.toJson());
/**
* 新增指定人
*/
WxCpFileAclAddRequest fileAclAdd = new WxCpFileAclAddRequest();
fileAclAdd.setUserId(uId);
fileAclAdd.setFileId(fileId2);
var authInfoData = new WxCpFileAclAddRequest.AuthInfo();
authInfoData.setType(1);
authInfoData.setAuth(1);
authInfoData.setUserId(uId);
ArrayList<WxCpFileAclAddRequest.AuthInfo> authList = Lists.newArrayList();
authList.add(authInfoData);
fileAclAdd.setAuthInfo(authList);
WxCpBaseResp result = cpService.getOaWeDriveService().fileAclAdd(fileAclAdd);
log.info("返回结果为:{}", result.toJson());
/**
* 删除文件