🆕 #3725【企业微信】 增加markdown_v2的消息类型支持
This commit is contained in:
@@ -70,6 +70,23 @@ public interface WxCpGroupRobotService {
|
||||
*/
|
||||
void sendMarkdown(String webhookUrl, String content) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 发送markdown_v2类型的消息
|
||||
*
|
||||
* @param content markdown内容,最长不超过4096个字节,必须是utf8编码
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
void sendMarkdownV2(String content) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 发送markdown_v2类型的消息
|
||||
*
|
||||
* @param webhookUrl webhook地址
|
||||
* @param content markdown内容,最长不超过4096个字节,必须是utf8编码
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
void sendMarkdownV2(String webhookUrl, String content) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 发送image类型的消息
|
||||
*
|
||||
|
||||
@@ -42,6 +42,11 @@ public class WxCpGroupRobotServiceImpl implements WxCpGroupRobotService {
|
||||
this.sendMarkdown(this.getWebhookUrl(), content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMarkdownV2(String content) throws WxErrorException {
|
||||
this.sendMarkdownV2(this.getWebhookUrl(), content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendImage(String base64, String md5) throws WxErrorException {
|
||||
this.sendImage(this.getWebhookUrl(), base64, md5);
|
||||
@@ -70,6 +75,14 @@ public class WxCpGroupRobotServiceImpl implements WxCpGroupRobotService {
|
||||
.toJson());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMarkdownV2(String webhookUrl, String content) throws WxErrorException {
|
||||
this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage()
|
||||
.setMsgType(GroupRobotMsgType.MARKDOWN_V2)
|
||||
.setContent(content)
|
||||
.toJson());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendImage(String webhookUrl, String base64, String md5) throws WxErrorException {
|
||||
this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage()
|
||||
|
||||
@@ -252,6 +252,12 @@ public class WxCpGroupRobotMessage implements Serializable {
|
||||
messageJson.add("markdown", text);
|
||||
break;
|
||||
}
|
||||
case MARKDOWN_V2: {
|
||||
JsonObject text = new JsonObject();
|
||||
text.addProperty("content", this.getContent());
|
||||
messageJson.add("markdown_v2", text);
|
||||
break;
|
||||
}
|
||||
case IMAGE: {
|
||||
JsonObject text = new JsonObject();
|
||||
text.addProperty("base64", this.getBase64());
|
||||
|
||||
@@ -630,6 +630,11 @@ public class WxCpConsts {
|
||||
*/
|
||||
public static final String MARKDOWN = "markdown";
|
||||
|
||||
/**
|
||||
* markdown_v2消息.
|
||||
*/
|
||||
public static final String MARKDOWN_V2 = "markdown_v2";
|
||||
|
||||
/**
|
||||
* 图文消息(点击跳转到外链).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user