Commit 9bf0ed11 authored by liuyang's avatar liuyang

测试回复消息

parent c05885bf
...@@ -34,10 +34,22 @@ public class MsgHandler extends AbstractHandler { ...@@ -34,10 +34,22 @@ public class MsgHandler extends AbstractHandler {
//TODO 可以选择将消息保存到本地 //TODO 可以选择将消息保存到本地
} }
String nickName = getNickNameByOpenId(wxMessage.getFromUser(),weixinService);
try {
return new TextBuilder().build("您好,"+nickName+",欢迎关注本公众号。", wxMessage, weixinService); try {
String nickName = getNickNameByOpenId(wxMessage.getFromUser(),weixinService);
String content = "您咨询的问题是:";
if (wxMessage.getMsgType().equals("text")){
content += wxMessage.getContent();
}else if (wxMessage.getMsgType().equals("voice")){
content += wxMessage.getRecognition();
}else if (wxMessage.getMsgType().equals("image")
|| wxMessage.getMsgType().equals("video")
|| wxMessage.getMsgType().equals("shortvideo")
|| wxMessage.getMsgType().equals("location")
|| wxMessage.getMsgType().equals("link")){
content = "对不起,暂不支持该类消息";
}
return new TextBuilder().build("您好,"+nickName+","+content, wxMessage, weixinService);
} catch (Exception e) { } catch (Exception e) {
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(e.getMessage()) WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(e.getMessage())
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
......
server: server:
port: 8080 port: 80
spring: spring:
...@@ -14,4 +14,11 @@ spring: ...@@ -14,4 +14,11 @@ spring:
log: log:
path: ../data/logs path: ../data/logs
wx:
mp:
configs:
- appid: wxea78b5b73ce4e861
secret: a7fcec7f9291e631de9d7547b43d2934
token: jingxiang
aesKey:
templateId: h7BghfwRb7P-2FeR8qbeS5c2EGQqA6fXO_I9FpwFGi8
server:
port: 80
spring:
datasource:
druid:
url: jdbc:mysql://localhost:3306/framework?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
username: root
password: 123456
# redis:
# host: localhost
log:
path: ../data/logs
wx:
mp:
configs:
- appid: wxe97fd2b45e0951b3
secret: b0b25c67b35f05c949fa04ef9cd07c48
token: jingxiang
aesKey:
templateId: h7BghfwRb7P-2FeR8qbeS5c2EGQqA6fXO_I9FpwFGi8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment