Skip to content

Commit 0285cbb

Browse files
committed
⬆️ 升级sdk版本为3.5.0
1 parent cf1e4e6 commit 0285cbb

File tree

11 files changed

+298
-361
lines changed

11 files changed

+298
-361
lines changed

pom.xml

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<plugin.maven-compiler>3.1</plugin.maven-compiler>
1919

2020
<!-- lib versions -->
21-
<WxJava.version>3.4.0</WxJava.version>
21+
<WxJava.version>3.5.0</WxJava.version>
2222
<junit.version>4.12</junit.version>
2323
<slf4j.version>1.7.21</slf4j.version>
2424
<spring.version>4.3.18.RELEASE</spring.version>
@@ -52,66 +52,6 @@
5252
<encoding>${project.build.sourceEncoding}</encoding>
5353
</configuration>
5454
</plugin>
55-
<!--
56-
<plugin>
57-
<groupId>org.apache.maven.plugins</groupId>
58-
<artifactId>maven-checkstyle-plugin</artifactId>
59-
<version>${plugin.checkstyle.version}</version>
60-
<configuration>
61-
<configLocation>${project.basedir}/build/check-style.xml</configLocation>
62-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
63-
<suppressionsLocation>${project.basedir}/build/check-style-suppression.xml</suppressionsLocation>
64-
<consoleOutput>true</consoleOutput>
65-
<failsOnError>true</failsOnError>
66-
</configuration>
67-
<executions>
68-
<execution>
69-
<phase>verify</phase>
70-
<goals>
71-
<goal>check</goal>
72-
</goals>
73-
</execution>
74-
</executions>
75-
</plugin>
76-
<plugin>
77-
<groupId>org.apache.maven.plugins</groupId>
78-
<artifactId>maven-pmd-plugin</artifactId>
79-
<version>${plugin.pmd.version}</version>
80-
<configuration>
81-
<rulesets>
82-
<ruleset>build/pmd.xml</ruleset>
83-
</rulesets>
84-
<targetJdk>${project.build.jdk}</targetJdk>
85-
<verbose>true</verbose>
86-
</configuration>
87-
<executions>
88-
<execution>
89-
<phase>verify</phase>
90-
<goals>
91-
<goal>check</goal>
92-
<goal>cpd-check</goal>
93-
</goals>
94-
</execution>
95-
</executions>
96-
</plugin>
97-
98-
<plugin>
99-
<groupId>org.codehaus.mojo</groupId>
100-
<artifactId>findbugs-maven-plugin</artifactId>
101-
<version>${plugin.findbugs.version}</version>
102-
<configuration>
103-
<excludeFilterFile>build/find-bugs-exclude-filter.xml</excludeFilterFile>
104-
</configuration>
105-
<executions>
106-
<execution>
107-
<phase>verify</phase>
108-
<goals>
109-
<goal>check</goal>
110-
</goals>
111-
</execution>
112-
</executions>
113-
</plugin>
114-
-->
11555
</plugins>
11656
</build>
11757

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.github.weixin.demo.config;
22

3-
import com.github.binarywang.wxpay.config.WxPayConfig;
4-
import com.github.binarywang.wxpay.service.WxPayService;
5-
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
6-
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
7-
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
83
import me.chanjar.weixin.mp.api.WxMpService;
94
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
5+
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
6+
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
107
import org.springframework.beans.factory.annotation.Value;
118
import org.springframework.context.annotation.Bean;
129
import org.springframework.context.annotation.Configuration;
@@ -21,32 +18,32 @@
2118
*/
2219
@Configuration
2320
public class MainConfiguration {
24-
@Value("#{wxProperties.appId}")
25-
private String appId;
21+
@Value("#{wxProperties.appId}")
22+
private String appId;
2623

27-
@Value("#{wxProperties.appSecret}")
28-
private String appSecret;
24+
@Value("#{wxProperties.appSecret}")
25+
private String appSecret;
2926

30-
@Value("#{wxProperties.token}")
31-
private String token;
27+
@Value("#{wxProperties.token}")
28+
private String token;
3229

33-
@Value("#{wxProperties.aesKey}")
34-
private String aesKey;
30+
@Value("#{wxProperties.aesKey}")
31+
private String aesKey;
3532

36-
@Bean
37-
public WxMpConfigStorage wxMpConfigStorage() {
38-
WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage();
39-
configStorage.setAppId(this.appId);
40-
configStorage.setSecret(this.appSecret);
41-
configStorage.setToken(this.token);
42-
configStorage.setAesKey(this.aesKey);
43-
return configStorage;
44-
}
33+
@Bean
34+
public WxMpConfigStorage wxMpConfigStorage() {
35+
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
36+
configStorage.setAppId(this.appId);
37+
configStorage.setSecret(this.appSecret);
38+
configStorage.setToken(this.token);
39+
configStorage.setAesKey(this.aesKey);
40+
return configStorage;
41+
}
4542

46-
@Bean
47-
public WxMpService wxMpService() {
48-
WxMpService wxMpService = new WxMpServiceImpl();
49-
wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
50-
return wxMpService;
51-
}
43+
@Bean
44+
public WxMpService wxMpService() {
45+
WxMpService wxMpService = new WxMpServiceImpl();
46+
wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
47+
return wxMpService;
48+
}
5249
}

