|
|
@@ -16,6 +16,7 @@ import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -154,6 +155,18 @@ public class DDImplClient_Storage implements DDClient_Storage {
|
|
|
return DDR_New.doPost(url, header, param, body).isSuccess();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean addSpacePermissionsNew(String access_token, String dentryUuid, String unionId, String roleId, List<Map> members, Map option) {
|
|
|
+ String url = "https://api.dingtalk.com/v2.0/storage/spaces/dentries/" + dentryUuid + "/permissions";
|
|
|
+ Map header = DDConf.initTokenHeader(access_token);
|
|
|
+ Map param = UtilMap.map("unionId", unionId);
|
|
|
+ Map body = UtilMap.map("roleId, members, option", roleId, members, option);
|
|
|
+// if (ObjectUtil.isNotNull(option)) {
|
|
|
+// body.putAll(option);
|
|
|
+// }
|
|
|
+ return DDR_New.doPost(url, header, param, body).isSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
///////////////////////// 通用上传逻辑 /////////////////////////
|
|
|
|
|
|
/**
|
|
|
@@ -172,6 +185,24 @@ public class DDImplClient_Storage implements DDClient_Storage {
|
|
|
}
|
|
|
return DDR_New.doPost(path, header, param, body);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取文件上传信息 (新)
|
|
|
+ *
|
|
|
+ * @apiNote https://open.dingtalk.com/document/development/upload-files-to-the-knowledge-base
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public DDR_New getUploadInfosNew(String access_token, String parentDentryUuid, String unionId, Map option) {
|
|
|
+ String path = "https://api.dingtalk.com/v2.0/storage/spaces/files/" + parentDentryUuid + "/uploadInfos/query";
|
|
|
+ Map header = DDConf.initTokenHeader(access_token);
|
|
|
+ Map param = UtilMap.map("unionId", unionId);
|
|
|
+ Map body = new HashMap<>();
|
|
|
+ body.put("protocol","HEADER_SIGNATURE");
|
|
|
+ body.put("option",option);
|
|
|
+ if (ObjectUtil.isNotNull(option)) {
|
|
|
+ body.putAll(option);
|
|
|
+ }
|
|
|
+ return DDR_New.doPost(path, header, param, body);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 文件上传 [官方]
|
|
|
@@ -226,4 +257,35 @@ public class DDImplClient_Storage implements DDClient_Storage {
|
|
|
DDR_New ddr = DDR_New.doPost(url, header, param, body);
|
|
|
return ddr.getDentry();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map commitFilesNew(String access_token, String parentDentryUuid, String unionId, String uploadKey, String name, Map option) {
|
|
|
+ String url = "https://api.dingtalk.com/v2.0/storage/spaces/files/" + parentDentryUuid + "/commit";
|
|
|
+ Map header = DDConf.initTokenHeader(access_token);
|
|
|
+ Map param = UtilMap.map("unionId", unionId);
|
|
|
+ Map body = UtilMap.map("uploadKey, name", uploadKey, name);
|
|
|
+ if (ObjectUtil.isNotNull(option)) {
|
|
|
+ body.putAll(option);
|
|
|
+ }
|
|
|
+ DDR_New ddr = DDR_New.doPost(url, header, param, body);
|
|
|
+ return ddr.getDentry();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索文件 https://open.dingtalk.com/document/development/obtains-the-object-preview-or-editing-information
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map searchFiles(String access_token, String spaceId, String unionId, String dentryId, Map option) {
|
|
|
+ String url = "https://api.dingtalk.com/v1.0/storage/spaces/" + spaceId + "/dentries/"+dentryId+"/openInfos/query";
|
|
|
+ Map header = DDConf.initTokenHeader(access_token);
|
|
|
+ Map param = UtilMap.map("unionId", unionId);
|
|
|
+// Map body = UtilMap.map("uploadKey, name, parentId", uploadKey, name, parentId);
|
|
|
+ Map body = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotNull(option)) {
|
|
|
+ body.putAll(option);
|
|
|
+ }
|
|
|
+ DDR_New ddr = DDR_New.doPost(url, header, param, body);
|
|
|
+
|
|
|
+ return UtilMap.map("url, hasWaterMark",ddr.getUrl(),ddr.getHasWaterMark());
|
|
|
+ }
|
|
|
}
|