From 7bc9c5f7432a9533a0b552c40fb63fc07de5b5fe Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 29 九月 2025 09:56:24 +0800
Subject: [PATCH] 优化
---
server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java | 72 ++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java
index e23b927..e4a88b3 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java
@@ -105,6 +105,19 @@
}
+ public OapiV2UserGetuserinfoResponse.UserGetByCodeResponse getDDUserByCode(String code) throws ApiException {
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo");
+ OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
+ req.setCode(code);
+ OapiV2UserGetuserinfoResponse rsp = client.execute(req, getToken());
+ if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){
+ return rsp.getResult();
+ }else{
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage());
+ }
+ }
+
+
/**
* 鍏ㄩ噺鍚屾 閮ㄩ棬淇℃伅
* 鎺ュ彛鏂囨。鍦板潃 https://open.dingtalk.com/document/orgapp/obtain-the-department-list-v2
@@ -248,6 +261,12 @@
}
+ /**
+ * 鑾峰彇閽夐拤閮ㄩ棬璇︽儏
+ * @param deptId
+ * @return
+ * @throws ApiException
+ */
public OapiV2DepartmentGetResponse.DeptGetResponse syncDepartmentInfo(Long deptId) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
@@ -292,11 +311,11 @@
return null;
}
Set<String> setUserIdList = new HashSet<>(allUserIdList);
- return syncUserInfo(setUserIdList);
+ return syncUserInfoList(setUserIdList);
}
- public List<OapiV2UserGetResponse.UserGetResponse> syncUserInfo(Set<String> setUserIdList) throws ApiException {
+ public List<OapiV2UserGetResponse.UserGetResponse> syncUserInfoList(Set<String> setUserIdList) throws ApiException {
List<OapiV2UserGetResponse.UserGetResponse> userList = new ArrayList<>();
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
@@ -315,7 +334,19 @@
}
-
+ public OapiV2UserGetResponse.UserGetResponse syncUserInfo(String userId)throws ApiException {
+ DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
+ OapiV2UserGetRequest req = new OapiV2UserGetRequest();
+ req.setUserid(userId);
+ req.setLanguage("zh_CN");
+ OapiV2UserGetResponse rsp = client.execute(req, getToken());
+ if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){
+ OapiV2UserGetResponse.UserGetResponse userGetResponse = rsp.getResult();
+ return userGetResponse;
+ }else{
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage());
+ }
+ }
public static void main(String[] args) throws Exception {
@@ -346,6 +377,41 @@
}
}
+ public void workInfoOANotice(Long agentId,String userIds,OapiMessageCorpconversationAsyncsendV2Request.Msg msg)throws ApiException {
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
+ OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
+ request.setAgentId(agentId);
+ request.setUseridList(userIds);
+ request.setToAllUser(false);
+// OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
+// msg.setMsgtype("oa");
+// OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();
+// oa.setMessageUrl("");
+// OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
+// head.setText("");
+// head.setBgcolor("#279BAA");
+//
+// oa.setHead(head);
+//
+// OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
+// body.setTitle("");
+// List<OapiMessageCorpconversationAsyncsendV2Request.Form> form = new ArrayList<>();
+//
+// body.setForm(form);
+// oa.setBody(body);
+// msg.setOa(oa);
+ request.setMsg(msg);
+ OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, getToken());
+ if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){
+
+ }else{
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage());
+ }
+ }
+
+
+
+
}
--
Gitblit v1.9.3