封装一个方法用于调用,方法是post,header必须填写
public String sendWechat(OaWeChat oc) {
String url = "################";
// OaWeChat oc=new OaWeChat();
// oc.setContent("测试");
// 测试的时候设置
List<String> list = new ArrayList<>();
list.add("180905006");
oc.setUserIds(list);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-type", "application/json; charset=utf-8");
HttpEntity<OaWeChat> entity = new HttpEntity<>(oc, headers);
String reqStr = JSON.toJSONString(oc);
LOGGER.info("发送微信提醒=" + reqStr);
String result = restTemplate.postForObject(url, entity, String.class);
LOGGER.info(result);
if (result != null && "1".equals(result)) {
LOGGER.info("发送成功", "msg=" + JSON.toJSONString(oc));
} else {
LOGGER.error("发送失败", "msg=" + JSON.toJSONString(oc));
}
return result;
}