Visitar URL original
:new: #2637【企业微信】新增微盘获取空间信息的接口 · binarywang/WxJava@7e96d6a · GitHub
Skip to content

Commit 7e96d6a

Browse files
authored
🆕 #2637【企业微信】新增微盘获取空间信息的接口
1 parent d6301d3 commit 7e96d6a

7 files changed

Lines changed: 363 additions & 13 deletions

File tree

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import lombok.NonNull;
44
import me.chanjar.weixin.common.error.WxErrorException;
55
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
6-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateData;
7-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateRequest;
8-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceRenameRequest;
6+
import me.chanjar.weixin.cp.bean.oa.wedrive.*;
97

108
/**
119
* 企业微信微盘相关接口.
@@ -25,15 +23,14 @@ public interface WxCpOaWeDriveService {
2523
*
2624
* @param request 新建空间对应请求参数
2725
* @return spaceid(空间id)
28-
*
2926
* @throws WxErrorException
3027
*/
3128
WxCpSpaceCreateData spaceCreate(@NonNull WxCpSpaceCreateRequest request) throws WxErrorException;
3229

3330
/**
3431
* 重命名空间
3532
* 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。
36-
*
33+
* <p>
3734
* 请求方式:POST(HTTPS)
3835
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN
3936
*
@@ -46,7 +43,7 @@ public interface WxCpOaWeDriveService {
4643
/**
4744
* 解散空间
4845
* 该接口用于解散已有空间,需要以空间管理员身份来解散。
49-
*
46+
* <p>
5047
* 请求方式:POST(HTTPS)
5148
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN
5249
*
@@ -57,4 +54,44 @@ public interface WxCpOaWeDriveService {
5754
*/
5855
WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
5956

57+
/**
58+
* 获取空间信息
59+
* 该接口用于获取空间成员列表、信息、权限等信息。
60+
* <p>
61+
* 请求方式:POST(HTTPS)
62+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN
63+
*
64+
* @param userId
65+
* @param spaceId
66+
* @return
67+
* @throws WxErrorException
68+
*/
69+
WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
70+
71+
/**
72+
* 添加成员/部门
73+
* 该接口用于对指定空间添加成员/部门,可一次性添加多个。
74+
* <p>
75+
* 请求方式:POST(HTTPS)
76+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN
77+
*
78+
* @param request 添加成员/部门请求参数
79+
* @return
80+
* @throws WxErrorException
81+
*/
82+
WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException;
83+
84+
/**
85+
* 移除成员/部门
86+
* 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。
87+
* <p>
88+
* 请求方式:POST(HTTPS)
89+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN
90+
*
91+
* @param request 移除成员/部门请求参数
92+
* @return
93+
* @throws WxErrorException
94+
*/
95+
WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException;
96+
6097
}

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import me.chanjar.weixin.cp.api.WxCpOaWeDriveService;
99
import me.chanjar.weixin.cp.api.WxCpService;
1010
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
11-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateData;
12-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceCreateRequest;
13-
import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpSpaceRenameRequest;
11+
import me.chanjar.weixin.cp.bean.oa.wedrive.*;
1412

1513
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
1614

@@ -49,4 +47,28 @@ public WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId
4947
return WxCpBaseResp.fromJson(responseContent);
5048
}
5149

