diff --git a/austin-common/src/main/java/com/java3y/austin/common/constant/OfficialAccountParamConstant.java b/austin-common/src/main/java/com/java3y/austin/common/constant/OfficialAccountParamConstant.java index c62663c..9b75998 100644 --- a/austin-common/src/main/java/com/java3y/austin/common/constant/OfficialAccountParamConstant.java +++ b/austin-common/src/main/java/com/java3y/austin/common/constant/OfficialAccountParamConstant.java @@ -37,9 +37,11 @@ public class OfficialAccountParamConstant { /** - * 关注后服务号的:文案 + * 扫码/关注后/取消关注后的服务号文案 */ public static final String SUBSCRIBE_TIPS = "关注公众号:Java3y 回复 austin 可获取项目笔记哟!"; + public static final String SCAN_TIPS = "咋又扫码啦?重新关注一波吧!"; + public static final String UNSUBSCRIBE_TIPS = "老乡别走!"; diff --git a/austin-web/src/main/java/com/java3y/austin/web/handler/ScanHandler.java b/austin-web/src/main/java/com/java3y/austin/web/handler/ScanHandler.java index 69ac2ad..fb60ea8 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/handler/ScanHandler.java +++ b/austin-web/src/main/java/com/java3y/austin/web/handler/ScanHandler.java @@ -1,8 +1,5 @@ package com.java3y.austin.web.handler; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.google.common.base.Throwables; import com.java3y.austin.common.constant.OfficialAccountParamConstant; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.session.WxSessionManager; @@ -10,8 +7,6 @@ import me.chanjar.weixin.mp.api.WxMpMessageHandler; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import java.util.Map; @@ -24,11 +19,8 @@ import java.util.Map; @Slf4j public class ScanHandler implements WxMpMessageHandler { - @Autowired - private StringRedisTemplate redisTemplate; - /** - * 扫码事件 + * 扫码事件 (暂不实现逻辑) * * @param wxMessage * @param context @@ -38,15 +30,8 @@ public class ScanHandler implements WxMpMessageHandler { */ @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) { - String content = DateUtil.now() + StrUtil.COLON + wxMessage.getFromUser() + StrUtil.COLON + OfficialAccountParamConstant.SCAN_HANDLER; - try { -// WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUser()); -// redisTemplate.opsForValue().set(wxMessage.getEventKey(), JSON.toJSONString(user), 30, TimeUnit.MINUTES); - } catch (Exception e) { - log.error("ScanHandler#handle fail:{}", Throwables.getStackTraceAsString(e)); - } return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) - .content(content).build(); + .content(OfficialAccountParamConstant.SCAN_TIPS).build(); } } diff --git a/austin-web/src/main/java/com/java3y/austin/web/handler/SubscribeHandler.java b/austin-web/src/main/java/com/java3y/austin/web/handler/SubscribeHandler.java index 7fe32c3..e9e7bdd 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/handler/SubscribeHandler.java +++ b/austin-web/src/main/java/com/java3y/austin/web/handler/SubscribeHandler.java @@ -41,7 +41,8 @@ public class SubscribeHandler implements WxMpMessageHandler { * @return */ @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) { + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService + , WxSessionManager sessionManager) { try { WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUser()); String eventKey = wxMessage.getEventKey().replaceAll(OfficialAccountParamConstant.QR_CODE_SCENE_PREFIX, CommonConstant.EMPTY_STRING); diff --git a/austin-web/src/main/java/com/java3y/austin/web/handler/UnSubscribeHandler.java b/austin-web/src/main/java/com/java3y/austin/web/handler/UnSubscribeHandler.java index e063d1f..1bc47b9 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/handler/UnSubscribeHandler.java +++ b/austin-web/src/main/java/com/java3y/austin/web/handler/UnSubscribeHandler.java @@ -1,8 +1,5 @@ package com.java3y.austin.web.handler; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.google.common.base.Throwables; import com.java3y.austin.common.constant.OfficialAccountParamConstant; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.session.WxSessionManager; @@ -10,29 +7,21 @@ import me.chanjar.weixin.mp.api.WxMpMessageHandler; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import java.util.Map; + +/** + * @author 3y + */ @Component("unSubscribeHandler") @Slf4j public class UnSubscribeHandler implements WxMpMessageHandler { - @Autowired - private StringRedisTemplate redisTemplate; @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) { - String content = DateUtil.now() + StrUtil.COLON + wxMessage.getFromUser() + StrUtil.COLON + OfficialAccountParamConstant.UNSUBSCRIBE_HANDLER; - try { -// String eventKey = wxMessage.getEventKey().replaceAll(OfficialAccountParamConstant.QR_CODE_SCENE_PREFIX, CommonConstant.EMPTY_STRING); -// String userInfo = redisTemplate.opsForValue().get(eventKey); -// redisTemplate.opsForValue().set(eventKey, JSON.toJSONString(userInfo), 30, TimeUnit.DAYS); - } catch (Exception e) { - log.error("UnSubscribeHandler#handle fail:{}", Throwables.getStackTraceAsString(e)); - } return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) - .content(content).build(); + .content(OfficialAccountParamConstant.UNSUBSCRIBE_TIPS).build(); } } diff --git a/austin-web/src/main/java/com/java3y/austin/web/utils/Convert4Amis.java b/austin-web/src/main/java/com/java3y/austin/web/utils/Convert4Amis.java index ec518d5..1f89102 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/utils/Convert4Amis.java +++ b/austin-web/src/main/java/com/java3y/austin/web/utils/Convert4Amis.java @@ -347,7 +347,8 @@ public class Convert4Amis { "return payload;"; - CommonAmisVo service = CommonAmisVo.builder().type("service").api(CommonAmisVo.ApiDTO.builder().url("${ls:backend_url}/officialAccount/check/login?sceneId=" + id) + CommonAmisVo service = CommonAmisVo.builder().type("service") + .api(CommonAmisVo.ApiDTO.builder().url("${ls:backend_url}/officialAccount/check/login?sceneId=" + id) .adaptor(adaptor).requestAdaptor(requestAdaptor).build()).interval(2000).silentPolling(true).build(); return CommonAmisVo.builder().type("form").title("登录").mode("horizontal").body(Arrays.asList(image, service)).build();