From ebf30b7902bfe601acfadaa07cf6d0f59fc407ae Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 19 May 2019 00:47:02 +0800 Subject: [PATCH] Update sdk to 3.4.0 --- pom.xml | 2 +- .../demo/wx/mp/config/WxMpConfiguration.java | 46 ++++++------------- .../wx/mp/controller/WxMenuController.java | 16 +++---- 3 files changed, 22 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index e12d37e..c02d7cc 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 基于 WxJava 和 Spring Boot 实现的微信公众号后端开发演示项目 - 3.3.8.B + 3.4.0 1.8 1.8 diff --git a/src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java b/src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java index ae56d72..c356395 100644 --- a/src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java +++ b/src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java @@ -2,6 +2,7 @@ import com.github.binarywang.demo.wx.mp.handler.*; import com.google.common.collect.Maps; +import lombok.AllArgsConstructor; import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; import me.chanjar.weixin.mp.api.WxMpMessageRouter; import me.chanjar.weixin.mp.api.WxMpService; @@ -23,42 +24,21 @@ * * @author Binary Wang(https://github.com/binarywang) */ +@AllArgsConstructor @Configuration @EnableConfigurationProperties(WxMpProperties.class) public class WxMpConfiguration { - private LogHandler logHandler; - private NullHandler nullHandler; - private KfSessionHandler kfSessionHandler; - private StoreCheckNotifyHandler storeCheckNotifyHandler; - private LocationHandler locationHandler; - private MenuHandler menuHandler; - private MsgHandler msgHandler; - private UnsubscribeHandler unsubscribeHandler; - private SubscribeHandler subscribeHandler; - private ScanHandler scanHandler; - - private WxMpProperties properties; - - private static Map routers = Maps.newHashMap(); - private static Map mpServices = Maps.newHashMap(); - - @Autowired - public WxMpConfiguration(LogHandler logHandler, NullHandler nullHandler, KfSessionHandler kfSessionHandler, - StoreCheckNotifyHandler storeCheckNotifyHandler, LocationHandler locationHandler, - MenuHandler menuHandler, MsgHandler msgHandler, UnsubscribeHandler unsubscribeHandler, - SubscribeHandler subscribeHandler, ScanHandler scanHandler, WxMpProperties properties) { - this.logHandler = logHandler; - this.nullHandler = nullHandler; - this.kfSessionHandler = kfSessionHandler; - this.storeCheckNotifyHandler = storeCheckNotifyHandler; - this.locationHandler = locationHandler; - this.menuHandler = menuHandler; - this.msgHandler = msgHandler; - this.unsubscribeHandler = unsubscribeHandler; - this.subscribeHandler = subscribeHandler; - this.scanHandler = scanHandler; - this.properties = properties; - } + private final LogHandler logHandler; + private final NullHandler nullHandler; + private final KfSessionHandler kfSessionHandler; + private final StoreCheckNotifyHandler storeCheckNotifyHandler; + private final LocationHandler locationHandler; + private final MenuHandler menuHandler; + private final MsgHandler msgHandler; + private final UnsubscribeHandler unsubscribeHandler; + private final SubscribeHandler subscribeHandler; + private final ScanHandler scanHandler; + private final WxMpProperties properties; @Bean public WxMpService wxMpService() { diff --git a/src/main/java/com/github/binarywang/demo/wx/mp/controller/WxMenuController.java b/src/main/java/com/github/binarywang/demo/wx/mp/controller/WxMenuController.java index ef5677c..516b2cc 100644 --- a/src/main/java/com/github/binarywang/demo/wx/mp/controller/WxMenuController.java +++ b/src/main/java/com/github/binarywang/demo/wx/mp/controller/WxMenuController.java @@ -43,7 +43,7 @@ public WxMenuController(WxMpService wxService) { */ @PostMapping("/create") public String menuCreate(@PathVariable String appid, @RequestBody WxMenu menu) throws WxErrorException { - return this.wxService.switchover1(appid).getMenuService().menuCreate(menu); + return this.wxService.switchoverTo(appid).getMenuService().menuCreate(menu); } @GetMapping("/create") @@ -92,7 +92,7 @@ public String menuCreateSample(@PathVariable String appid) throws WxErrorExcepti if (servletRequestAttributes != null) { HttpServletRequest request = servletRequestAttributes.getRequest(); URL requestURL = new URL(request.getRequestURL().toString()); - String url = this.wxService.switchover1(appid).oauth2buildAuthorizationUrl( + String url = this.wxService.switchoverTo(appid).oauth2buildAuthorizationUrl( String.format("%s://%s/wx/redirect/%s/greet", requestURL.getProtocol(), requestURL.getHost(), appid), WxConsts.OAuth2Scope.SNSAPI_USERINFO, null); button34.setUrl(url); @@ -119,7 +119,7 @@ public String menuCreateSample(@PathVariable String appid) throws WxErrorExcepti */ @PostMapping("/createByJson") public String menuCreate(@PathVariable String appid, @RequestBody String json) throws WxErrorException { - return this.wxService.switchover1(appid).getMenuService().menuCreate(json); + return this.wxService.switchoverTo(appid).getMenuService().menuCreate(json); } /** @@ -130,7 +130,7 @@ public String menuCreate(@PathVariable String appid, @RequestBody String json) t */ @GetMapping("/delete") public void menuDelete(@PathVariable String appid) throws WxErrorException { - this.wxService.switchover1(appid).getMenuService().menuDelete(); + this.wxService.switchoverTo(appid).getMenuService().menuDelete(); } /** @@ -143,7 +143,7 @@ public void menuDelete(@PathVariable String appid) throws WxErrorException { */ @GetMapping("/delete/{menuId}") public void menuDelete(@PathVariable String appid, @PathVariable String menuId) throws WxErrorException { - this.wxService.switchover1(appid).getMenuService().menuDelete(menuId); + this.wxService.switchoverTo(appid).getMenuService().menuDelete(menuId); } /** @@ -154,7 +154,7 @@ public void menuDelete(@PathVariable String appid, @PathVariable String menuId) */ @GetMapping("/get") public WxMpMenu menuGet(@PathVariable String appid) throws WxErrorException { - return this.wxService.switchover1(appid).getMenuService().menuGet(); + return this.wxService.switchoverTo(appid).getMenuService().menuGet(); } /** @@ -167,7 +167,7 @@ public WxMpMenu menuGet(@PathVariable String appid) throws WxErrorException { */ @GetMapping("/menuTryMatch/{userid}") public WxMenu menuTryMatch(@PathVariable String appid, @PathVariable String userid) throws WxErrorException { - return this.wxService.switchover1(appid).getMenuService().menuTryMatch(userid); + return this.wxService.switchoverTo(appid).getMenuService().menuTryMatch(userid); } /** @@ -187,6 +187,6 @@ public WxMenu menuTryMatch(@PathVariable String appid, @PathVariable String user */ @GetMapping("/getSelfMenuInfo") public WxMpGetSelfMenuInfoResult getSelfMenuInfo(@PathVariable String appid) throws WxErrorException { - return this.wxService.switchover1(appid).getMenuService().getSelfMenuInfo(); + return this.wxService.switchoverTo(appid).getMenuService().getSelfMenuInfo(); } }