|
|
@ -37,6 +37,10 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map.Entry; |
|
|
|
import java.util.Map.Entry; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
import lombok.Builder; |
|
|
|
|
|
|
|
import lombok.Data; |
|
|
|
|
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
@ -83,25 +87,24 @@ public final class FeiShuSender { |
|
|
|
alertResult.setSuccess(false); |
|
|
|
alertResult.setSuccess(false); |
|
|
|
|
|
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(result)) { |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(result)) { |
|
|
|
alertResult.setMessage("send fei shu msg error"); |
|
|
|
alertResult.setMessage("send feishu msg error: feishu server resp is blank."); |
|
|
|
log.info("send fei shu msg error,fei shu server resp is null"); |
|
|
|
log.info("send feishu msg error: feishu server resp is blank."); |
|
|
|
return alertResult; |
|
|
|
return alertResult; |
|
|
|
} |
|
|
|
} |
|
|
|
FeiShuSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, FeiShuSendMsgResponse.class); |
|
|
|
FeiShuSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, FeiShuSendMsgResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
if (null == sendMsgResponse) { |
|
|
|
if (null == sendMsgResponse) { |
|
|
|
alertResult.setMessage("send fei shu msg fail"); |
|
|
|
alertResult.setMessage("send feishu msg error: feishu server resp parse error is null."); |
|
|
|
log.info("send fei shu msg error,resp error"); |
|
|
|
log.info("send feishu msg error: feishu server resp parse error is null."); |
|
|
|
return alertResult; |
|
|
|
return alertResult; |
|
|
|
} |
|
|
|
} |
|
|
|
if (sendMsgResponse.statusCode == 0) { |
|
|
|
if (sendMsgResponse.code == 0) { |
|
|
|
alertResult.setSuccess(true); |
|
|
|
alertResult.setSuccess(true); |
|
|
|
alertResult.setMessage("send fei shu msg success"); |
|
|
|
alertResult.setMessage("send feishu msg success."); |
|
|
|
return alertResult; |
|
|
|
return alertResult; |
|
|
|
} |
|
|
|
} |
|
|
|
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage())); |
|
|
|
alertResult.setMessage(String.format("alert send feishu msg error: %s", sendMsgResponse.getMsg())); |
|
|
|
log.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), |
|
|
|
log.info("alert send feishu msg error: {}", sendMsgResponse); |
|
|
|
sendMsgResponse.getExtra()); |
|
|
|
|
|
|
|
return alertResult; |
|
|
|
return alertResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -134,10 +137,10 @@ public final class FeiShuSender { |
|
|
|
String resp = sendMsg(alertData); |
|
|
|
String resp = sendMsg(alertData); |
|
|
|
return checkSendFeiShuSendMsgResult(resp); |
|
|
|
return checkSendFeiShuSendMsgResult(resp); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("send fei shu alert failed:", e); |
|
|
|
log.error("send feishu alert failed:", e); |
|
|
|
alertResult = new AlertResult(); |
|
|
|
alertResult = new AlertResult(); |
|
|
|
alertResult.setSuccess(false); |
|
|
|
alertResult.setSuccess(false); |
|
|
|
alertResult.setMessage("send fei shu alert fail."); |
|
|
|
alertResult.setMessage("send feishu alert fail."); |
|
|
|
} |
|
|
|
} |
|
|
|
return alertResult; |
|
|
|
return alertResult; |
|
|
|
} |
|
|
|
} |
|
|
@ -167,95 +170,25 @@ public final class FeiShuSender { |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
response.close(); |
|
|
|
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); |
|
|
|
resp); |
|
|
|
return resp; |
|
|
|
return resp; |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
httpClient.close(); |
|
|
|
httpClient.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@AllArgsConstructor |
|
|
|
|
|
|
|
@Builder |
|
|
|
|
|
|
|
@Data |
|
|
|
|
|
|
|
@NoArgsConstructor |
|
|
|
static final class FeiShuSendMsgResponse { |
|
|
|
static final class FeiShuSendMsgResponse { |
|
|
|
|
|
|
|
|
|
|
|
@JsonProperty("Extra") |
|
|
|
@JsonProperty("data") |
|
|
|
private String extra; |
|
|
|
private Object data; |
|
|
|
@JsonProperty("StatusCode") |
|
|
|
@JsonProperty("code") |
|
|
|
private Integer statusCode; |
|
|
|
private Integer code; |
|
|
|
@JsonProperty("StatusMessage") |
|
|
|
@JsonProperty("msg") |
|
|
|
private String statusMessage; |
|
|
|
private String msg; |
|
|
|
|
|
|
|
|
|
|
|
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("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() + ")"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|