Commit b9114eb7 by fudahua

会员标签同步-告警

parent 8589e46e
...@@ -4,15 +4,25 @@ package com.gic.haoban.manage.api.enums; ...@@ -4,15 +4,25 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2021/8/2. * Created by hua on 2021/8/2.
*/ */
public enum AlertTypeEnum { public enum AlertTypeEnum {
QYWX_TAG_SYNC(1, "企微标签同步"), QYWX_TAG_SYNC(1, "企微标签同步", null),
QUNFA_MESSAGE(2, "企微群发"), QUNFA_MESSAGE(2, "企微群发", null),
FRIEND_ADD(3, "企微好友添加"),; FRIEND_ADD(3, "企微好友添加", null),;
private Integer type; private Integer type;
private String name; private String name;
private String dingUrl;
AlertTypeEnum(Integer type, String name) { AlertTypeEnum(Integer type, String name, String dingUrl) {
this.type = type; this.type = type;
this.name = name; this.name = name;
this.dingUrl = dingUrl;
}
public String getDingUrl() {
return dingUrl;
}
public void setDingUrl(String dingUrl) {
this.dingUrl = dingUrl;
} }
public Integer getType() { public Integer getType() {
...@@ -30,4 +40,14 @@ public enum AlertTypeEnum { ...@@ -30,4 +40,14 @@ public enum AlertTypeEnum {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public static AlertTypeEnum getEnum(int type) {
AlertTypeEnum[] values = AlertTypeEnum.values();
for (AlertTypeEnum value : values) {
if (value.getType() == type) {
return value;
}
}
return null;
}
} }
...@@ -149,13 +149,19 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic ...@@ -149,13 +149,19 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
dingMap.put("markdown", markdownMap); dingMap.put("markdown", markdownMap);
String text = ""; String text = "";
String dingUrl = ALERT_URL;
//企业微信标签同步 AlertTypeEnum anEnum = AlertTypeEnum.getEnum(messageDTO.getAlertType());
if (messageDTO.getAlertType().equals(AlertTypeEnum.QYWX_TAG_SYNC.getType())) { if (anEnum != null) {
markdownMap.put("title", AlertTypeEnum.QYWX_TAG_SYNC.getName() + "-" + messageDTO.getAlertTitle()); markdownMap.put("title", anEnum.getName() + "-" + messageDTO.getAlertTitle());
text += "标题:" + AlertTypeEnum.QYWX_TAG_SYNC.getName() + "-" + messageDTO.getAlertTitle() + "\n\r"; text += "标题:" + anEnum.getName() + "-" + messageDTO.getAlertTitle() + "\n\r";
if (anEnum.getDingUrl() != null) {
dingUrl = anEnum.getDingUrl();
} }
} else {
markdownMap.put("title", messageDTO.getAlertTitle());
text += "标题:" + messageDTO.getAlertTitle() + "\n\r";
}
//企业信息 //企业信息
if (StringUtils.isNotBlank(messageDTO.getWxEnterpriseId())) { if (StringUtils.isNotBlank(messageDTO.getWxEnterpriseId())) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(messageDTO.getWxEnterpriseId()); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(messageDTO.getWxEnterpriseId());
...@@ -180,7 +186,7 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic ...@@ -180,7 +186,7 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
text += "链路:[" + messageDTO.getTraceId() + "](" + traceUrl + ")"; text += "链路:[" + messageDTO.getTraceId() + "](" + traceUrl + ")";
} }
markdownMap.put("text", text); markdownMap.put("text", text);
String post = HttpUtil.post(ALERT_URL, JSONObject.toJSONString(dingMap)); String post = HttpUtil.post(dingUrl, JSONObject.toJSONString(dingMap));
logger.info("alert:{}", post); logger.info("alert:{}", post);
} }
......
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