|
|
package cn.teammodel;
|
|
|
|
|
|
import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
import com.dingtalk.api.DingTalkClient;
|
|
|
import com.dingtalk.api.request.OapiRobotSendRequest;
|
|
|
import com.dingtalk.api.response.OapiRobotSendResponse;
|
|
|
import com.taobao.api.ApiException;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
/**
|
|
|
* @author winter
|
|
|
* @create 2023-11-10 10:42
|
|
|
*/
|
|
|
public class TestWithoutSpring {
|
|
|
@Test
|
|
|
public void testJwtDecode() {
|
|
|
// Claims claims = null;
|
|
|
// try {
|
|
|
// Jwts.parser()
|
|
|
//
|
|
|
//
|
|
|
//// claims = Jwts.parser()
|
|
|
//// .setSigningKey("fXO6ko/qyXeYrkecPeKdgXnuLXf9vMEtnBC9OB3s+aA=")
|
|
|
//// .parseClaimsJws("eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0LnRlYW1tb2RlbC5jbiIsInN1YiI6IjE1OTUzMjEzNTQiLCJhenAiOiJoYmNuIiwiZXhwIjoxNjk5NTg2MzM1LCJuYW1lIjoi572X6ICB5biIIiwicGljdHVyZSI6Imh0dHBzOi8vY29yZXN0b3JhZ2VzZXJ2aWNlLmJsb2IuY29yZS5jaGluYWNsb3VkYXBpLmNuL2FjY291bnQvYXZhdGFyLzE1OTUzMjEzNTQiLCJyb2xlcyI6WyJ0ZWFjaGVyIiwiYWRtaW4iLCJhcmVhIl0sInBlcm1pc3Npb25zIjpbXSwic3RhbmRhcmQiOiJzdGFuZGFyZDEiLCJzY29wZSI6InRlYWNoZXIiLCJhcmVhIjoiNjllM2Q0MTMtNTBhMS00ZjVlLTg0NGEtZTBmN2M5NjIyZWEzIiwid2Vic2l0ZSI6IklFUyJ9.4NdqwDdDQcyberEAirX0srOIb1ADXLJfP-a9qNXb0yw")
|
|
|
//// .getBody();
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testDingDing() throws ApiException {
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6");
|
|
|
OapiRobotSendRequest request = new OapiRobotSendRequest();
|
|
|
request.setMsgtype("text");
|
|
|
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
|
|
|
text.setContent("测试告警文本消息");
|
|
|
request.setText(text);
|
|
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
|
|
at.setAtMobiles(Arrays.asList("15196506772"));
|
|
|
// isAtAll类型如果不为Boolean,请升级至最新SDK
|
|
|
at.setIsAtAll(true);
|
|
|
at.setAtUserIds(Arrays.asList("109929","32099"));
|
|
|
request.setAt(at);
|
|
|
|
|
|
request.setMsgtype("link");
|
|
|
OapiRobotSendRequest.Link link = new OapiRobotSendRequest.Link();
|
|
|
link.setMessageUrl("https://www.dingtalk.com/");
|
|
|
link.setPicUrl("");
|
|
|
link.setTitle("告警时代的火车向前开");
|
|
|
link.setText("告警这个即将发布的新版本,创始人xx称它为红树林。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是红树林");
|
|
|
request.setLink(link);
|
|
|
|
|
|
request.setMsgtype("markdown");
|
|
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
|
|
markdown.setTitle("杭州天气");
|
|
|
markdown.setText("#### 告警杭州天气 @156xxxx8827\n" +
|
|
|
"> 9度,西北风1级,空气良89,相对温度73%\n\n" +
|
|
|
"> \n" +
|
|
|
"> ###### 10点20分发布 [天气](http://www.thinkpage.cn/) \n");
|
|
|
request.setMarkdown(markdown);
|
|
|
OapiRobotSendResponse response = client.execute(request);
|
|
|
}
|
|
|
}
|