Skip to content

Commit a4e3af0

Browse files
committed
🎨 #3437 【企业微信】 微盘文件管理相关接口移除过期的userid参数
1 parent f70a305 commit a4e3af0

File tree

8 files changed

+60
-80
lines changed

8 files changed

+60
-80
lines changed

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* 企业微信微盘相关接口.
12-
* https://developer.work.weixin.qq.com/document/path/93654
12+
* <a href="https://developer.work.weixin.qq.com/document/path/93654">...</a>
1313
*
1414
* @author <a href="https://github.com/0katekate0">Wang_Wong</a> created on 2022-04-22
1515
*/
@@ -20,7 +20,7 @@ public interface WxCpOaWeDriveService {
2020
* 该接口用于在微盘内新建空间,可以指定人创建空间。
2121
* <p>
2222
* 请求方式:POST(HTTPS)
23-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=ACCESS_TOKEN
23+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=ACCESS_TOKEN">...</a>
2424
*
2525
* @param request 新建空间对应请求参数
2626
* @return spaceid (空间id)
@@ -33,7 +33,7 @@ public interface WxCpOaWeDriveService {
3333
* 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。
3434
* <p>
3535
* 请求方式:POST(HTTPS)
36-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN
36+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN">...</a>
3737
*
3838
* @param request 重命名空间的请求参数
3939
* @return wx cp base resp
@@ -46,7 +46,7 @@ public interface WxCpOaWeDriveService {
4646
* 该接口用于解散已有空间,需要以空间管理员身份来解散。
4747
* <p>
4848
* 请求方式:POST(HTTPS)
49-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN
49+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN">...</a>
5050
*
5151
* @param userId the user id
5252
* @param spaceId the space id
@@ -60,7 +60,7 @@ public interface WxCpOaWeDriveService {
6060
* 该接口用于获取空间成员列表、信息、权限等信息。
6161
* <p>
6262
* 请求方式:POST(HTTPS)
63-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN
63+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN">...</a>
6464
*
6565
* @param userId the user id
6666
* @param spaceId the space id
@@ -74,7 +74,7 @@ public interface WxCpOaWeDriveService {
7474
* 该接口用于对指定空间添加成员/部门,可一次性添加多个。
7575
* <p>
7676
* 请求方式:POST(HTTPS)
77-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN
77+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN">...</a>
7878
*
7979
* @param request 添加成员/部门请求参数
8080
* @return wx cp base resp
@@ -87,7 +87,7 @@ public interface WxCpOaWeDriveService {
8787
* 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。
8888
* <p>
8989
* 请求方式:POST(HTTPS)
90-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN
90+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN">...</a>
9191
*
9292
* @param request 移除成员/部门请求参数
9393
* @return wx cp base resp
@@ -100,7 +100,7 @@ public interface WxCpOaWeDriveService {
100100
* 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。
101101
* <p>
102102
* 请求方式:POST(HTTPS)
103-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN
103+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN">...</a>
104104
*
105105
* @param request 权限管理请求参数
106106
* @return wx cp base resp
@@ -113,7 +113,7 @@ public interface WxCpOaWeDriveService {
113113
* 该接口用于获取空间邀请分享链接。
114114
* <p>
115115
* 请求方式:POST(HTTPS)
116-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN
116+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN">...</a>
117117
*
118118
* @param userId the user id
119119
* @param spaceId the space id
@@ -127,7 +127,7 @@ public interface WxCpOaWeDriveService {
127127
* 该接口用于获取指定地址下的文件列表。
128128
* <p>
129129
* 请求方式:POST(HTTPS)
130-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=ACCESS_TOKEN
130+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=ACCESS_TOKEN">...</a>
131131
*
132132
* @param request 获取文件列表请求参数
133133
* @return wx cp file list
@@ -140,7 +140,7 @@ public interface WxCpOaWeDriveService {
140140
* 该接口用于向微盘中的指定位置上传文件。
141141
* <p>
142142
* 请求方式:POST(HTTPS)
143-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=ACCESS_TOKEN
143+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=ACCESS_TOKEN">...</a>
144144
*
145145
* @param request 上传文件请求参数
146146
* @return wx cp file upload
@@ -153,54 +153,58 @@ public interface WxCpOaWeDriveService {
153153
* 该接口用于下载文件,请求的userid需有下载权限。
154154
* <p>
155155
* 请求方式:POST(HTTPS)
156-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN
156+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN">...</a>
157157
*
158-
* @param userId the user id
159-
* @param fileId the file id
160-
* @return wx cp file download
158+
* @param fileId 文件fileid(只支持下载普通文件,不支持下载文件夹或微文档)
159+
* @param selectedTicket 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填fileid。
160+
* @return {
161+
* "errcode": 0,
162+
* "errmsg": "ok",
163+
* "download_url": "DOWNLOAD_URL",
164+
* "cookie_name": "COOKIE_NAME",
165+
* "cookie_value": "COOKIE_VALUE"
166+
* }
161167
* @throws WxErrorException the wx error exception
162168
*/
163-
WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fileId) throws WxErrorException;
169+
WxCpFileDownload fileDownload( String fileId, String selectedTicket) throws WxErrorException;
164170

165171
/**
166172
* 重命名文件
167173
* 该接口用于对指定文件进行重命名。
168174
* <p>
169175
* 请求方式:POST(HTTPS)
170-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=ACCESS_TOKEN
176+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=ACCESS_TOKEN">...</a>
171177
*
172-
* @param userId the user id
173178
* @param fileId the file id
174179
* @param newName the new name
175180
* @return wx cp file rename
176181
* @throws WxErrorException the wx error exception
177182
*/
178-
WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException;
183+
WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException;
179184

180185
/**
181-
* 新建文件/微文档
182-
* 该接口用于在微盘指定位置新建文件、微文档
186+
* 新建文件夹/文档
187+
* 该接口用于在微盘指定位置新建文件夹、文档(更多文档接口能力可见文档API接口说明)
183188
* <p>
184189
* 请求方式:POST(HTTPS)
185-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=ACCESS_TOKEN
190+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=ACCESS_TOKEN">...</a>
186191
*
187-
* @param userId 操作者userid
188192
* @param spaceId 空间spaceid
189193
* @param fatherId 父目录fileid, 在根目录时为空间spaceid
190-
* @param fileType 文件类型, 1:文件夹 3:微文档(文档) 4:微文档(表格)
191-
* @param fileName 文件名字
194+
* @param fileType 文件类型, 1:文件夹 3:文档(文档) 4:文档(表格)
195+
* @param fileName 文件名字(注意:文件名最多填255个字符, 英文算1个, 汉字算2个)
192196
* @return wx cp file create
193197
* @throws WxErrorException the wx error exception
194198
*/
195-
WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
196-
@NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException;
199+
WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId, @NonNull Integer fileType,
200+
@NonNull String fileName) throws WxErrorException;
197201

198202
/**
199203
* 移动文件
200204
* 该接口用于将文件移动到指定位置。
201205
* <p>
202206
* 请求方式:POST(HTTPS)
203-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=ACCESS_TOKEN
207+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=ACCESS_TOKEN">...</a>
204208
*
205209
* @param request 移动文件的请求参数
206210
* @return wx cp file move
@@ -213,21 +217,33 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
213217
* 该接口用于删除指定文件。
214218
* <p>
215219
* 请求方式:POST(HTTPS)
216-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=ACCESS_TOKEN
220+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=ACCESS_TOKEN">...</a>
217221
*
218-
* @param userId 操作者userid
219-
* @param fileId 文件fileid列表
222+
* @param fileIds 文件fileid列表
220223
* @return wx cp base resp
221224
* @throws WxErrorException the wx error exception
222225
*/
223-
WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List<String> fileId) throws WxErrorException;
226+
WxCpBaseResp fileDelete(@NonNull List<String> fileIds) throws WxErrorException;
227+
228+
/**
229+
* 文件信息
230+
* 该接口用于获取指定文件的信息。
231+
* <p>
232+
* 请求方式:POST(HTTPS)
233+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=ACCESS_TOKEN">...</a>
234+
*
235+
* @param fileId the file id
236+
* @return wx cp file info
237+
* @throws WxErrorException the wx error exception
238+
*/
239+
WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException;
224240

225241
/**
226242
* 新增指定人
227243
* 该接口用于对指定文件添加指定人/部门。
228244
* <p>
229245
* 请求方式:POST(HTTPS)
230-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN
246+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN">...</a>
231247
*
232248
* @param request 新增指定人请求参数
233249
* @return wx cp base resp
@@ -240,7 +256,7 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
240256
* 该接口用于删除指定文件的指定人/部门。
241257
* <p>
242258
* 请求方式:POST(HTTPS)
243-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN
259+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN">...</a>
244260
*
245261
* @param request 请求参数
246262
* @return wx cp base resp
@@ -253,7 +269,7 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
253269
* 该接口用于文件的分享设置。
254270
* <p>
255271
* 请求方式:POST(HTTPS)
256-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN
272+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN">...</a>
257273
*
258274
* @param userId the user id
259275
* @param fileId the file id
@@ -269,7 +285,7 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
269285
* 该接口用于获取文件的分享链接。
270286
* <p>
271287
* 请求方式:POST(HTTPS)
272-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN
288+
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN">...</a>
273289
*
274290
* @param userId the user id
275291
* @param fileId the file id
@@ -278,18 +294,4 @@ WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId,
278294
*/
279295
WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException;
280296

281-
/**
282-
* 文件信息
283-
* 该接口用于获取指定文件的信息。
284-
* <p>
285-
* 请求方式:POST(HTTPS)
286-
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=ACCESS_TOKEN
287-
*
288-
* @param userId the user id
289-
* @param fileId the file id
290-
* @return wx cp file info
291-
* @throws WxErrorException the wx error exception
292-
*/
293-
WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException;
294-
295297
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,20 @@ public WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fil
114114
}
115115

116116
@Override
117-
public WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException {
117+
public WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException {
118118
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_RENAME);
119119
JsonObject jsonObject = new JsonObject();
120-
jsonObject.addProperty("userid", userId);
121120
jsonObject.addProperty("fileid", fileId);
122121
jsonObject.addProperty("new_name", newName);
123122
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
124123
return WxCpFileRename.fromJson(responseContent);
125124
}
126125

127126
@Override
128-
public WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId, @NonNull String fatherId,
127+
public WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId,
129128
@NonNull Integer fileType, @NonNull String fileName) throws WxErrorException {
130129
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_CREATE);
131130
JsonObject jsonObject = new JsonObject();
132-
jsonObject.addProperty("userid", userId);
133131
jsonObject.addProperty("spaceid", spaceId);
134132
jsonObject.addProperty("fatherid", fatherId);
135133
jsonObject.addProperty("file_type", fileType);
@@ -146,9 +144,9 @@ public WxCpFileMove fileMove(@NonNull WxCpFileMoveRequest request) throws WxErro
146144
}
147145

148146
@Override
149-
public WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List<String> fileId) throws WxErrorException {
147+
public WxCpBaseResp fileDelete(@NonNull List<String> fileIds) throws WxErrorException {
150148
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DELETE);
151-
WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(userId, fileId);
149+
WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(fileIds);
152150
String responseContent = this.cpService.post(apiUrl, request.toJson());
153151
return WxCpBaseResp.fromJson(responseContent);
154152
}
@@ -193,10 +191,9 @@ public WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) t
193191
}
194192

195193
@Override
196-
public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException {
194+
public WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException {
197195
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO);
198196
JsonObject jsonObject = new JsonObject();
199-
jsonObject.addProperty("userid", userId);
200197
jsonObject.addProperty("fileid", fileId);
201198
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
202199
return WxCpFileInfo.fromJson(responseContent);

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDeleteRequest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
public class WxCpFileDeleteRequest implements Serializable {
2323
private static final long serialVersionUID = -4960239393895754138L;
2424

25-
@SerializedName("userid")
26-
private String userId;
27-
2825
@SerializedName("fileid")
2926
private List<String> fileId;
3027

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDownload.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,4 @@ public static WxCpFileDownload fromJson(String json) {
3535
return WxCpGsonBuilder.create().fromJson(json, WxCpFileDownload.class);
3636
}
3737

38-
public String toJson() {
39-
return WxCpGsonBuilder.create().toJson(this);
40-
}
41-
4238
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileListRequest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
public class WxCpFileListRequest implements Serializable {
2222
private static final long serialVersionUID = -4960239393895754138L;
2323

24-
@SerializedName("userid")
25-
private String userId;
26-
2724
@SerializedName("spaceid")
2825
private String spaceId;
2926

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileMoveRequest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
public class WxCpFileMoveRequest implements Serializable {
2222
private static final long serialVersionUID = -4960239393895754138L;
2323

24-
/**
25-
* 操作者userid
26-
*/
27-
@SerializedName("userid")
28-
private String userId;
29-
3024
/**
3125
* 如果移动到的目标目录与需要移动的文件重名时,是否覆盖。
3226
* true:重名文件覆盖

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileUploadRequest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
public class WxCpFileUploadRequest implements Serializable {
2222
private static final long serialVersionUID = -4960239393895754138L;
2323

24-
@SerializedName("userid")
25-
private String userId;
26-
2724
@SerializedName("spaceid")
2825
private String spaceId;
2926

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public void test() throws Exception {
110110
*/
111111
ArrayList<String> fileIds = Lists.newArrayList();
112112
fileIds.add(fileId);
113-
WxCpBaseResp fileDelete = cpService.getOaWeDriveService().fileDelete(uId, fileIds);
113+
WxCpBaseResp fileDelete = cpService.getOaWeDriveService().fileDelete(fileIds);
114114
log.info("删除文件数据为:{}", fileDelete.toJson());
115115

116116
/**
117117
* 文件信息
118118
*/
119-
WxCpFileInfo fileInfo = cpService.getOaWeDriveService().fileInfo(uId, fileId);
119+
WxCpFileInfo fileInfo = cpService.getOaWeDriveService().fileInfo(fileId);
120120
log.info("fileInfo数据为:{}", fileInfo.toJson());
121121

122122
/**
@@ -134,7 +134,7 @@ public void test() throws Exception {
134134
/**
135135
* 新建文件/微文档
136136
*/
137-
WxCpFileCreate fileCreate = cpService.getOaWeDriveService().fileCreate(uId, spId, spId, 3, "新建微文档1");
137+
WxCpFileCreate fileCreate = cpService.getOaWeDriveService().fileCreate(spId, spId, 3, "新建微文档1");
138138
log.info("新建文件/微文档:{}", fileCreate.toJson());
139139

140140
/**

0 commit comments

Comments
 (0)