🆕 #2637【企业微信】新增微盘获取空间信息的接口
This commit is contained in:
@@ -3,9 +3,7 @@ package me.chanjar.weixin.cp.api;
|
||||
import lombok.NonNull;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateData;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceRenameRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.*;
|
||||
|
||||
/**
|
||||
* 企业微信微盘相关接口.
|
||||
@@ -25,7 +23,6 @@ public interface WxCpOaWeDriveService {
|
||||
*
|
||||
* @param request 新建空间对应请求参数
|
||||
* @return spaceid(空间id)
|
||||
*
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException;
|
||||
@@ -33,7 +30,7 @@ public interface WxCpOaWeDriveService {
|
||||
/**
|
||||
* 重命名空间
|
||||
* 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。
|
||||
*
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN
|
||||
*
|
||||
@@ -46,7 +43,7 @@ public interface WxCpOaWeDriveService {
|
||||
/**
|
||||
* 解散空间
|
||||
* 该接口用于解散已有空间,需要以空间管理员身份来解散。
|
||||
*
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN
|
||||
*
|
||||
@@ -57,4 +54,44 @@ public interface WxCpOaWeDriveService {
|
||||
*/
|
||||
WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取空间信息
|
||||
* 该接口用于获取空间成员列表、信息、权限等信息。
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param userId
|
||||
* @param spaceId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 添加成员/部门
|
||||
* 该接口用于对指定空间添加成员/部门,可一次性添加多个。
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param request 添加成员/部门请求参数
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 移除成员/部门
|
||||
* 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param request 移除成员/部门请求参数
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.WxCpOaWeDriveService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateData;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceRenameRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.wedrive.*;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
|
||||
|
||||
@@ -49,4 +47,28 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService {
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_INFO);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("userid", userId);
|
||||
jsonObject.addProperty("spaceid", spaceId);
|
||||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
|
||||
return WxCpSpaceInfo.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_ADD);
|
||||
String responseContent = this.cpService.post(apiUrl, request.toJson());
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_DEL);
|
||||
String responseContent = this.cpService.post(apiUrl, request.toJson());
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 WxCpSpaceAclAddRequest implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754138L;
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
@SerializedName("spaceid")
|
||||
private String spaceId;
|
||||
|
||||
@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 WxCpSpaceAclAddRequest fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceAclAddRequest.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 WxCpSpaceAclDelRequest implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754138L;
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
@SerializedName("spaceid")
|
||||
private String spaceId;
|
||||
|
||||
@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 WxCpSpaceAclDelRequest fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceAclDelRequest.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package me.chanjar.weixin.cp.bean.oa.wedrive;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取空间信息.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpSpaceInfo extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625142879581L;
|
||||
|
||||
@SerializedName("space_info")
|
||||
private SpaceInfo spaceInfo;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SpaceInfo implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754598L;
|
||||
|
||||
@SerializedName("spaceid")
|
||||
private String spaceId;
|
||||
|
||||
@SerializedName("space_name")
|
||||
private String spaceName;
|
||||
|
||||
@SerializedName("auth_list")
|
||||
private AuthList authList;
|
||||
|
||||
public static SpaceInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, SpaceInfo.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class AuthList implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754598L;
|
||||
|
||||
@SerializedName("auth_info")
|
||||
private List<AuthInfo> authInfo;
|
||||
|
||||
@SerializedName("quit_userid")
|
||||
private List<String> quitUserId;
|
||||
|
||||
public static AuthList fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, AuthList.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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 WxCpSpaceInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceInfo.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -148,6 +148,9 @@ public interface WxCpApiPathConsts {
|
||||
String SPACE_CREATE = "/cgi-bin/wedrive/space_create";
|
||||
String SPACE_RENAME = "/cgi-bin/wedrive/space_rename";
|
||||
String SPACE_DISMISS = "/cgi-bin/wedrive/space_dismiss";
|
||||
String SPACE_INFO = "/cgi-bin/wedrive/space_info";
|
||||
String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add";
|
||||
String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del";
|
||||
|
||||
/**
|
||||
* 审批流程引擎
|
||||
|
||||
Reference in New Issue
Block a user