com.hn.robot.dingtalk.domain.TextMsg Maven / Gradle / Ivy
package com.hn.robot.dingtalk.domain;
import cn.hutool.json.JSONUtil;
/**
* 描述: 钉钉消息
*
* @author shilvfei
*/
public class TextMsg {
/**
* 消息类型
*/
private String msgtype;
/**
* 只有text类型 这个字段才生效
*/
private At at;
/**
* 消息对象
* 最后转成json的时候,需要将[msgContent]替换成[msgtype的值]
*/
private Object msgContent;
public At getAt() {
return at;
}
public void setAt(At at) {
this.at = at;
}
public String getMsgtype() {
return msgtype;
}
public Object getMsgContent() {
return msgContent;
}
public Text text(){
msgtype="text";
Text text = new Text();
msgContent = text;
return text;
}
public Link link(){
msgtype="link";
Link link = new Link();
msgContent = link;
return link;
}
public Markdown markdown(String title){
msgtype="markdown";
Markdown markdown = new Markdown(title);
msgContent = markdown;
return markdown;
}
public FeedCard feedCard(){
msgtype="feedCard";
FeedCard feedCard = new FeedCard();
msgContent = feedCard;
return feedCard;
}
public ActionCard actionCard(String title){
msgtype="actionCard";
ActionCard actionCard = new ActionCard(title);
msgContent = actionCard;
return actionCard;
}
public String toJsonStr(){
String jsonStr = JSONUtil.toJsonStr(this);
jsonStr = jsonStr.replace("msgContent", msgtype);
// JSONObject jsonObject = JSONObject.parseObject(jsonStr);
// jonObject.put(msgtype,content);
return jsonStr;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy