Skip to content

Commit

Permalink
Update sdk to 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed May 18, 2019
1 parent 0f2d263 commit ebf30b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<description>基于 WxJava 和 Spring Boot 实现的微信公众号后端开发演示项目</description>

<properties>
<weixin-java-mp.version>3.3.8.B</weixin-java-mp.version>
<weixin-java-mp.version>3.4.0</weixin-java-mp.version>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, WxMpMessageRouter> routers = Maps.newHashMap();
private static Map<String, WxMpService> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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();
}
}

0 comments on commit ebf30b7

Please sign in to comment.