|
@@ -1,5 +1,8 @@
|
|
|
package com.usoftchina.dingtalk.sdk;
|
|
|
|
|
|
+import com.aliyun.dingtalktodo_1_0.models.*;
|
|
|
+import com.aliyun.teaopenapi.models.Config;
|
|
|
+import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
import com.dingtalk.api.DingTalkClient;
|
|
|
import com.dingtalk.api.request.*;
|
|
@@ -340,7 +343,7 @@ public class OaSdk extends BaseSdk {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> getAllLeaves(String agentCode,List<String> userIdList, long startTime, long endTime){
|
|
|
+ public List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> getAllLeaves(String agentCode, List<String> userIdList, long startTime, long endTime){
|
|
|
List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> dataList = new ArrayList<>();
|
|
|
long i=1,size=20;
|
|
|
while (true) {
|
|
@@ -356,4 +359,97 @@ public class OaSdk extends BaseSdk {
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 使用 Token 初始化账号Client
|
|
|
+ * @return Client
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public com.aliyun.dingtalktodo_1_0.Client initClient() throws Exception {
|
|
|
+ Config config = new Config();
|
|
|
+ config.protocol = "https";
|
|
|
+ config.regionId = "central";
|
|
|
+ return new com.aliyun.dingtalktodo_1_0.Client(config);
|
|
|
+ }
|
|
|
+ public void createTodo(String agentCode,String unionId,String creatorId,String appUrl,String pcUrl,String title,String description,int priority,String dingNotify,Boolean isOnlyShow) throws Exception {
|
|
|
+ com.aliyun.dingtalktodo_1_0.Client client = initClient();
|
|
|
+ CreateTodoTaskHeaders createTodoTaskHeaders = new CreateTodoTaskHeaders();
|
|
|
+ createTodoTaskHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
|
|
|
+ CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs notifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs()
|
|
|
+ .setDingNotify(dingNotify);
|
|
|
+ CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl detailUrl = new CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl()
|
|
|
+ .setAppUrl(appUrl)
|
|
|
+ .setPcUrl(pcUrl);
|
|
|
+ CreateTodoTaskRequest createTodoTaskRequest = new CreateTodoTaskRequest()
|
|
|
+ .setSubject(title)
|
|
|
+ .setCreatorId(creatorId)
|
|
|
+ .setDescription(description)
|
|
|
+ .setDueTime(DateUtils.nowDateEnd().getTime())
|
|
|
+ .setExecutorIds(java.util.Arrays.asList(
|
|
|
+ unionId
|
|
|
+ ))
|
|
|
+ .setParticipantIds(java.util.Arrays.asList(
|
|
|
+ unionId
|
|
|
+ ))
|
|
|
+ .setDetailUrl(detailUrl)
|
|
|
+ .setIsOnlyShowExecutor(isOnlyShow)
|
|
|
+ .setPriority(priority)
|
|
|
+ .setNotifyConfigs(notifyConfigs);
|
|
|
+ client.createTodoTaskWithOptions(unionId, createTodoTaskRequest, createTodoTaskHeaders, new RuntimeOptions());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateTodo(String agentCode,String creatorId,String unionId,String taskId,String title,String description) throws Exception {
|
|
|
+ com.aliyun.dingtalktodo_1_0.Client client = initClient();
|
|
|
+ UpdateTodoTaskHeaders updateTodoTaskHeaders = new UpdateTodoTaskHeaders();
|
|
|
+ updateTodoTaskHeaders.xAcsDingtalkAccessToken =getAccessToken(agentCode);
|
|
|
+ UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest()
|
|
|
+ .setOperatorId(creatorId)
|
|
|
+ .setSubject(title)
|
|
|
+ .setDescription(description)
|
|
|
+ .setDueTime(DateUtils.nowDateTime().getTime())
|
|
|
+ .setDone(true)
|
|
|
+ .setExecutorIds(java.util.Arrays.asList(
|
|
|
+ unionId
|
|
|
+ ))
|
|
|
+ .setParticipantIds(java.util.Arrays.asList(
|
|
|
+ unionId
|
|
|
+ ));
|
|
|
+ client.updateTodoTaskWithOptions(unionId, taskId, updateTodoTaskRequest, updateTodoTaskHeaders, new RuntimeOptions());
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryOrgTodoTasksResponse getTodo(String agentCode,String unionId,String nextToken,Boolean isDone) throws Exception {
|
|
|
+ com.aliyun.dingtalktodo_1_0.Client client = initClient();
|
|
|
+ QueryOrgTodoTasksHeaders queryOrgTodoTasksHeaders = new QueryOrgTodoTasksHeaders();
|
|
|
+ queryOrgTodoTasksHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
|
|
|
+ QueryOrgTodoTasksRequest queryOrgTodoTasksRequest = new QueryOrgTodoTasksRequest()
|
|
|
+ .setNextToken(nextToken)
|
|
|
+ .setIsDone(isDone);
|
|
|
+ return client.queryOrgTodoTasksWithOptions(unionId, queryOrgTodoTasksRequest, queryOrgTodoTasksHeaders, new RuntimeOptions());
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards> getAllTodo(String agentCode,String unionId,String nextToken,Boolean isDone) throws Exception {
|
|
|
+ Boolean b=true;
|
|
|
+ List<QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards> todos = new ArrayList<>();
|
|
|
+ while (b){
|
|
|
+ QueryOrgTodoTasksResponse todo = getTodo(agentCode, unionId, nextToken, isDone);
|
|
|
+ QueryOrgTodoTasksResponseBody body = todo.getBody();
|
|
|
+ todos.addAll(body.getTodoCards());
|
|
|
+ String token = body.getNextToken();
|
|
|
+ if (token!=null&&!"".equals(token)){
|
|
|
+ nextToken=token;
|
|
|
+ }else {
|
|
|
+ b=false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return todos;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteTodo(String agentCode,String unionId,String taskId) throws Exception {
|
|
|
+ com.aliyun.dingtalktodo_1_0.Client client = initClient();
|
|
|
+ DeleteTodoTaskHeaders deleteTodoTaskHeaders = new DeleteTodoTaskHeaders();
|
|
|
+ deleteTodoTaskHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
|
|
|
+ DeleteTodoTaskRequest deleteTodoTaskRequest = new DeleteTodoTaskRequest()
|
|
|
+ .setOperatorId(unionId);
|
|
|
+ client.deleteTodoTaskWithOptions(unionId, taskId, deleteTodoTaskRequest, deleteTodoTaskHeaders, new RuntimeOptions());
|
|
|
+ }
|
|
|
}
|