|
|
|
@ -37,6 +37,10 @@ import java.util.List;
|
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Map.Entry; |
|
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.Builder; |
|
|
|
|
import lombok.Data; |
|
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
@ -83,25 +87,24 @@ public final class FeiShuSender {
|
|
|
|
|
alertResult.setSuccess(false); |
|
|
|
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(result)) { |
|
|
|
|
alertResult.setMessage("send fei shu msg error"); |
|
|
|
|
log.info("send fei shu msg error,fei shu server resp is null"); |
|
|
|
|
alertResult.setMessage("send feishu msg error: feishu server resp is blank."); |
|
|
|
|
log.info("send feishu msg error: feishu server resp is blank."); |
|
|
|
|
return alertResult; |
|
|
|
|
} |
|
|
|
|
FeiShuSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, FeiShuSendMsgResponse.class); |
|
|
|
|
|
|
|
|
|
if (null == sendMsgResponse) { |
|
|
|
|
alertResult.setMessage("send fei shu msg fail"); |
|
|
|
|
log.info("send fei shu msg error,resp error"); |
|
|
|
|
alertResult.setMessage("send feishu msg error: feishu server resp parse error is null."); |
|
|
|
|
log.info("send feishu msg error: feishu server resp parse error is null."); |
|
|
|
|
return alertResult; |
|
|
|
|
} |
|
|
|
|
if (sendMsgResponse.statusCode == 0) { |
|
|
|
|
if (sendMsgResponse.code == 0) { |
|
|
|
|
alertResult.setSuccess(true); |
|
|
|
|
alertResult.setMessage("send fei shu msg success"); |
|
|
|
|
alertResult.setMessage("send feishu msg success."); |
|
|
|
|
return alertResult; |
|
|
|
|
} |
|
|
|
|
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage())); |
|
|
|
|
log.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), |
|
|
|
|
sendMsgResponse.getExtra()); |
|
|
|
|
alertResult.setMessage(String.format("alert send feishu msg error: %s", sendMsgResponse.getMsg())); |
|
|
|
|
log.info("alert send feishu msg error: {}", sendMsgResponse); |
|
|
|
|
return alertResult; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -167,95 +170,25 @@ public final class FeiShuSender {
|
|
|
|
|
} finally { |
|
|
|
|
response.close(); |
|
|
|
|
} |
|
|
|
|
log.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), |
|
|
|
|
log.info("feishu send title: {}, content: {}, resp: {}", alertData.getTitle(), alertData.getContent(), |
|
|
|
|
resp); |
|
|
|
|
return resp; |
|
|
|
|
} finally { |
|
|
|
|
httpClient.close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@Builder |
|
|
|
|
@Data |
|
|
|
|
@NoArgsConstructor |
|
|
|
|
static final class FeiShuSendMsgResponse { |
|
|
|
|
|
|
|
|
|
@JsonProperty("Extra") |
|
|
|
|
private String extra; |
|
|
|
|
@JsonProperty("StatusCode") |
|
|
|
|
private Integer statusCode; |
|
|
|
|
@JsonProperty("StatusMessage") |
|
|
|
|
private String statusMessage; |
|
|
|
|
|
|
|
|
|
public FeiShuSendMsgResponse() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getExtra() { |
|
|
|
|
return this.extra; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@JsonProperty("Extra") |
|
|
|
|
public void setExtra(String extra) { |
|
|
|
|
this.extra = extra; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Integer getStatusCode() { |
|
|
|
|
return this.statusCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@JsonProperty("StatusCode") |
|
|
|
|
public void setStatusCode(Integer statusCode) { |
|
|
|
|
this.statusCode = statusCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getStatusMessage() { |
|
|
|
|
return this.statusMessage; |
|
|
|
|
} |
|
|
|
|
@JsonProperty("data") |
|
|
|
|
private Object data; |
|
|
|
|
@JsonProperty("code") |
|
|
|
|
private Integer code; |
|
|
|
|
@JsonProperty("msg") |
|
|
|
|
private String msg; |
|
|
|
|
|
|
|
|
|
@JsonProperty("StatusMessage") |
|
|
|
|
public void setStatusMessage(String statusMessage) { |
|
|
|
|
this.statusMessage = statusMessage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean equals(final Object o) { |
|
|
|
|
if (o == this) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (!(o instanceof FeiShuSendMsgResponse)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
final FeiShuSendMsgResponse other = (FeiShuSendMsgResponse) o; |
|
|
|
|
final Object this$extra = this.getExtra(); |
|
|
|
|
final Object other$extra = other.getExtra(); |
|
|
|
|
if (this$extra == null ? other$extra != null : !this$extra.equals(other$extra)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
final Object this$statusCode = this.getStatusCode(); |
|
|
|
|
final Object other$statusCode = other.getStatusCode(); |
|
|
|
|
if (this$statusCode == null ? other$statusCode != null : !this$statusCode.equals(other$statusCode)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
final Object this$statusMessage = this.getStatusMessage(); |
|
|
|
|
final Object other$statusMessage = other.getStatusMessage(); |
|
|
|
|
if (this$statusMessage == null ? other$statusMessage != null |
|
|
|
|
: !this$statusMessage.equals(other$statusMessage)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int hashCode() { |
|
|
|
|
final int PRIME = 59; |
|
|
|
|
int result = 1; |
|
|
|
|
final Object $extra = this.getExtra(); |
|
|
|
|
result = result * PRIME + ($extra == null ? 43 : $extra.hashCode()); |
|
|
|
|
final Object $statusCode = this.getStatusCode(); |
|
|
|
|
result = result * PRIME + ($statusCode == null ? 43 : $statusCode.hashCode()); |
|
|
|
|
final Object $statusMessage = this.getStatusMessage(); |
|
|
|
|
result = result * PRIME + ($statusMessage == null ? 43 : $statusMessage.hashCode()); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
return "FeiShuSender.FeiShuSendMsgResponse(extra=" + this.getExtra() + ", statusCode=" |
|
|
|
|
+ this.getStatusCode() + ", statusMessage=" + this.getStatusMessage() + ")"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|