50+
@Override
51+
public WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException {
52+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_INFO);
53+
JsonObject jsonObject = new JsonObject();
54+
jsonObject.addProperty("userid", userId);
55+
jsonObject.addProperty("spaceid", spaceId);
56+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
57+
return WxCpSpaceInfo.fromJson(responseContent);
58+
}
59+
60+
@Override
61+
public WxCpBaseResp spaceAclAdd(@NonNull WxCpSpaceAclAddRequest request) throws WxErrorException {
62+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_ADD);
63+
String responseContent = this.cpService.post(apiUrl, request.toJson());
64+
return WxCpBaseResp.fromJson(responseContent);
65+
}
66+
67+
@Override
68+
public WxCpBaseResp spaceAclDel(@NonNull WxCpSpaceAclDelRequest request) throws WxErrorException {
69+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SPACE_ACL_DEL);
70+
String responseContent = this.cpService.post(apiUrl, request.toJson());
71+
return WxCpBaseResp.fromJson(responseContent);
72+
}
73+
5274
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package me.chanjar.weixin.cp.bean.oa.wedrive;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.*;
5+
import lombok.experimental.Accessors;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
import java.util.List;
10+
11+
/**
12+
* 添加成员/部门请求.
13+
*/
14+
@Data
15+
@Builder
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
@Accessors(chain = true)
19+
public class WxCpSpaceAclAddRequest implements Serializable {
20+
private static final long serialVersionUID = -4960239393895754138L;
21+
22+
@SerializedName("userid")
23+
private String userId;
24+
25+
@SerializedName("spaceid")
26+
private String spaceId;
27+
28+
@SerializedName("auth_info")
29+
private List<AuthInfo> authInfo;
30+
31+
@Getter
32+
@Setter
33+
public static class AuthInfo implements Serializable {
34+
private static final long serialVersionUID = -4960239393895754598L;
35+
36+
@SerializedName("type")
37+
private Integer type;
38+
39+
@SerializedName("departmentid")
40+
private Integer departmentId;
41+
42+
@SerializedName("auth")
43+
private Integer auth;
44+
45+
@SerializedName("userid")
46+
private String userId;
47+
48+
public static AuthInfo fromJson(String json) {
49+
return WxCpGsonBuilder.create().fromJson(json, AuthInfo.class);
50+
}
51+
52+
public String toJson() {
53+
return WxCpGsonBuilder.create().toJson(this);
54+
}
55+
56+
}
57+
58+
public static WxCpSpaceAclAddRequest fromJson(String json) {
59+
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceAclAddRequest.class);
60+
}
61+
62+
public String toJson() {
63+
return WxCpGsonBuilder.create().toJson(this);
64+
}
65+
66+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package me.chanjar.weixin.cp.bean.oa.wedrive;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.*;
5+
import lombok.experimental.Accessors;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
import java.util.List;
10+
11+
/**
12+
* 移除成员/部门请求.
13+
*/
14+
@Data
15+
@Builder
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
@Accessors(chain = true)
19+
public class WxCpSpaceAclDelRequest implements Serializable {
20+
private static final long serialVersionUID = -4960239393895754138L;
21+
22+
@SerializedName("userid")
23+
private String userId;
24+
25+
@SerializedName("spaceid")
26+
private String spaceId;
27+
28+
@SerializedName("auth_info")
29+
private List<AuthInfo> authInfo;
30+
31+
@Getter
32+
@Setter
33+
public static class AuthInfo implements Serializable {
34+
private static final long serialVersionUID = -4960239393895754598L;
35+
36+
@SerializedName("type")
37+
private Integer type;
38+
39+
@SerializedName("departmentid")
40+
private Integer departmentId;
41+
42+
@SerializedName("userid")
43+
private String userId;
44+
45+
public static AuthInfo fromJson(String json) {
46+
return WxCpGsonBuilder.create().fromJson(json, AuthInfo.class);
47+
}
48+
49+
public String toJson() {
50+
return WxCpGsonBuilder.create().toJson(this);
51+
}
52+
53+
}
54+
55+
public static WxCpSpaceAclDelRequest fromJson(String json) {
56+
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceAclDelRequest.class);
57+
}
58+
59+
public String toJson() {
60+
return WxCpGsonBuilder.create().toJson(this);
61+
}
62+
63+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package me.chanjar.weixin.cp.bean.oa.wedrive;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.Getter;
6+
import lombok.Setter;
7+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
8+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
9+
10+
import java.io.Serializable;
11+
import java.util.List;
12+
13+
/**
14+
* 获取空间信息.
15+
*
16+
* @author Wang_Wong
17+
*/
18+
@Data
19+
public class WxCpSpaceInfo extends WxCpBaseResp implements Serializable {
20+
private static final long serialVersionUID = -5028321625142879581L;
21+
22+
@SerializedName("space_info")
23+
private SpaceInfo spaceInfo;
24+
25+
@Getter
26+
@Setter
27+
public static class SpaceInfo implements Serializable {
28+
private static final long serialVersionUID = -4960239393895754598L;
29+
30+
@SerializedName("spaceid")
31+
private String spaceId;
32+
33+
@SerializedName("space_name")
34+
private String spaceName;
35+
36+
@SerializedName("auth_list")
37+
private AuthList authList;
38+
39+
public static SpaceInfo fromJson(String json) {
40+
return WxCpGsonBuilder.create().fromJson(json, SpaceInfo.class);
41+
}
42+
43+
public String toJson() {
44+
return WxCpGsonBuilder.create().toJson(this);
45+
}
46+
47+
}
48+
49+
@Getter
50+
@Setter
51+
public static class AuthList implements Serializable {
52+
private static final long serialVersionUID = -4960239393895754598L;
53+
54+
@SerializedName("auth_info")
55+
private List<AuthInfo> authInfo;
56+
57+
@SerializedName("quit_userid")
58+
private List<String> quitUserId;
59+
60+
public static AuthList fromJson(String json) {
61+
return WxCpGsonBuilder.create().fromJson(json, AuthList.class);
62+
}
63+
64+
public String toJson() {
65+
return WxCpGsonBuilder.create().toJson(this);
66+
}
67+
68+
}
69+
70+
@Getter
71+
@Setter
72+
public static class AuthInfo implements Serializable {
73+
private static final long serialVersionUID = -4960239393895754598L;
74+
75+
@SerializedName("type")
76+
private Integer type;
77+
78+
@SerializedName("departmentid")
79+
private Integer departmentId;
80+
81+
@SerializedName("auth")
82+
private Integer auth;
83+
84+
@SerializedName("userid")
85+
private String userId;
86+
87+
public static AuthInfo fromJson(String json) {
88+
return WxCpGsonBuilder.create().fromJson(json, AuthInfo.class);
89+
}
90+
91+
public String toJson() {
92+
return WxCpGsonBuilder.create().toJson(this);
93+
}
94+
95+
}
96+
97+
public static WxCpSpaceInfo fromJson(String json) {
98+
return WxCpGsonBuilder.create().fromJson(json, WxCpSpaceInfo.class);
99+
}
100+
101+
public String toJson() {
102+
return WxCpGsonBuilder.create().toJson(this);
103+
}
104+
105+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ interface Oa {
148148
String SPACE_CREATE = "/cgi-bin/wedrive/space_create";
149149
String SPACE_RENAME = "/cgi-bin/wedrive/space_rename";
150150
String SPACE_DISMISS = "/cgi-bin/wedrive/space_dismiss";
151+
String SPACE_INFO = "/cgi-bin/wedrive/space_info";
152+
String SPACE_ACL_ADD = "/cgi-bin/wedrive/space_acl_add";
153+
String SPACE_ACL_DEL = "/cgi-bin/wedrive/space_acl_del";
151154

152155
/**
153156
* 审批流程引擎

0 commit comments

Comments
 (0)