From f67d70fcb6f2f60dc0ac1228908603f2b95d8917 Mon Sep 17 00:00:00 2001 From: xueye Date: Sat, 3 Jul 2021 01:50:40 +0800 Subject: [PATCH] =?UTF-8?q?deps:=20=E7=A7=BB=E9=99=A4Spring=E5=8F=8D?= =?UTF-8?q?=E5=BA=94=E5=BC=8F=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notify-wechat/pom.xml | 12 ++--- .../notify/wechat/WechatMessageTemplate.java | 46 ++++--------------- .../com/cicdi/notify/wechat/WechatTest.java | 1 - 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/notify-wechat/pom.xml b/notify-wechat/pom.xml index 0b52f15..98311d4 100644 --- a/notify-wechat/pom.xml +++ b/notify-wechat/pom.xml @@ -25,12 +25,6 @@ compile - - org.springframework.boot - spring-boot-starter-webflux - 2.3.11.RELEASE - - com.alibaba fastjson @@ -50,6 +44,12 @@ httpclient 4.5.13 + + + commons-lang + commons-lang + 2.6 + \ No newline at end of file diff --git a/notify-wechat/src/main/java/com/cicdi/notify/wechat/WechatMessageTemplate.java b/notify-wechat/src/main/java/com/cicdi/notify/wechat/WechatMessageTemplate.java index f4f278a..daef2f9 100644 --- a/notify-wechat/src/main/java/com/cicdi/notify/wechat/WechatMessageTemplate.java +++ b/notify-wechat/src/main/java/com/cicdi/notify/wechat/WechatMessageTemplate.java @@ -3,9 +3,7 @@ package com.cicdi.notify.wechat; import com.alibaba.fastjson.JSONObject; import com.cicdi.notify.template.Template; -import org.springframework.util.StringUtils; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.util.UriComponentsBuilder; +import org.apache.commons.lang.StringUtils; import java.util.Collections; import java.util.Map; @@ -65,52 +63,24 @@ public class WechatMessageTemplate implements Template { this.message = message; } - public BodyInserters.FormInserter createFormInserter(BodyInserters.FormInserter inserter, Map context) { - inserter.with("agentid", this.getAgentId()) - .with("msgtype","text") - .with("text",this.createMessage(context)); - if (StringUtils.hasText(toUser)) { - inserter.with("touser", this.createUserIdList(context)); - } - if (StringUtils.hasText(toParty)) { - inserter.with("toparty", this.createDepartmentIdList(context)); - } - return inserter; - - } - - public String createJsonRequest(Map context){ - JSONObject json=new JSONObject(); - json.put("agentid",getAgentId()); - json.put("msgtype","text"); + public String createJsonRequest(Map context) { + JSONObject json = new JSONObject(); + json.put("agentid", getAgentId()); + json.put("msgtype", "text"); // TODO // json.put("text",Collections.singletonMap("content",ExpressionUtils.analytical(message, context.getAllValues(), "spel"))); - json.put("text",Collections.singletonMap("content", message)); + json.put("text", Collections.singletonMap("content", message)); - if (StringUtils.hasText(toUser)) { + if (StringUtils.isNotBlank(toUser)) { json.put("touser", this.createUserIdList(context)); } - if (StringUtils.hasText(toParty)) { + if (StringUtils.isNotBlank(toParty)) { json.put("toparty", this.createDepartmentIdList(context)); } return json.toJSONString(); } - - public UriComponentsBuilder createUriParameter(UriComponentsBuilder builder, Map context){ - builder.queryParam("agentid", this.getAgentId()) - .queryParam("msgtype","text") - .queryParam("text",this.createMessage(context)); - if (StringUtils.hasText(toUser)) { - builder.queryParam("touser", this.createUserIdList(context)); - } - if (StringUtils.hasText(toParty)) { - builder.queryParam("toparty", this.createDepartmentIdList(context)); - } - return builder; - } - public String createUserIdList(Map context) { if (StringUtils.isEmpty(toUser)) { return toUser; diff --git a/notify-wechat/src/test/java/com/cicdi/notify/wechat/WechatTest.java b/notify-wechat/src/test/java/com/cicdi/notify/wechat/WechatTest.java index b3d8bf8..0b63ee6 100644 --- a/notify-wechat/src/test/java/com/cicdi/notify/wechat/WechatTest.java +++ b/notify-wechat/src/test/java/com/cicdi/notify/wechat/WechatTest.java @@ -7,7 +7,6 @@ import com.cicdi.notify.template.Template; import com.cicdi.notify.template.TemplateManager; import com.cicdi.notify.template.TemplateProperties; import org.junit.Test; -import reactor.core.publisher.Hooks; import java.util.HashMap; import java.util.Map;