|
|
@@ -4,6 +4,7 @@ import cn.reghao.devops.manager.notification.notifier.Notify;
|
|
|
import cn.reghao.jutil.jdk.http.WebRequest;
|
|
|
import cn.reghao.jutil.jdk.http.WebResponse;
|
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.crypto.Mac;
|
|
|
@@ -32,7 +33,14 @@ public class DingNotify implements Notify<DingMsg> {
|
|
|
public void send(String receiver, DingMsg msg) throws Exception {
|
|
|
WebResponse webResponse = webRequest.postJson(receiver, JsonConverter.objectToJson(msg));
|
|
|
if (webResponse.getStatusCode() != 200) {
|
|
|
- throw new Exception("通知发送失败, " + webResponse.getBody());
|
|
|
+ throw new Exception(webResponse.getBody());
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonObject jsonObject = JsonConverter.jsonToJsonElement(webResponse.getBody()).getAsJsonObject();
|
|
|
+ int errcode = jsonObject.get("errcode").getAsInt();
|
|
|
+ if (errcode != 0) {
|
|
|
+ String errmsg = jsonObject.get("errmsg").getAsString();
|
|
|
+ throw new Exception(errmsg);
|
|
|
}
|
|
|
}
|
|
|
|