feat(招商发送请求封装):

This commit is contained in:
fuhao 2024-08-14 15:48:06 +08:00
parent 1e68d2bfcf
commit ba39ca8472
No known key found for this signature in database
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package com.ruoyi.sensor.merchants;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.sensor.domain.WarningStatusInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
public class MerchantsHttp {
private static final Logger log = LoggerFactory.getLogger(MerchantsHttp.class);
private static final String uri = "http://localhost:8080/merchants";
public static void sendWarning(WarningStatusInfo warningStatusInfo){
String jsonString = JSON.toJSONString(warningStatusInfo);
String result = null;
Map<String, String> header = new HashMap<>();
try {
result = HttpUtils.postCall(uri, jsonString, header);
} catch (Exception e) {
log.error("send warning error", e);
return;
}
if (StringUtils.isEmpty(result)) {
log.error("send warning error");
return;
}
// 记录上报结果
log.info(result);
}
}