|
12 | 12 | import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
13 | 13 | import me.chanjar.weixin.cp.api.WxCpService;
|
14 | 14 | import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
15 |
| -import me.chanjar.weixin.cp.bean.external.WxCpAddMomentResult; |
16 |
| -import me.chanjar.weixin.cp.bean.external.WxCpAddMomentTask; |
17 |
| -import me.chanjar.weixin.cp.bean.external.WxCpContactWayInfo; |
18 |
| -import me.chanjar.weixin.cp.bean.external.WxCpContactWayResult; |
19 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentComments; |
20 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentCustomerList; |
21 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentList; |
22 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentSendResult; |
23 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentTask; |
24 |
| -import me.chanjar.weixin.cp.bean.external.WxCpGetMomentTaskResult; |
25 |
| -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplate; |
26 |
| -import me.chanjar.weixin.cp.bean.external.WxCpMsgTemplateAddResult; |
27 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUpdateRemarkRequest; |
28 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactList; |
29 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo; |
30 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList; |
31 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatStatistic; |
32 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatTransferResp; |
33 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupInfo; |
34 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalTagGroupList; |
35 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUnassignList; |
36 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserExternalUserBehaviorStatistic; |
37 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerReq; |
38 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferCustomerResp; |
39 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserTransferResultResp; |
40 |
| -import me.chanjar.weixin.cp.bean.external.WxCpUserWithExternalPermission; |
41 |
| -import me.chanjar.weixin.cp.bean.external.WxCpWelcomeMsg; |
| 15 | +import me.chanjar.weixin.cp.bean.external.*; |
42 | 16 | import me.chanjar.weixin.cp.bean.external.contact.*;
|
43 | 17 | import org.apache.commons.lang3.ArrayUtils;
|
44 | 18 | import org.apache.commons.lang3.StringUtils;
|
@@ -157,6 +131,16 @@ public String unionidToExternalUserid(@NotNull String unionid,String openid) thr
|
157 | 131 | return tmpJson.get("external_userid").getAsString();
|
158 | 132 | }
|
159 | 133 |
|
| 134 | + @Override |
| 135 | + public String opengidToChatid(@NotNull String opengid) throws WxErrorException { |
| 136 | + JsonObject json = new JsonObject(); |
| 137 | + json.addProperty("opengid",opengid); |
| 138 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(OPENID_TO_CHATID); |
| 139 | + String responseContent = this.mainService.post(url, json.toString()); |
| 140 | + JsonObject tmpJson = GsonParser.parse(responseContent); |
| 141 | + return tmpJson.get("chat_id").getAsString(); |
| 142 | + } |
| 143 | + |
160 | 144 | @Override
|
161 | 145 | public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList,
|
162 | 146 | String cursor,
|
@@ -586,7 +570,7 @@ public WxCpGroupMsgListResult getGroupMsgListV2(String chatType, @NonNull Date s
|
586 | 570 | json.addProperty("limit", limit);
|
587 | 571 | json.addProperty("cursor", cursor);
|
588 | 572 |
|
589 |
| - final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_SEND_RESULT); |
| 573 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_LIST_V2); |
590 | 574 | final String result = this.mainService.post(url, json.toString());
|
591 | 575 | return WxCpGroupMsgListResult.fromJson(result);
|
592 | 576 | }
|
@@ -636,8 +620,86 @@ public WxCpGroupMsgTaskResult getGroupMsgTask(String msgid, Integer limit, Strin
|
636 | 620 | json.addProperty("limit", limit);
|
637 | 621 | json.addProperty("cursor", cursor);
|
638 | 622 |
|
639 |
| - final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_SEND_RESULT); |
| 623 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_TASK); |
640 | 624 | final String result = this.mainService.post(url, json.toString());
|
641 | 625 | return WxCpGroupMsgTaskResult.fromJson(result);
|
642 | 626 | }
|
| 627 | + |
| 628 | + /** |
| 629 | + * <pre> |
| 630 | + * 添加入群欢迎语素材。 |
| 631 | + * https://open.work.weixin.qq.com/api/doc/90000/90135/92366#添加入群欢迎语素材 |
| 632 | + * </pre> |
| 633 | + * |
| 634 | + * @param template 素材内容 |
| 635 | + * @return template_id 欢迎语素材id |
| 636 | + * @throws WxErrorException the wx error exception |
| 637 | + */ |
| 638 | + @Override |
| 639 | + public String addGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException { |
| 640 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_ADD); |
| 641 | + final String responseContent = this.mainService.post(url, template.toJson()); |
| 642 | + JsonObject tmpJson = GsonParser.parse(responseContent); |
| 643 | + return tmpJson.get("template_id").getAsString(); |
| 644 | + } |
| 645 | + |
| 646 | + /** |
| 647 | + * <pre> |
| 648 | + * 编辑入群欢迎语素材。 |
| 649 | + * https://open.work.weixin.qq.com/api/doc/90000/90135/92366#编辑入群欢迎语素材 |
| 650 | + * </pre> |
| 651 | + * |
| 652 | + * @param template |
| 653 | + * @return wx cp base resp |
| 654 | + * @throws WxErrorException the wx error exception |
| 655 | + */ |
| 656 | + @Override |
| 657 | + public WxCpBaseResp editGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException { |
| 658 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_EDIT); |
| 659 | + final String result = this.mainService.post(url, template.toJson()); |
| 660 | + return WxCpGroupWelcomeTemplateResult.fromJson(result); |
| 661 | + } |
| 662 | + |
| 663 | + /** |
| 664 | + * <pre> |
| 665 | + * 获取入群欢迎语素材。 |
| 666 | + * https://open.work.weixin.qq.com/api/doc/90000/90135/92366#获取入群欢迎语素材 |
| 667 | + * </pre> |
| 668 | + * |
| 669 | + * @param templateId 群欢迎语的素材id |
| 670 | + * @return wx cp base resp |
| 671 | + * @throws WxErrorException the wx error exception |
| 672 | + */ |
| 673 | + @Override |
| 674 | + public WxCpGroupWelcomeTemplateResult getGroupWelcomeTemplate(@NotNull String templateId) throws WxErrorException { |
| 675 | + JsonObject json = new JsonObject(); |
| 676 | + json.addProperty("template_id", templateId); |
| 677 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_GET); |
| 678 | + final String result = this.mainService.post(url, json.toString()); |
| 679 | + return WxCpGroupWelcomeTemplateResult.fromJson(result); |
| 680 | + } |
| 681 | + |
| 682 | + /** |
| 683 | + * <pre> |
| 684 | + * 删除入群欢迎语素材。 |
| 685 | + * 企业可通过此API删除入群欢迎语素材,且仅能删除调用方自己创建的入群欢迎语素材。 |
| 686 | + * https://open.work.weixin.qq.com/api/doc/90000/90135/92366#删除入群欢迎语素材 |
| 687 | + * </pre> |
| 688 | + * |
| 689 | + * @param templateId 群欢迎语的素材id |
| 690 | + * @param agentId |
| 691 | + * @return wx cp base resp |
| 692 | + * @throws WxErrorException the wx error exception |
| 693 | + */ |
| 694 | + @Override |
| 695 | + public WxCpBaseResp delGroupWelcomeTemplate(@NotNull String templateId, String agentId) throws WxErrorException { |
| 696 | + JsonObject json = new JsonObject(); |
| 697 | + json.addProperty("template_id", templateId); |
| 698 | + if (!StringUtils.isEmpty(agentId)) { |
| 699 | + json.addProperty("agentid", agentId); |
| 700 | + } |
| 701 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_DEL); |
| 702 | + final String result = this.mainService.post(url, json.toString()); |
| 703 | + return WxCpBaseResp.fromJson(result); |
| 704 | + } |
643 | 705 | }
|
0 commit comments