src/main/java/com/github/weixin/demo/config/MenuConfig.java

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import me.chanjar.weixin.common.bean.menu.WxMenu;
44
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
55
import me.chanjar.weixin.common.error.WxErrorException;
6-
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
7-
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
86
import me.chanjar.weixin.mp.api.WxMpService;
97
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
8+
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
9+
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
1010

1111
import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType;
1212

@@ -16,115 +16,115 @@
1616
*/
1717
public class MenuConfig {
1818

19-
/**
20-
* 定义菜单结构
21-
*
22-
* @return
23-
*/
24-
protected static WxMenu getMenu() {
25-
26-
MainConfig mainConfig = new MainConfig("appid", "appsecret", "token", "aesKey");
27-
WxMpService wxMpService = mainConfig.wxMpService();
28-
29-
WxMenu menu = new WxMenu();
30-
WxMenuButton button1 = new WxMenuButton();
31-
button1.setType(MenuButtonType.VIEW);
32-
button1.setName("买家订单");
33-
button1.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
34-
35-
WxMenuButton button2 = new WxMenuButton();
36-
button2.setName("我是卖家");
37-
38-
WxMenuButton button21 = new WxMenuButton();
39-
button21.setType(MenuButtonType.VIEW);
40-
button21.setName("我的订单");
41-
button21.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
42-
43-
WxMenuButton button22 = new WxMenuButton();
44-
button22.setType(MenuButtonType.VIEW);
45-
button22.setName("收入统计");
46-
button22.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
47-
48-
WxMenuButton button23 = new WxMenuButton();
49-
button23.setType(MenuButtonType.VIEW);
50-
button23.setName("发布商品");
51-
button23.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
52-
53-
WxMenuButton button24 = new WxMenuButton();
54-
button24.setType(MenuButtonType.VIEW);
55-
button24.setName("商品管理");
56-
button24.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
57-
58-
button2.getSubButtons().add(button21);
59-
button2.getSubButtons().add(button22);
60-
button2.getSubButtons().add(button23);
61-
button2.getSubButtons().add(button24);
62-
63-
WxMenuButton button3 = new WxMenuButton();
64-
button3.setType(MenuButtonType.CLICK);
65-
button3.setName("使用帮助");
66-
button3.setKey("help");
67-
68-
menu.getButtons().add(button1);
69-
menu.getButtons().add(button2);
70-
menu.getButtons().add(button3);
71-
72-
return menu;
73-
}
74-
75-
76-
public static class MainConfig {
77-
78-
private String appId;
79-
private String appSecret;
80-
private String token;
81-
private String aesKey;
82-
83-
/**
84-
* 为了生成自定义菜单使用的构造函数
85-
*
86-
* @param appId
87-
* @param appSecret
88-
* @param token
89-
* @param aesKey
90-
*/
91-
protected MainConfig(String appId, String appSecret, String token, String aesKey) {
92-
this.appId = appId;
93-
this.appSecret = appSecret;
94-
this.token = token;
95-
this.aesKey = aesKey;
96-
}
97-
98-
public WxMpConfigStorage wxMpConfigStorage() {
99-
WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage();
100-
configStorage.setAppId(this.appId);
101-
configStorage.setSecret(this.appSecret);
102-
configStorage.setToken(this.token);
103-
configStorage.setAesKey(this.aesKey);
104-
return configStorage;
105-
}
106-
107-
public WxMpService wxMpService() {
108-
WxMpService wxMpService = new WxMpServiceImpl();
109-
wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
110-
return wxMpService;
111-
}
112-
113-
}
114-
115-
/**
116-
* 运行此main函数即可生成公众号自定义菜单,注意要修改MainConfig构造方法行代码的对应四个参数为实际值
117-
*
118-
* @param args
119-
*/
120-
public static void main(String[] args) {
121-
MainConfig mainConfig = new MainConfig("appid", "appsecret", "token", "aesKey");
122-
WxMpService wxMpService = mainConfig.wxMpService();
123-
try {
124-
wxMpService.getMenuService().menuCreate(getMenu());
125-
} catch (WxErrorException e) {
126-
e.printStackTrace();
127-
}
128-
}
19+
/**
20+
* 定义菜单结构
21+
*
22+
* @return
23+
*/
24+
protected static WxMenu getMenu() {
25+
26+
MainConfig mainConfig = new MainConfig("appid", "appsecret", "token", "aesKey");
27+
WxMpService wxMpService = mainConfig.wxMpService();
28+
29+
WxMenu menu = new WxMenu();
30+
WxMenuButton button1 = new WxMenuButton();
31+
button1.setType(MenuButtonType.VIEW);
32+
button1.setName("买家订单");
33+
button1.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
34+
35+
WxMenuButton button2 = new WxMenuButton();
36+
button2.setName("我是卖家");
37+
38+
WxMenuButton button21 = new WxMenuButton();
39+
button21.setType(MenuButtonType.VIEW);
40+
button21.setName("我的订单");
41+
button21.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
42+
43+
WxMenuButton button22 = new WxMenuButton();
44+
button22.setType(MenuButtonType.VIEW);
45+
button22.setName("收入统计");
46+
button22.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
47+
48+
WxMenuButton button23 = new WxMenuButton();
49+
button23.setType(MenuButtonType.VIEW);
50+
button23.setName("发布商品");
51+
button23.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
52+
53+
WxMenuButton button24 = new WxMenuButton();
54+
button24.setType(MenuButtonType.VIEW);
55+
button24.setName("商品管理");
56+
button24.setUrl(wxMpService.oauth2buildAuthorizationUrl("", "snsapi_base", ""));
57+
58+
button2.getSubButtons().add(button21);
59+
button2.getSubButtons().add(button22);
60+
button2.getSubButtons().add(button23);
61+
button2.getSubButtons().add(button24);
62+
63+
WxMenuButton button3 = new WxMenuButton();
64+
button3.setType(MenuButtonType.CLICK);
65+
button3.setName("使用帮助");
66+
button3.setKey("help");
67+
68+
menu.getButtons().add(button1);
69+
menu.getButtons().add(button2);
70+
menu.getButtons().add(button3);
71+
72+
return menu;
73+
}
74+
75+
76+
public static class MainConfig {
77+
78+
private String appId;
79+
private String appSecret;
80+
private String token;
81+
private String aesKey;
82+
83+
/**
84+
* 为了生成自定义菜单使用的构造函数
85+
*
86+
* @param appId
87+
* @param appSecret
88+
* @param token
89+
* @param aesKey
90+
*/
91+
protected MainConfig(String appId, String appSecret, String token, String aesKey) {
92+
this.appId = appId;
93+
this.appSecret = appSecret;
94+
this.token = token;
95+
this.aesKey = aesKey;
96+
}
97+
98+
public WxMpConfigStorage wxMpConfigStorage() {
99+
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
100+
configStorage.setAppId(this.appId);
101+
configStorage.setSecret(this.appSecret);
102+
configStorage.setToken(this.token);
103+
configStorage.setAesKey(this.aesKey);
104+
return configStorage;
105+
}
106+
107+
public WxMpService wxMpService() {
108+
WxMpService wxMpService = new WxMpServiceImpl();
109+
wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
110+
return wxMpService;
111+
}
112+
113+
}
114+
115+
/**
116+
* 运行此main函数即可生成公众号自定义菜单,注意要修改MainConfig构造方法行代码的对应四个参数为实际值
117+
*
118+
* @param args
119+
*/
120+
public static void main(String[] args) {
121+
MainConfig mainConfig = new MainConfig("appid", "appsecret", "token", "aesKey");
122+
WxMpService wxMpService = mainConfig.wxMpService();
123+
try {
124+
wxMpService.getMenuService().menuCreate(getMenu());
125+
} catch (WxErrorException e) {
126+
e.printStackTrace();
127+
}
128+
}
129129

130130
}

0 commit comments

Comments
 (0)