From 4736f383ce392451bf7e7f24d5114f8952502e74 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 20 Mar 2020 15:02:53 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=BE=AE=E4=BF=A1=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E5=B9=B3=E5=8F=B0=E6=9C=8D=E5=8A=A1=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 -- .../vertical/config/RedisProperties.java | 124 ++++++++++++++++++ .../open/controller/WxOpenApiController.java | 2 + .../controller/WxOpenNotifyController.java | 16 ++- 4 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/rymcu/vertical/config/RedisProperties.java diff --git a/pom.xml b/pom.xml index 6f5f2f0..bd2ce30 100644 --- a/pom.xml +++ b/pom.xml @@ -175,16 +175,6 @@ jodd-http 5.0.13 - - com.github.binarywang - weixin-java-mp - 3.7.0 - - - com.github.binarywang - weixin-java-miniapp - 3.7.0 - com.github.binarywang weixin-java-open diff --git a/src/main/java/com/rymcu/vertical/config/RedisProperties.java b/src/main/java/com/rymcu/vertical/config/RedisProperties.java new file mode 100644 index 0000000..02ae5d2 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/config/RedisProperties.java @@ -0,0 +1,124 @@ +package com.rymcu.vertical.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import redis.clients.jedis.JedisPoolConfig; +import redis.clients.jedis.Protocol; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocketFactory; + +/** + * @author 007 + */ +@ConfigurationProperties(prefix = "spring.redis") +public class RedisProperties extends JedisPoolConfig { + private String host = Protocol.DEFAULT_HOST; + private int port = Protocol.DEFAULT_PORT; + private String password; + private int database = 1; + private int connectionTimeout = Protocol.DEFAULT_TIMEOUT; + private int soTimeout = Protocol.DEFAULT_TIMEOUT; + private String clientName; + private boolean ssl; + private SSLSocketFactory sslSocketFactory; + private SSLParameters sslParameters; + private HostnameVerifier hostnameVerifier; + + public boolean isSsl() { + return ssl; + } + + public void setSsl(boolean ssl) { + this.ssl = ssl; + } + + public SSLSocketFactory getSslSocketFactory() { + return sslSocketFactory; + } + + public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { + this.sslSocketFactory = sslSocketFactory; + } + + public SSLParameters getSslParameters() { + return sslParameters; + } + + public void setSslParameters(SSLParameters sslParameters) { + this.sslParameters = sslParameters; + } + + public HostnameVerifier getHostnameVerifier() { + return hostnameVerifier; + } + + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + this.hostnameVerifier = hostnameVerifier; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + if (host == null || "".equals(host)) { + host = Protocol.DEFAULT_HOST; + } + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + if ("".equals(password)) { + password = null; + } + this.password = password; + } + + public int getDatabase() { + return database; + } + + public void setDatabase(int database) { + this.database = database; + } + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + if ("".equals(clientName)) { + clientName = null; + } + this.clientName = clientName; + } + + public int getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public int getSoTimeout() { + return soTimeout; + } + + public void setSoTimeout(int soTimeout) { + this.soTimeout = soTimeout; + } +} diff --git a/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenApiController.java b/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenApiController.java index ed14ee3..3473a02 100644 --- a/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenApiController.java +++ b/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenApiController.java @@ -37,6 +37,8 @@ public class WxOpenApiController { @GetMapping("/goto_auth_url") public void gotoPreAuthUrl(HttpServletRequest request, HttpServletResponse response){ + System.out.println("===================================Host:"); + System.out.println(request.getHeader("host")); String host = request.getHeader("host"); String url = "http://"+host+"/vertical-console/wx/open/auth/jump"; try { diff --git a/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenNotifyController.java b/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenNotifyController.java index 1b23a91..d7b2784 100644 --- a/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenNotifyController.java +++ b/src/main/java/com/rymcu/vertical/wx/open/controller/WxOpenNotifyController.java @@ -1,6 +1,7 @@ package com.rymcu.vertical.wx.open.controller; import com.rymcu.vertical.wx.open.handler.WxOpenServiceHandler; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; @@ -22,6 +23,13 @@ public class WxOpenNotifyController { @Autowired protected WxOpenServiceHandler wxOpenService; + /**全网发布官方测试小程序 AppId*/ + private final static String testMiniProgramAppId = "wxd101a85aa106f53e"; + /**全网发布官方测试公众号 AppId*/ + private final static String testMpAppId = "wx570bc396a51b8ff8"; + private final static String TESTCOMPONENT_MSG_TYPE_TEXT = "TESTCOMPONENT_MSG_TYPE_TEXT"; + private final static String TESTCOMPONENT_MSG_TYPE_TEXT_callback = "TESTCOMPONENT_MSG_TYPE_TEXT_callback"; + @RequestMapping("/receive_ticket") public Object receiveTicket(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce, @RequestParam("signature") String signature, @@ -76,12 +84,12 @@ public class WxOpenNotifyController { wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); // 全网发布测试用例 - if (StringUtils.equalsAnyIgnoreCase(appId)) { + if (StringUtils.equalsAnyIgnoreCase(appId, testMiniProgramAppId, testMpAppId)) { try { - if (StringUtils.equals(inMessage.getMsgType(), "text")) { - if (StringUtils.equals(inMessage.getContent(), "TESTCOMPONENT_MSG_TYPE_TEXT")) { + if (StringUtils.equals(inMessage.getMsgType(), WxConsts.XmlMsgType.TEXT)) { + if (StringUtils.equals(inMessage.getContent(), TESTCOMPONENT_MSG_TYPE_TEXT)) { out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml( - WxMpXmlOutMessage.TEXT().content("TESTCOMPONENT_MSG_TYPE_TEXT_callback") + WxMpXmlOutMessage.TEXT().content(TESTCOMPONENT_MSG_TYPE_TEXT_callback) .fromUser(inMessage.getToUser()) .toUser(inMessage.getFromUser()) .build(),