Commit 29f3a17a authored by 孙路路's avatar 孙路路

钉钉机器人支持at到人

parent 7e60c511
......@@ -28,7 +28,7 @@ public class DingTalkSendMsgServiceImpl implements DingTalkSendMsgService {
@Override
public boolean sendTextMsg(String content, String accessToken, String keyWords) {
return DingTalkSendMsgUtil.sendTextMsg(content, accessToken, keyWords);
return DingTalkSendMsgUtil.sendTextMsg(content,null, accessToken, keyWords);
}
public DingTalkSendMsgServiceImpl(DingTalkWebHookProperties dingTalkWebHookProperties) {
......
......@@ -7,6 +7,8 @@ import com.dingtalk.api.response.OapiRobotSendResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.util.Arrays;
/**
* @Describe:
* @Created by tangfeng 2020-07-07 19:58
......@@ -21,10 +23,15 @@ public class DingTalkSendMsgUtil {
*/
public static boolean sendTextMsg(String content, String accessToken) {
return sendTextMsg(content, accessToken, null);
return sendTextMsg(content,null, accessToken, null);
}
public static boolean sendTextMsg(String content, String accessToken, String keyWords) {
public static boolean sendTextMsgAt(String content,String mobiles, String accessToken) {
return sendTextMsg(content,mobiles, accessToken, null);
}
public static boolean sendTextMsg(String content, String mobiles, String accessToken, String keyWords) {
Assert.notNull(content, "消息内容不能为空");
Assert.notNull(accessToken, "accessToken不能为空");
......@@ -40,6 +47,14 @@ public class DingTalkSendMsgUtil {
request.setMsgtype("text");
request.setText(text);
if (StringUtils.isNotEmpty(mobiles)){
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
at.setAtMobiles(Arrays.asList(mobiles.split(",")));
// isAtAll类型如果不为Boolean,请升级至最新SDK
at.setIsAtAll(true);
request.setAt(at);
}
OapiRobotSendResponse response = client.execute(request);
//System.out.println(JSONObject.toJSONString(response));
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment