|
@@ -17,6 +17,10 @@ import lombok.Builder;
|
|
|
|
|
|
/**
|
|
|
* 使用RestTemplate调用能力商店钉钉消息推送服务API接口
|
|
|
+ *
|
|
|
+ * 此接口实际调用webhook接口的机器人实现
|
|
|
+ *
|
|
|
+ * markdown方式使用<font color='red'>内容</font>方式修改字体颜色,在pc端钉钉可生效,在安卓端钉钉上不生效。
|
|
|
*/
|
|
|
@Builder
|
|
|
public class PushMessageUtil {
|
|
@@ -32,8 +36,10 @@ public class PushMessageUtil {
|
|
|
private String moduleId;
|
|
|
// 业务编码
|
|
|
private String busiCode;
|
|
|
- // 钉钉群机器人accessToken
|
|
|
+ // 钉钉群机器人accessToken,通过添加webhook的机器人可以查询到,也可使用已添加的机器人
|
|
|
private String accessToken;
|
|
|
+ // 钉钉机器人前缀
|
|
|
+ private String prefix;
|
|
|
private RestTemplate restTemplate;
|
|
|
@Builder.Default
|
|
|
private DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
|
|
@@ -81,6 +87,7 @@ public class PushMessageUtil {
|
|
|
map.put("DATA", data);
|
|
|
Map<String, Object> text = new HashMap<>();
|
|
|
data.put("TEXT", text);
|
|
|
+ messge = messge.startsWith(prefix) ? messge : prefix + messge;
|
|
|
text.put("CONTENT", messge);
|
|
|
if (atList != null) {
|
|
|
data.put("AT_LIST", atList);
|
|
@@ -146,7 +153,8 @@ public class PushMessageUtil {
|
|
|
map.put("DATA", data);
|
|
|
Map<String, Object> markdown = new HashMap<>();
|
|
|
data.put("MARK_DOWN", markdown);
|
|
|
- title = title == null || "".equals(title) ? "markdown消息" : title;
|
|
|
+ title = title == null || "".equals(title) ? prefix : title;
|
|
|
+ title = title.startsWith(prefix) ? title : prefix + title;
|
|
|
markdown.put("TITLE", title);
|
|
|
markdown.put("TEXT", messge);
|
|
|
if (atList != null) {
|