Merge branch 'feature/REQ-3117' into 'master'
Feature/req 3117 See merge request universal/infrastructure/backend/riven!68
This commit is contained in:
commit
76ddbe7636
@ -1,6 +1,7 @@
|
||||
package cn.axzo.riven.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootMsgReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -13,10 +14,23 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
public interface DingDingMsgApi {
|
||||
/**
|
||||
* 发送钉钉消息
|
||||
*
|
||||
* 正对于单个人进行发送
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/dingDing/reboot/msg/send")
|
||||
ApiResult<Void> sendRebootMsg(@RequestBody DingDingSendRebootMsgReq req);
|
||||
|
||||
|
||||
/**
|
||||
* 发送钉钉消息
|
||||
* 给单个群发送
|
||||
* 目前只能给一个APPKEY,发送,后续扩展支持多个
|
||||
* 目前只能支持2个横着的按钮发送,其他类型,理论支持,但是需要验证
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/dingDing/reboot/groupMsg/send")
|
||||
ApiResult<Void> sendRebootGroupMsg(@RequestBody DingDingSendRebootGroupMsgReq req);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.axzo.riven.client.model;
|
||||
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author zhongpeng
|
||||
* @since 2024-11-14 14:01
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SampleActionCard6 implements ReplyMessage<SampleActionCard6> {
|
||||
String title;
|
||||
String text;
|
||||
|
||||
String buttonTitle1;
|
||||
String buttonUrl1;
|
||||
String buttonTitle2;
|
||||
String buttonUrl2;
|
||||
|
||||
@Override
|
||||
public DingTalkMsgTypeEnum msgType() {
|
||||
return DingTalkMsgTypeEnum.sampleActionCard6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleActionCard6 messageBody() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static SampleActionCard6 from(String title, String text, String buttonTitle1, String buttonUrl1, String buttonTitle2, String buttonUrl2) {
|
||||
return new SampleActionCard6(title, text, buttonTitle1, buttonUrl1, buttonTitle2, buttonUrl2);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,9 @@ package cn.axzo.riven.client.model;
|
||||
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 简单的 MD 内容
|
||||
@ -11,10 +13,11 @@ import lombok.Data;
|
||||
* @since 2024-10-24 14:01
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SampleMarkdown implements ReplyMessage<SampleMarkdown> {
|
||||
private final String title;
|
||||
private final String text;
|
||||
private String title;
|
||||
private String text;
|
||||
|
||||
@Override
|
||||
public DingTalkMsgTypeEnum msgType() {
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import com.google.common.base.Strings;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -18,6 +19,7 @@ import static com.google.common.net.HttpHeaders.X_REQUEST_ID;
|
||||
* @since 2024-10-24 17:14
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SampleMessageQueue implements ReplyMessage<SampleMessageQueue> {
|
||||
private String applicationName;
|
||||
|
||||
@ -13,7 +13,7 @@ import lombok.Data;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class SampleText implements ReplyMessage<SampleText> {
|
||||
private final String content;
|
||||
private String content;
|
||||
|
||||
@Override
|
||||
public DingTalkMsgTypeEnum msgType() {
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.riven.client.req;
|
||||
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import cn.axzo.riven.client.model.ReplyMessage;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhognpeng@axzo.cn
|
||||
*/
|
||||
@Data
|
||||
public class DingDingSendRebootGroupMsgReq {
|
||||
/**
|
||||
* 消息类型
|
||||
* 目前支持sampleActionCard6,其他待补充
|
||||
*/
|
||||
private DingTalkMsgTypeEnum msgType;
|
||||
/**
|
||||
* 消息内容
|
||||
* 目前支持SampleActionCard6,其他待补充
|
||||
* 其中的消息,为:markdown格式的消息,,具体见:https://open.dingtalk.com/document/orgapp/message-types-and-data-format#
|
||||
* ReplyMessage的实现类,并进行调用其:toJson方法得到的字符串
|
||||
*/
|
||||
private String dingDingJson;
|
||||
|
||||
/**
|
||||
* 业务场景code,为了灵活支持多个消息发送,此处直接采用字符串,与nacos中的钉钉群配置一一对应
|
||||
* 对应nacos:reboot.group.list[].dingDingScene
|
||||
* 暂时不支持对多个群发送,如有需求,可以进行改造
|
||||
*/
|
||||
private String dingDingScene;
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.axzo.riven.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后续其他钉钉配置,可以收口到这里
|
||||
* @author zhongpeng@axzo.cn
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "reboot.group")
|
||||
public class DingDingRebootMainConfig {
|
||||
|
||||
List<DingDingConfigDTO> list;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class DingDingConfigDTO {
|
||||
private String appKey;
|
||||
private String appSecret;
|
||||
private Long agentId;
|
||||
//机器人的ID
|
||||
private String rebootCode;
|
||||
//群的ID,可以升级为支持多个群
|
||||
private String openConversationId;
|
||||
//场景字符串,唯一
|
||||
private String dingDingScene;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,9 +2,13 @@ package cn.axzo.riven.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.riven.client.feign.DingDingMsgApi;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootMsgReq;
|
||||
import cn.axzo.riven.service.DingDingRebootService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@ -12,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DingDingMsgController implements DingDingMsgApi {
|
||||
private final DingDingRebootService dingDingRebootService;
|
||||
|
||||
@ -20,4 +26,11 @@ public class DingDingMsgController implements DingDingMsgApi {
|
||||
dingDingRebootService.sendCorpRebbootMsg(req);
|
||||
return ApiResult.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> sendRebootGroupMsg(DingDingSendRebootGroupMsgReq req) {
|
||||
log.info("sendRebootGroupMsg={}", JSON.toJSONString(req));
|
||||
dingDingRebootService.sendCorpRebootGroupMsg(req);
|
||||
return ApiResult.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package cn.axzo.riven.manger;
|
||||
|
||||
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.axzo.riven.common.constants.RedisKeyConstant;
|
||||
import cn.axzo.riven.common.util.Throws;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketResponse;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketResponseBody;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest;
|
||||
@ -14,6 +16,7 @@ import com.aliyun.dingtalkoauth2_1_0.models.GetCorpAccessTokenResponse;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetCorpAccessTokenResponseBody;
|
||||
import com.aliyun.dingtalkrobot_1_0.models.BatchSendOTOHeaders;
|
||||
import com.aliyun.dingtalkrobot_1_0.models.BatchSendOTORequest;
|
||||
import com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -23,6 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -143,4 +147,39 @@ public class DingDingNewSdkManger {
|
||||
LogUtil.error(LogUtil.ErrorLevel.P1, LogUtil.ErrorType.ERROR_THIRD_SERVICE, "RPC钉钉系统异常,api={},", api, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGroupMessage(String accessToken, String rebootCode, String openConversationId, DingDingSendRebootGroupMsgReq req) {
|
||||
|
||||
com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendHeaders orgGroupSendHeaders = new com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendHeaders();
|
||||
orgGroupSendHeaders.xAcsDingtalkAccessToken = accessToken;
|
||||
com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendRequest orgGroupSendRequest = new com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendRequest();
|
||||
|
||||
orgGroupSendRequest.setRobotCode(rebootCode);
|
||||
orgGroupSendRequest.setOpenConversationId(openConversationId);
|
||||
orgGroupSendRequest.setMsgKey(req.getMsgType().toString());
|
||||
|
||||
orgGroupSendRequest.setMsgParam(req.getDingDingJson());
|
||||
|
||||
log.info("sendGroupMessage, orgGroupSendRequest={},accessToken={}", JSON.toJSONString(orgGroupSendRequest), accessToken);
|
||||
|
||||
try {
|
||||
OrgGroupSendResponse response = dingTalkRobotClient.orgGroupSendWithOptions(orgGroupSendRequest, orgGroupSendHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
log.info("sendGroupMessage, response={}", JSON.toJSONString(response));
|
||||
if (Objects.isNull(response) || Objects.isNull(response.getBody())) {
|
||||
log.error("sendGroupMessage orgGroupSendWithOptions return error, response={}",
|
||||
response);
|
||||
return;
|
||||
}
|
||||
String processQueryKey = response.getBody().getProcessQueryKey();
|
||||
log.info("发送钉钉群消息 返回消息 ID:{}", processQueryKey);
|
||||
} catch (TeaException e) {
|
||||
log.error("sendGroupMessage orgGroupSendWithOptions throw TeaException, errCode={}, " +
|
||||
"errorMessage={}", e.getCode(), e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("sendGroupMessage error", e);
|
||||
throw Throws.bizDefaultException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,11 +2,13 @@ package cn.axzo.riven.service;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootMsgReq;
|
||||
import cn.axzo.riven.common.constants.DingDingJumpConstant;
|
||||
import cn.axzo.riven.common.util.Throws;
|
||||
import cn.axzo.riven.config.DeliverConfig;
|
||||
import cn.axzo.riven.config.DingDingRebootConfig;
|
||||
import cn.axzo.riven.config.DingDingRebootMainConfig;
|
||||
import cn.axzo.riven.gateway.OrganizationalNodeUserApiGateway;
|
||||
import cn.axzo.riven.manger.DingDingNewSdkManger;
|
||||
import cn.axzo.riven.repository.entity.ThirdPartyUser;
|
||||
@ -18,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -38,6 +37,10 @@ public class DingDingRebootService {
|
||||
private DingDingRebootConfig dingRebootConfig;
|
||||
@Autowired
|
||||
private DeliverConfig deliverConfig;
|
||||
|
||||
@Autowired
|
||||
private DingDingRebootMainConfig dingDingRebootMainConfig;
|
||||
|
||||
@Autowired
|
||||
private OrganizationalNodeUserApiGateway organizationalNodeUserApiGateway;
|
||||
|
||||
@ -46,12 +49,12 @@ public class DingDingRebootService {
|
||||
|
||||
// 非生产环境mock
|
||||
String env = SpringUtil.getActiveProfile();
|
||||
if(!"master".equals(env)) {
|
||||
if (!"master".equals(env)) {
|
||||
// 取交集
|
||||
List<String> tmp = Arrays.asList(dingRebootConfig.getMockPersonIds().split(","));
|
||||
List<Long> mockIds = tmp.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
Collection<Long> intersection = org.apache.commons.collections4.CollectionUtils.intersection(mockIds, req.getPersonIds());
|
||||
if(CollectionUtils.isEmpty(intersection)) {
|
||||
if (CollectionUtils.isEmpty(intersection)) {
|
||||
return;
|
||||
}
|
||||
req.setPersonIds(new ArrayList<>(intersection));
|
||||
@ -88,4 +91,32 @@ public class DingDingRebootService {
|
||||
dingDingNewSdkManger.robotoToMessagesBatchSend(accessToken.getAccessToken(), dingRebootConfig.getRebootCode(), dingUserIds.subList(i, i + sendLength), req.getMsgType(), JSONUtil.toJsonStr(req.getSampleActionCard()));
|
||||
}
|
||||
}
|
||||
|
||||
public void sendCorpRebootGroupMsg(DingDingSendRebootGroupMsgReq req) {
|
||||
|
||||
//根据场景选择对应的配置
|
||||
DingDingRebootMainConfig.DingDingConfigDTO dto = getByScene(req.getDingDingScene());
|
||||
//获取token
|
||||
GetAccessTokenResponseBody accessToken = dingDingNewSdkManger.getAccessToken(dto.getAppKey(), dto.getAppSecret());
|
||||
//发送消息
|
||||
dingDingNewSdkManger.sendGroupMessage(accessToken.getAccessToken(), dto.getRebootCode(), dto.getOpenConversationId(), req);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务场景匹配对应的发送钉钉配置
|
||||
* @param dingDingScene
|
||||
* @return
|
||||
*/
|
||||
private DingDingRebootMainConfig.DingDingConfigDTO getByScene(String dingDingScene) {
|
||||
|
||||
if (Objects.nonNull(dingDingScene) && !CollectionUtils.isEmpty(dingDingRebootMainConfig.getList())) {
|
||||
for (DingDingRebootMainConfig.DingDingConfigDTO dto : dingDingRebootMainConfig.getList()) {
|
||||
if (dingDingScene.equals(dto.getDingDingScene())) {
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw Throws.bizException(BaseCode.UNAVAILABLE_FOR_LEGAL_REASONS, "发送钉钉群的业务场景对应配置不存在,请检查配置和业务场景的对应关系");
|
||||
}
|
||||
}
|
||||
|
||||
25
riven-server/src/main/resources/application-local.yml
Normal file
25
riven-server/src/main/resources/application-local.yml
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
##钉钉群消息发送配置
|
||||
reboot:
|
||||
group:
|
||||
list:
|
||||
#场景-运营通知
|
||||
#dingDingScene必须唯一,其他随意
|
||||
- dingDingScene: WORK_OPERATION
|
||||
appKey: dingx9pejjkh8whnaqkw
|
||||
appSecret: IViT8sL_VVZ03gRc3oIvbtzS0DsTKUI9pLgXSNh9FErHgzFR_97liY5g6SpmJpjk
|
||||
#暂时未使用
|
||||
agentId: 3286362019
|
||||
#机器人ID
|
||||
rebootCode: dingx9pejjkh8whnaqkw
|
||||
#群ID
|
||||
openConversationId: cidAy86bIrB513xUaCOmvD/Hg==
|
||||
#场景-公用告警通知,待补充
|
||||
- dingDingScene: COMMON_ALERT
|
||||
appKey: 待补充
|
||||
appSecret: 待补充
|
||||
agentId: 0
|
||||
#机器人ID
|
||||
rebootCode: 待补充
|
||||
#群ID
|
||||
openConversationId: 待补充
|
||||
@ -17,4 +17,7 @@ spring:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
server:
|
||||
shutdown: graceful
|
||||
shutdown: graceful
|
||||
|
||||
|
||||
|
||||
|
||||
18
riven-server/src/test/java/cn/axzo/riven/test/BaseTest.java
Normal file
18
riven-server/src/test/java/cn/axzo/riven/test/BaseTest.java
Normal file
@ -0,0 +1,18 @@
|
||||
package cn.axzo.riven.test;
|
||||
|
||||
import cn.axzo.riven.Application;
|
||||
import cn.azxo.framework.common.logger.JobLoggerTemplate;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
/**
|
||||
* @author zhongpeng
|
||||
* @date 2024/11/18 16:33
|
||||
*/
|
||||
@SpringBootTest(classes = Application.class)
|
||||
public class BaseTest {
|
||||
|
||||
@MockBean
|
||||
JobLoggerTemplate jobLoggerTemplate;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.axzo.riven.test;
|
||||
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import cn.axzo.riven.client.model.SampleActionCard6;
|
||||
import cn.axzo.riven.client.model.SampleMarkdown;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.axzo.riven.controller.DingDingMsgController;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author zhongpeng
|
||||
* @date 2024/11/14 18:17
|
||||
*/
|
||||
public class DingDingMsgControllerTest extends BaseTest {
|
||||
|
||||
|
||||
@Resource
|
||||
private DingDingMsgController dingDingMsgController;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
DingDingSendRebootGroupMsgReq req = new DingDingSendRebootGroupMsgReq();
|
||||
req.setMsgType(DingTalkMsgTypeEnum.sampleActionCard6);
|
||||
|
||||
req.setDingDingScene("WORK_OPERATION");
|
||||
|
||||
String title = "标题";
|
||||
String text = "内容 \n ## 标题1 你好";
|
||||
String buttonTitle1 = "百度";
|
||||
String buttonUrl1 = "http://www.baidu.com";
|
||||
String buttonTitle2 = "MQ";
|
||||
String buttonUrl2 = "https://rocketmq.apache.org/zh/docs/domainModel/02topic/";
|
||||
|
||||
|
||||
SampleActionCard6 sampleActionCard6 = new SampleActionCard6(title,text,buttonTitle1,buttonUrl1,buttonTitle2,buttonUrl2);
|
||||
req.setDingDingJson(sampleActionCard6.toJson());
|
||||
|
||||
dingDingMsgController.sendRebootGroupMsg(req);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
|
||||
DingDingSendRebootGroupMsgReq req = new DingDingSendRebootGroupMsgReq();
|
||||
req.setMsgType(DingTalkMsgTypeEnum.sampleActionCard6);
|
||||
|
||||
req.setDingDingScene("WORK_OPERATION");
|
||||
|
||||
String title = "标题";
|
||||
String text = "内容 \n ## 标题1 你好";
|
||||
|
||||
|
||||
SampleMarkdown sampleMarkdown = new SampleMarkdown(title,text);
|
||||
req.setDingDingJson(sampleMarkdown.toJson());
|
||||
|
||||
dingDingMsgController.sendRebootGroupMsg(req);
|
||||
}
|
||||
|
||||
}
|
||||
490
riven-server/src/test/java/cn/axzo/riven/test/DingDingTest.java
Normal file
490
riven-server/src/test/java/cn/axzo/riven/test/DingDingTest.java
Normal file
@ -0,0 +1,490 @@
|
||||
package cn.axzo.riven.test;
|
||||
|
||||
import cn.axzo.riven.client.model.ReplyMessage;
|
||||
import cn.axzo.riven.client.model.SampleActionCard6;
|
||||
import cn.axzo.riven.client.req.DingDingActionCardDto;
|
||||
import cn.axzo.riven.client.req.DingDingBtnJsonListDto;
|
||||
import cn.axzo.riven.common.util.Throws;
|
||||
import cn.axzo.riven.manger.DingDingNewSdkManger;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dingtalkim_1_0.Client;
|
||||
import com.aliyun.dingtalkim_1_0.models.SendRobotMessageResponse;
|
||||
import com.aliyun.dingtalkrobot_1_0.models.GetBotListInGroupResponse;
|
||||
import com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.*;
|
||||
import com.dingtalk.api.response.*;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.redis.core.script.ReactiveScriptExecutor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongpeng
|
||||
* @date 2024/11/14 14:58
|
||||
*/
|
||||
public class DingDingTest {
|
||||
|
||||
private static final String appKey = "dingx9pejjkh8whnaqkw";
|
||||
private static final String appSecret = "IViT8sL_VVZ03gRc3oIvbtzS0DsTKUI9pLgXSNh9FErHgzFR_97liY5g6SpmJpjk";
|
||||
private static final String agentId = "3286362019";
|
||||
|
||||
|
||||
private static final String robotCode = "dingx9pejjkh8whnaqkw";
|
||||
//需要调用testGetAccessToken获取最新token
|
||||
private static final String token = "24bef3d2e00534b3887eafb5b47d4006";
|
||||
|
||||
private static final String openConversationId = "cidAy86bIrB513xUaCOmvD/Hg==";
|
||||
|
||||
@Test
|
||||
public void testGetAccessToken() throws Exception {
|
||||
OapiGettokenResponse response = getToken();
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
}
|
||||
|
||||
|
||||
private OapiGettokenResponse getToken() throws ApiException {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
||||
OapiGettokenRequest request = new OapiGettokenRequest();
|
||||
request.setAppkey(appKey);
|
||||
request.setAppsecret(appSecret);
|
||||
request.setHttpMethod("GET");
|
||||
OapiGettokenResponse response = client.execute(request);
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws ApiException {
|
||||
|
||||
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
DingDingActionCardDto actionCardDto = new DingDingActionCardDto();
|
||||
|
||||
actionCardDto.setTitle("标题");
|
||||
//消息内容
|
||||
actionCardDto.setMarkdown("消息内容");
|
||||
|
||||
actionCardDto.setSingleTitle(null);
|
||||
actionCardDto.setSingleUrl(null);
|
||||
|
||||
DingDingBtnJsonListDto btnJson1 = new DingDingBtnJsonListDto();
|
||||
btnJson1.setTitle("百度");
|
||||
btnJson1.setActionUrl("www.baidu.com");
|
||||
|
||||
DingDingBtnJsonListDto btnJson2 = new DingDingBtnJsonListDto();
|
||||
btnJson2.setTitle("MQ文档");
|
||||
btnJson2.setActionUrl("https://rocketmq.apache.org/zh/docs/domainModel/02topic/");
|
||||
|
||||
actionCardDto.setBtnJsonList(new ArrayList<>());
|
||||
actionCardDto.getBtnJsonList().add(btnJson1);
|
||||
actionCardDto.getBtnJsonList().add(btnJson2);
|
||||
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
|
||||
|
||||
|
||||
OapiMessageCorpconversationAsyncsendV2Request req = new OapiMessageCorpconversationAsyncsendV2Request();
|
||||
|
||||
req.setAgentId(Long.valueOf(agentId));
|
||||
|
||||
|
||||
OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
|
||||
|
||||
msg.setActionCard(new OapiMessageCorpconversationAsyncsendV2Request.ActionCard());
|
||||
msg.getActionCard().setTitle(actionCardDto.getTitle());
|
||||
msg.getActionCard().setMarkdown(actionCardDto.getMarkdown());
|
||||
msg.getActionCard().setSingleTitle(actionCardDto.getSingleTitle());
|
||||
msg.getActionCard().setSingleUrl(actionCardDto.getSingleUrl());
|
||||
msg.getActionCard().setBtnOrientation(actionCardDto.getBtnOrientation());
|
||||
if (!CollectionUtils.isEmpty(actionCardDto.getBtnJsonList())) {
|
||||
List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList = new ArrayList<>();
|
||||
actionCardDto.getBtnJsonList().forEach(item -> {
|
||||
OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList btnJsonList1 = new OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList();
|
||||
btnJsonList1.setActionUrl(item.getActionUrl());
|
||||
btnJsonList1.setTitle(item.getTitle());
|
||||
|
||||
btnJsonList.add(btnJsonList1);
|
||||
});
|
||||
msg.getActionCard().setBtnJsonList(btnJsonList);
|
||||
|
||||
//0:竖直排列
|
||||
//1:横向排列
|
||||
msg.getActionCard().setBtnOrientation("1");
|
||||
}
|
||||
|
||||
msg.setMsgtype("action_card");
|
||||
req.setMsg(msg);
|
||||
req.setToAllUser(true);
|
||||
|
||||
req.getHeaderMap().put("chatId", "1231");
|
||||
|
||||
|
||||
OapiMessageCorpconversationAsyncsendV2Response rsp;
|
||||
try {
|
||||
rsp = client.execute(req, token);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
System.out.println(JSON.toJSONString(rsp));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test() throws ApiException {
|
||||
|
||||
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
DingDingActionCardDto actionCardDto = new DingDingActionCardDto();
|
||||
|
||||
actionCardDto.setTitle("标题");
|
||||
//消息内容
|
||||
actionCardDto.setMarkdown("消息内容");
|
||||
|
||||
actionCardDto.setSingleTitle(null);
|
||||
actionCardDto.setSingleUrl(null);
|
||||
|
||||
DingDingBtnJsonListDto btnJson1 = new DingDingBtnJsonListDto();
|
||||
btnJson1.setTitle("百度");
|
||||
btnJson1.setActionUrl("www.baidu.com");
|
||||
|
||||
DingDingBtnJsonListDto btnJson2 = new DingDingBtnJsonListDto();
|
||||
btnJson2.setTitle("MQ文档");
|
||||
btnJson2.setActionUrl("https://rocketmq.apache.org/zh/docs/domainModel/02topic/");
|
||||
|
||||
actionCardDto.setBtnJsonList(new ArrayList<>());
|
||||
actionCardDto.getBtnJsonList().add(btnJson1);
|
||||
actionCardDto.getBtnJsonList().add(btnJson2);
|
||||
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartbot/msg/push");
|
||||
OapiSmartbotMsgPushRequest req = new OapiSmartbotMsgPushRequest();
|
||||
|
||||
OapiSmartbotMsgPushRequest.Msg msg = new OapiSmartbotMsgPushRequest.Msg();
|
||||
|
||||
msg.setActionCard(new OapiSmartbotMsgPushRequest.ActionCard());
|
||||
msg.getActionCard().setTitle(actionCardDto.getTitle());
|
||||
msg.getActionCard().setMarkdown(actionCardDto.getMarkdown());
|
||||
msg.getActionCard().setSingleTitle(actionCardDto.getSingleTitle());
|
||||
msg.getActionCard().setSingleUrl(actionCardDto.getSingleUrl());
|
||||
msg.getActionCard().setBtnOrientation(actionCardDto.getBtnOrientation());
|
||||
if (!CollectionUtils.isEmpty(actionCardDto.getBtnJsonList())) {
|
||||
List<OapiSmartbotMsgPushRequest.BtnJson> btnJsonList = new ArrayList<>();
|
||||
actionCardDto.getBtnJsonList().forEach(item -> {
|
||||
OapiSmartbotMsgPushRequest.BtnJson btnJsonList1 = new OapiSmartbotMsgPushRequest.BtnJson();
|
||||
btnJsonList1.setActionUrl(item.getActionUrl());
|
||||
btnJsonList1.setTitle(item.getTitle());
|
||||
btnJsonList.add(btnJsonList1);
|
||||
});
|
||||
msg.getActionCard().setBtnJsonList(btnJsonList);
|
||||
}
|
||||
|
||||
msg.setMsgtype("action_card");
|
||||
req.setMsg(msg);
|
||||
req.setUserIdList(null);
|
||||
req.setToAllUser(null);
|
||||
OapiSmartbotMsgPushResponse rsp;
|
||||
try {
|
||||
rsp = client.execute(req, token);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(LogUtil.ErrorLevel.P1, LogUtil.ErrorType.ERROR_THIRD_SERVICE, "RPC钉钉系统异常,api={},", "smartBotMsgPush", e);
|
||||
throw Throws.bizDefaultException();
|
||||
}
|
||||
|
||||
System.out.println(JSON.toJSONString(rsp));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test3() {
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
try {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/chat/get");
|
||||
OapiChatGetRequest req = new OapiChatGetRequest();
|
||||
req.setHttpMethod("GET");
|
||||
OapiChatGetResponse rsp = client.execute(req, token);
|
||||
System.out.println(JSON.toJSONString(rsp));
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createGroup() {
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
try {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/chat/get");
|
||||
OapiChatGetRequest req = new OapiChatGetRequest();
|
||||
req.setHttpMethod("GET");
|
||||
OapiChatGetResponse rsp = client.execute(req, token);
|
||||
System.out.println(JSON.toJSONString(rsp));
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//自定义机器人发送消息
|
||||
@Test
|
||||
public void test4() throws ApiException {
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send");
|
||||
OapiRobotSendRequest req = new OapiRobotSendRequest();
|
||||
|
||||
OapiRobotSendRequest.Actioncard actioncard = new OapiRobotSendRequest.Actioncard();
|
||||
|
||||
actioncard.setBtns(new ArrayList<>());
|
||||
actioncard.setTitle("标题");
|
||||
actioncard.setText("内容");
|
||||
|
||||
OapiRobotSendRequest.Btns btns1 = new OapiRobotSendRequest.Btns();
|
||||
btns1.setTitle("百度");
|
||||
btns1.setActionURL("http://www.baidu.com");
|
||||
OapiRobotSendRequest.Btns btns2 = new OapiRobotSendRequest.Btns();
|
||||
|
||||
btns2.setTitle("MQ文档");
|
||||
btns2.setActionURL("https://rocketmq.apache.org/zh/docs/domainModel/02topic/");
|
||||
actioncard.getBtns().add(btns1);
|
||||
actioncard.getBtns().add(btns2);
|
||||
|
||||
req.setMarkdown(new OapiRobotSendRequest.Markdown());
|
||||
req.setMsgtype("action_card");
|
||||
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||
at.setAtMobiles(Arrays.asList("15008222057"));
|
||||
req.setAt(at);
|
||||
|
||||
OapiRobotSendResponse rsp = client.execute(req, token);
|
||||
System.out.println(rsp.getBody());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static com.aliyun.dingtalkim_1_0.Client createClient() throws Exception {
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
||||
config.protocol = "https";
|
||||
config.regionId = "central";
|
||||
return new com.aliyun.dingtalkim_1_0.Client(config);
|
||||
}
|
||||
|
||||
//企业机器人发送消息,无权限
|
||||
@Test
|
||||
public void test5() throws Exception {
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
com.aliyun.dingtalkim_1_0.Client client = createClient();
|
||||
|
||||
|
||||
com.aliyun.dingtalkim_1_0.models.SendRobotMessageHeaders sendRobotMessageHeaders = new com.aliyun.dingtalkim_1_0.models.SendRobotMessageHeaders();
|
||||
sendRobotMessageHeaders.xAcsDingtalkAccessToken = token;
|
||||
com.aliyun.dingtalkim_1_0.models.SendRobotMessageRequest sendRobotMessageRequest = new com.aliyun.dingtalkim_1_0.models.SendRobotMessageRequest();
|
||||
|
||||
//发送多个群
|
||||
sendRobotMessageRequest.setOpenConversationIds(Arrays.asList("cidAy86bIrB513xUaCOmvD/Hg=="));
|
||||
sendRobotMessageRequest.setMsgType("action_card");
|
||||
|
||||
sendRobotMessageRequest.setMsgContent("消息内容");
|
||||
|
||||
|
||||
try {
|
||||
SendRobotMessageResponse response = client.sendRobotMessageWithOptions(sendRobotMessageRequest, sendRobotMessageHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
} catch (TeaException err) {
|
||||
err.printStackTrace();
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
} catch (Exception _err) {
|
||||
_err.printStackTrace();
|
||||
|
||||
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// OapiRobotSendRequest req = new OapiRobotSendRequest();
|
||||
//
|
||||
// OapiRobotSendRequest.Actioncard actioncard = new OapiRobotSendRequest.Actioncard();
|
||||
//
|
||||
// actioncard.setBtns(new ArrayList<>());
|
||||
// actioncard.setTitle("标题");
|
||||
// actioncard.setText("内容");
|
||||
//
|
||||
// OapiRobotSendRequest.Btns btns1 = new OapiRobotSendRequest.Btns();
|
||||
// btns1.setTitle("百度");
|
||||
// btns1.setActionURL("http://www.baidu.com");
|
||||
// OapiRobotSendRequest.Btns btns2 = new OapiRobotSendRequest.Btns();
|
||||
//
|
||||
// btns2.setTitle("MQ文档");
|
||||
// btns2.setActionURL("https://rocketmq.apache.org/zh/docs/domainModel/02topic/");
|
||||
// actioncard.getBtns().add(btns1);
|
||||
// actioncard.getBtns().add(btns2);
|
||||
//
|
||||
// req.setMarkdown(new OapiRobotSendRequest.Markdown());
|
||||
// req.setMsgtype("action_card");
|
||||
// OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||
// at.setAtMobiles(Arrays.asList("15008222057"));
|
||||
// req.setAt(at);
|
||||
//
|
||||
// OapiRobotSendResponse rsp = client.execute(req, token);
|
||||
// System.out.println(rsp.getBody());
|
||||
|
||||
|
||||
}
|
||||
|
||||
//企业机器人发送消息,无权限
|
||||
@Test
|
||||
public void test6() throws Exception {
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
com.aliyun.dingtalkim_1_0.Client client = createClient();
|
||||
|
||||
|
||||
com.aliyun.dingtalkim_1_0.models.SendRobotMessageHeaders sendRobotMessageHeaders = new com.aliyun.dingtalkim_1_0.models.SendRobotMessageHeaders();
|
||||
sendRobotMessageHeaders.xAcsDingtalkAccessToken = token;
|
||||
com.aliyun.dingtalkim_1_0.models.SendRobotMessageRequest sendRobotMessageRequest = new com.aliyun.dingtalkim_1_0.models.SendRobotMessageRequest();
|
||||
|
||||
//发送多个群
|
||||
sendRobotMessageRequest.setOpenConversationIds(Arrays.asList("cidAy86bIrB513xUaCOmvD/Hg=="));
|
||||
sendRobotMessageRequest.setMsgType("action_card");
|
||||
|
||||
sendRobotMessageRequest.setMsgContent("消息内容");
|
||||
|
||||
|
||||
try {
|
||||
SendRobotMessageResponse response = client.sendRobotMessageWithOptions(sendRobotMessageRequest, sendRobotMessageHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
} catch (TeaException err) {
|
||||
err.printStackTrace();
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
} catch (Exception _err) {
|
||||
_err.printStackTrace();
|
||||
|
||||
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static com.aliyun.dingtalkrobot_1_0.Client createClient1() throws Exception {
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
||||
config.protocol = "https";
|
||||
config.regionId = "central";
|
||||
return new com.aliyun.dingtalkrobot_1_0.Client(config);
|
||||
}
|
||||
|
||||
//企业机器人,通过群的openConversationId,获取群的机器人
|
||||
@Test
|
||||
public void test7() throws Exception {
|
||||
|
||||
String token = "8b154088e6f235fa8155daffca12b6cc";
|
||||
|
||||
|
||||
com.aliyun.dingtalkrobot_1_0.Client client = createClient1();
|
||||
com.aliyun.dingtalkrobot_1_0.models.GetBotListInGroupHeaders getBotListInGroupHeaders = new com.aliyun.dingtalkrobot_1_0.models.GetBotListInGroupHeaders();
|
||||
getBotListInGroupHeaders.xAcsDingtalkAccessToken = token;
|
||||
com.aliyun.dingtalkrobot_1_0.models.GetBotListInGroupRequest getBotListInGroupRequest = new com.aliyun.dingtalkrobot_1_0.models.GetBotListInGroupRequest();
|
||||
|
||||
|
||||
getBotListInGroupRequest.setOpenConversationId(openConversationId);
|
||||
try {
|
||||
GetBotListInGroupResponse response = client.getBotListInGroupWithOptions(getBotListInGroupRequest, getBotListInGroupHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
} catch (TeaException err) {
|
||||
err.printStackTrace();
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
} catch (Exception _err) {
|
||||
_err.printStackTrace();
|
||||
|
||||
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//企业机器人发送消息,指定群发送带有2个按钮的消息卡片
|
||||
@Test
|
||||
public void test8() throws Exception {
|
||||
|
||||
com.aliyun.dingtalkrobot_1_0.Client client = createClient1();
|
||||
|
||||
|
||||
com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendHeaders orgGroupSendHeaders = new com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendHeaders();
|
||||
orgGroupSendHeaders.xAcsDingtalkAccessToken = token;
|
||||
com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendRequest orgGroupSendRequest = new com.aliyun.dingtalkrobot_1_0.models.OrgGroupSendRequest();
|
||||
|
||||
orgGroupSendRequest.setRobotCode(robotCode);
|
||||
orgGroupSendRequest.setOpenConversationId(openConversationId);
|
||||
orgGroupSendRequest.setMsgKey("sampleActionCard");
|
||||
|
||||
// SampleActionCard6 replyMessage = new SampleActionCard6("标题","内容");
|
||||
|
||||
JSONObject actionCard = new JSONObject();
|
||||
actionCard.put("title","标题");
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("## ").append("标题");
|
||||
stringBuilder.append(" \n ");
|
||||
stringBuilder.append("123241rfewqf");
|
||||
|
||||
actionCard.put("text",stringBuilder.toString());
|
||||
actionCard.put("buttonTitle1","百度");
|
||||
actionCard.put("buttonUrl1","http://www.baidu.com");
|
||||
actionCard.put("buttonTitle2","MQ");
|
||||
actionCard.put("buttonUrl2","https://rocketmq.apache.org/zh/docs/domainModel/02topic/");
|
||||
|
||||
orgGroupSendRequest.setMsgParam(actionCard.toJSONString());
|
||||
|
||||
try {
|
||||
OrgGroupSendResponse response = client.orgGroupSendWithOptions(orgGroupSendRequest, orgGroupSendHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
} catch (TeaException err) {
|
||||
err.printStackTrace();
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
} catch (Exception _err) {
|
||||
_err.printStackTrace();
|
||||
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user