diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java index ad2dc635f..8c3efbc1a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveService.java @@ -9,7 +9,7 @@ import java.util.List; /** * 企业微信微盘相关接口. - * https://developer.work.weixin.qq.com/document/path/93654 + * ... * * @author Wang_Wong created on 2022-04-22 */ @@ -20,7 +20,7 @@ public interface WxCpOaWeDriveService { * 该接口用于在微盘内新建空间,可以指定人创建空间。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 新建空间对应请求参数 * @return spaceid (空间id) @@ -33,7 +33,7 @@ public interface WxCpOaWeDriveService { * 该接口用于重命名已有空间,接收userid参数,以空间管理员身份来重命名。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 重命名空间的请求参数 * @return wx cp base resp @@ -46,7 +46,7 @@ public interface WxCpOaWeDriveService { * 该接口用于解散已有空间,需要以空间管理员身份来解散。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param userId the user id * @param spaceId the space id @@ -60,7 +60,7 @@ public interface WxCpOaWeDriveService { * 该接口用于获取空间成员列表、信息、权限等信息。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param userId the user id * @param spaceId the space id @@ -74,7 +74,7 @@ public interface WxCpOaWeDriveService { * 该接口用于对指定空间添加成员/部门,可一次性添加多个。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 添加成员/部门请求参数 * @return wx cp base resp @@ -87,7 +87,7 @@ public interface WxCpOaWeDriveService { * 该接口用于对指定空间移除成员/部门,操作者需要有移除权限。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 移除成员/部门请求参数 * @return wx cp base resp @@ -100,7 +100,7 @@ public interface WxCpOaWeDriveService { * 该接口用于修改空间权限,需要传入userid,修改权限范围继承传入用户的权限范围。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 权限管理请求参数 * @return wx cp base resp @@ -113,7 +113,7 @@ public interface WxCpOaWeDriveService { * 该接口用于获取空间邀请分享链接。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param userId the user id * @param spaceId the space id @@ -127,7 +127,7 @@ public interface WxCpOaWeDriveService { * 该接口用于获取指定地址下的文件列表。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 获取文件列表请求参数 * @return wx cp file list @@ -140,7 +140,7 @@ public interface WxCpOaWeDriveService { * 该接口用于向微盘中的指定位置上传文件。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 上传文件请求参数 * @return wx cp file upload @@ -153,54 +153,58 @@ public interface WxCpOaWeDriveService { * 该接口用于下载文件,请求的userid需有下载权限。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN + * 请求地址: ... * - * @param userId the user id - * @param fileId the file id - * @return wx cp file download + * @param fileId 文件fileid(只支持下载普通文件,不支持下载文件夹或微文档) + * @param selectedTicket 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填fileid。 + * @return { + * "errcode": 0, + * "errmsg": "ok", + * "download_url": "DOWNLOAD_URL", + * "cookie_name": "COOKIE_NAME", + * "cookie_value": "COOKIE_VALUE" + * } * @throws WxErrorException the wx error exception */ - WxCpFileDownload fileDownload(@NonNull String userId, @NonNull String fileId) throws WxErrorException; + WxCpFileDownload fileDownload( String fileId, String selectedTicket) throws WxErrorException; /** * 重命名文件 * 该接口用于对指定文件进行重命名。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=ACCESS_TOKEN + * 请求地址: ... * - * @param userId the user id * @param fileId the file id * @param newName the new name * @return wx cp file rename * @throws WxErrorException the wx error exception */ - WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException; + WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException; /** - * 新建文件/微文档 - * 该接口用于在微盘指定位置新建文件、微文档。 + * 新建文件夹/文档 + * 该接口用于在微盘指定位置新建文件夹、文档(更多文档接口能力可见文档API接口说明)。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=ACCESS_TOKEN + * 请求地址: ... * - * @param userId 操作者userid * @param spaceId 空间spaceid * @param fatherId 父目录fileid, 在根目录时为空间spaceid - * @param fileType 文件类型, 1:文件夹 3:微文档(文档) 4:微文档(表格) - * @param fileName 文件名字 + * @param fileType 文件类型, 1:文件夹 3:文档(文档) 4:文档(表格) + * @param fileName 文件名字(注意:文件名最多填255个字符, 英文算1个, 汉字算2个) * @return wx cp file create * @throws WxErrorException the wx error exception */ - WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId, - @NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException; + WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId, @NonNull Integer fileType, + @NonNull String fileName) throws WxErrorException; /** * 移动文件 * 该接口用于将文件移动到指定位置。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 移动文件的请求参数 * @return wx cp file move @@ -213,21 +217,33 @@ public interface WxCpOaWeDriveService { * 该接口用于删除指定文件。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=ACCESS_TOKEN + * 请求地址: ... * - * @param userId 操作者userid - * @param fileId 文件fileid列表 + * @param fileIds 文件fileid列表 * @return wx cp base resp * @throws WxErrorException the wx error exception */ - WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List fileId) throws WxErrorException; + WxCpBaseResp fileDelete(@NonNull List fileIds) throws WxErrorException; + + /** + * 文件信息 + * 该接口用于获取指定文件的信息。 + *

+ * 请求方式:POST(HTTPS) + * 请求地址: ... + * + * @param fileId the file id + * @return wx cp file info + * @throws WxErrorException the wx error exception + */ + WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException; /** * 新增指定人 * 该接口用于对指定文件添加指定人/部门。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 新增指定人请求参数 * @return wx cp base resp @@ -240,7 +256,7 @@ public interface WxCpOaWeDriveService { * 该接口用于删除指定文件的指定人/部门。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param request 请求参数 * @return wx cp base resp @@ -253,7 +269,7 @@ public interface WxCpOaWeDriveService { * 该接口用于文件的分享设置。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param userId the user id * @param fileId the file id @@ -269,7 +285,7 @@ public interface WxCpOaWeDriveService { * 该接口用于获取文件的分享链接。 *

* 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN + * 请求地址: ... * * @param userId the user id * @param fileId the file id @@ -278,18 +294,4 @@ public interface WxCpOaWeDriveService { */ WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException; - /** - * 文件信息 - * 该接口用于获取指定文件的信息。 - *

- * 请求方式:POST(HTTPS) - * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=ACCESS_TOKEN - * - * @param userId the user id - * @param fileId the file id - * @return wx cp file info - * @throws WxErrorException the wx error exception - */ - WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException; - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java index 979e86e55..597851aae 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaWeDriveServiceImpl.java @@ -114,10 +114,9 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { } @Override - public WxCpFileRename fileRename(@NonNull String userId, @NonNull String fileId, @NonNull String newName) throws WxErrorException { + public WxCpFileRename fileRename(@NonNull String fileId, @NonNull String newName) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_RENAME); JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("userid", userId); jsonObject.addProperty("fileid", fileId); jsonObject.addProperty("new_name", newName); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); @@ -125,11 +124,10 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { } @Override - public WxCpFileCreate fileCreate(@NonNull String userId, @NonNull String spaceId, @NonNull String fatherId, + public WxCpFileCreate fileCreate(@NonNull String spaceId, @NonNull String fatherId, @NonNull Integer fileType, @NonNull String fileName) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_CREATE); JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("userid", userId); jsonObject.addProperty("spaceid", spaceId); jsonObject.addProperty("fatherid", fatherId); jsonObject.addProperty("file_type", fileType); @@ -146,9 +144,9 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { } @Override - public WxCpBaseResp fileDelete(@NonNull String userId, @NonNull List fileId) throws WxErrorException { + public WxCpBaseResp fileDelete(@NonNull List fileIds) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_DELETE); - WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(userId, fileId); + WxCpFileDeleteRequest request = new WxCpFileDeleteRequest(fileIds); String responseContent = this.cpService.post(apiUrl, request.toJson()); return WxCpBaseResp.fromJson(responseContent); } @@ -193,10 +191,9 @@ public class WxCpOaWeDriveServiceImpl implements WxCpOaWeDriveService { } @Override - public WxCpFileInfo fileInfo(@NonNull String userId, @NonNull String fileId) throws WxErrorException { + public WxCpFileInfo fileInfo(@NonNull String fileId) throws WxErrorException { String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(FILE_INFO); JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("userid", userId); jsonObject.addProperty("fileid", fileId); String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); return WxCpFileInfo.fromJson(responseContent); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDeleteRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDeleteRequest.java index bb740f393..3b95629cc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDeleteRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDeleteRequest.java @@ -22,9 +22,6 @@ import java.util.List; public class WxCpFileDeleteRequest implements Serializable { private static final long serialVersionUID = -4960239393895754138L; - @SerializedName("userid") - private String userId; - @SerializedName("fileid") private List fileId; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDownload.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDownload.java index 9c2507c68..f52f0ca42 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDownload.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileDownload.java @@ -35,8 +35,4 @@ public class WxCpFileDownload extends WxCpBaseResp implements Serializable { return WxCpGsonBuilder.create().fromJson(json, WxCpFileDownload.class); } - public String toJson() { - return WxCpGsonBuilder.create().toJson(this); - } - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileListRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileListRequest.java index 1855c1a0d..890f35d36 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileListRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileListRequest.java @@ -21,9 +21,6 @@ import java.io.Serializable; public class WxCpFileListRequest implements Serializable { private static final long serialVersionUID = -4960239393895754138L; - @SerializedName("userid") - private String userId; - @SerializedName("spaceid") private String spaceId; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileMoveRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileMoveRequest.java index 5802e3c27..58460067b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileMoveRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileMoveRequest.java @@ -21,12 +21,6 @@ import java.io.Serializable; public class WxCpFileMoveRequest implements Serializable { private static final long serialVersionUID = -4960239393895754138L; - /** - * 操作者userid - */ - @SerializedName("userid") - private String userId; - /** * 如果移动到的目标目录与需要移动的文件重名时,是否覆盖。 * true:重名文件覆盖 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileUploadRequest.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileUploadRequest.java index 7a107562b..d6ffe7b11 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileUploadRequest.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/wedrive/WxCpFileUploadRequest.java @@ -21,9 +21,6 @@ import java.io.Serializable; public class WxCpFileUploadRequest implements Serializable { private static final long serialVersionUID = -4960239393895754138L; - @SerializedName("userid") - private String userId; - @SerializedName("spaceid") private String spaceId; diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java index dc1c45873..365741c32 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java @@ -110,13 +110,13 @@ public class WxCpOaWeDriveServiceTest { */ ArrayList fileIds = Lists.newArrayList(); fileIds.add(fileId); - WxCpBaseResp fileDelete = cpService.getOaWeDriveService().fileDelete(uId, fileIds); + WxCpBaseResp fileDelete = cpService.getOaWeDriveService().fileDelete(fileIds); log.info("删除文件数据为:{}", fileDelete.toJson()); /** * 文件信息 */ - WxCpFileInfo fileInfo = cpService.getOaWeDriveService().fileInfo(uId, fileId); + WxCpFileInfo fileInfo = cpService.getOaWeDriveService().fileInfo(fileId); log.info("fileInfo数据为:{}", fileInfo.toJson()); /** @@ -134,7 +134,7 @@ public class WxCpOaWeDriveServiceTest { /** * 新建文件/微文档 */ - WxCpFileCreate fileCreate = cpService.getOaWeDriveService().fileCreate(uId, spId, spId, 3, "新建微文档1"); + WxCpFileCreate fileCreate = cpService.getOaWeDriveService().fileCreate(spId, spId, 3, "新建微文档1"); log.info("新建文件/微文档:{}", fileCreate.toJson()); /**