Skip to content

Commit 9e3f256

Browse files
authored
🆕 #2206 【开放平台】增加第三方平台启动ticket推送接口
1 parent d3730b3 commit 9e3f256

4 files changed

Lines changed: 150 additions & 114 deletions

File tree

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package me.chanjar.weixin.open.api;
22

33
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
4-
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
5-
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
6-
import me.chanjar.weixin.common.error.WxErrorException;
74
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
5+
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
86
import me.chanjar.weixin.common.error.WxErrorException;
97
import me.chanjar.weixin.mp.api.WxMpService;
108
import me.chanjar.weixin.open.bean.WxOpenCreateResult;
@@ -31,6 +29,10 @@ public interface WxOpenComponentService {
3129
* The constant API_COMPONENT_TOKEN_URL.
3230
*/
3331
String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
32+
/**
33+
* 启动ticket推送服务
34+
*/
35+
String API_START_PUSH_TICKET = "https://api.weixin.qq.com/cgi-bin/component/api_start_push_ticket";
3436
/**
3537
* The constant API_CREATE_PREAUTHCODE_URL.
3638
*/
@@ -220,6 +222,13 @@ public interface WxOpenComponentService {
220222
*/
221223
boolean checkSignature(String timestamp, String nonce, String signature);
222224

225+
/**
226+
* 启动ticket推送服务 该 API 用于启动ticket推送服务
227+
*
228+
* @throws WxErrorException 如果调用失败返回此异常
229+
*/
230+
void startPushTicket() throws WxErrorException;
231+
223232
/**
224233
* Gets component access token.
225234
*

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ public boolean checkSignature(String timestamp, String nonce, String signature)
149149
}
150150
}
151151

152+
@Override
153+
public void startPushTicket() throws WxErrorException {
154+
WxOpenConfigStorage config = getWxOpenConfigStorage();
155+
156+
JsonObject json = new JsonObject();
157+
json.addProperty("component_appid", config.getComponentAppId());
158+
json.addProperty("component_secret", config.getComponentAppSecret());
159+
160+
getWxOpenService().post(API_START_PUSH_TICKET, json.toString());
161+
}
162+
152163
@Override
153164
public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException {
154165
final WxOpenConfigStorage config = this.getWxOpenConfigStorage();
Lines changed: 125 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package me.chanjar.weixin.open.api.impl;
22

3+
import com.google.inject.Inject;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
import me.chanjar.weixin.open.api.WxOpenComponentService;
6+
import me.chanjar.weixin.open.test.ApiTestModule;
7+
import org.testng.annotations.Guice;
38
import org.testng.annotations.Test;
49

510
/**
@@ -8,153 +13,162 @@
813
* @author <a href="https://github.com/binarywang">Binary Wang</a>
914
* @date 2020-06-06
1015
*/
16+
@Guice(modules = ApiTestModule.class)
1117
public class WxOpenComponentServiceImplTest {
1218

13-
@Test
14-
public void testGetWxMpServiceByAppid() {
15-
}
19+
@Inject
20+
WxOpenComponentService wxOpenComponentService;
1621

17-
@Test
18-
public void testGetWxMaServiceByAppid() {
19-
}
22+
@Test
23+
public void testGetWxMpServiceByAppid() {
24+
}
2025

21-
@Test
22-
public void testGetWxFastMaServiceByAppid() {
23-
}
26+
@Test
27+
public void testGetWxMaServiceByAppid() {
28+
}
2429

25-
@Test
26-
public void testGetWxOpenService() {
27-
}
30+
@Test
31+
public void testGetWxFastMaServiceByAppid() {
32+
}
2833

29-
@Test
30-
public void testGetWxOpenConfigStorage() {
31-
}
34+
@Test
35+
public void testGetWxOpenService() {
36+
}
3237

33-
@Test
34-
public void testCheckSignature() {
35-
}
38+
@Test
39+
public void testGetWxOpenConfigStorage() {
40+
}
3641

37-
@Test
38-
public void testGetComponentAccessToken() {
39-
}
42+
@Test
43+
public void testCheckSignature() {
44+
}
4045

41-
@Test
42-
public void testPost() {
43-
}
46+
@Test
47+
public void testGetComponentAccessToken() {
48+
}
4449

45-
@Test
46-
public void testTestPost() {
47-
}
50+
@Test
51+
public void testPost() {
52+
}
4853

49-
@Test
50-
public void testGet() {
51-
}
54+
@Test
55+
public void testTestPost() {
56+
}
5257

53-
@Test
54-
public void testTestGet() {
55-
}
58+
@Test
59+
public void testGet() {
60+
}
5661

57-
@Test
58-
public void testGetPreAuthUrl() {
59-
}
62+
@Test
63+
public void testTestGet() {
64+
}
6065

61-
@Test
62-
public void testTestGetPreAuthUrl() {
63-
}
66+
@Test
67+
public void testGetPreAuthUrl() {
68+
}
6469

65-
@Test
66-
public void testGetMobilePreAuthUrl() {
67-
}
70+
@Test
71+
public void testTestGetPreAuthUrl() {
72+
}
6873

69-
@Test
70-
public void testTestGetMobilePreAuthUrl() {
71-
}
74+
@Test
75+
public void testGetMobilePreAuthUrl() {
76+
}
7277

73-
@Test
74-
public void testRoute() {
75-
}
78+
@Test
79+
public void testTestGetMobilePreAuthUrl() {
80+
}
7681

77-
@Test
78-
public void testGetQueryAuth() {
79-
}
82+
@Test
83+
public void testRoute() {
84+
}
8085

81-
@Test
82-
public void testGetAuthorizerInfo() {
83-
}
86+
@Test
87+
public void testGetQueryAuth() {
88+
}
8489

85-
@Test
86-
public void testGetAuthorizerList() {
87-
}
90+
@Test
91+
public void testGetAuthorizerInfo() {
92+
}
8893

89-
@Test
90-
public void testGetAuthorizerOption() {
91-
}
94+
@Test
95+
public void testGetAuthorizerList() {
96+
}
9297

93-
@Test
94-
public void testSetAuthorizerOption() {
95-
}
98+
@Test
99+
public void testGetAuthorizerOption() {
100+
}
96101

97-
@Test
98-
public void testGetAuthorizerAccessToken() {
99-
}
102+
@Test
103+
public void testSetAuthorizerOption() {
104+
}
100105

101-
@Test
102-
public void testOauth2getAccessToken() {
103-
}
106+
@Test
107+
public void testGetAuthorizerAccessToken() {
108+
}
104109

105-
@Test
106-
public void testTestCheckSignature() {
107-
}
110+
@Test
111+
public void testOauth2getAccessToken() {
112+
}
108113

109-
@Test
110-
public void testOauth2refreshAccessToken() {
111-
}
114+
@Test
115+
public void testTestCheckSignature() {
116+
}
112117

113-
@Test
114-
public void testOauth2buildAuthorizationUrl() {
115-
}
118+
@Test
119+
public void testOauth2refreshAccessToken() {
120+
}
116121

117-
@Test
118-
public void testMiniappJscode2Session() {
119-
}
122+
@Test
123+
public void testOauth2buildAuthorizationUrl() {
124+
}
120125

121-
@Test
122-
public void testGetTemplateDraftList() {
123-
}
126+
@Test
127+
public void testMiniappJscode2Session() {
128+
}
124129

125-
@Test
126-
public void testGetTemplateList() {
127-
}
130+
@Test
131+
public void testGetTemplateDraftList() {
132+
}
128133

129-
@Test
130-
public void testAddToTemplate() {
131-
}
134+
@Test
135+
public void testGetTemplateList() {
136+
}
132137

133-
@Test
134-
public void testDeleteTemplate() {
135-
}
138+
@Test
139+
public void testAddToTemplate() {
140+
}
136141

137-
@Test
138-
public void testCreateOpenAccount() {
139-
}
142+
@Test
143+
public void testDeleteTemplate() {
144+
}
140145

141-
@Test
142-
public void testBindOpenAccount() {
143-
}
146+
@Test
147+
public void testCreateOpenAccount() {
148+
}
144149

145-
@Test
146-
public void testUnbindOpenAccount() {
147-
}
150+
@Test
151+
public void testBindOpenAccount() {
152+
}
148153

149-
@Test
150-
public void testGetOpenAccount() {
151-
}
154+
@Test
155+
public void testUnbindOpenAccount() {
156+
}
152157

153-
@Test
154-
public void testFastRegisterWeapp() {
155-
}
158+
@Test
159+
public void testGetOpenAccount() {
160+
}
156161

157-
@Test
158-
public void testFastRegisterWeappSearch() {
159-
}
162+
@Test
163+
public void testFastRegisterWeapp() {
164+
}
165+
166+
@Test
167+
public void testFastRegisterWeappSearch() {
168+
}
169+
170+
@Test
171+
public void testStartPushTicket() throws WxErrorException {
172+
wxOpenComponentService.startPushTicket();
173+
}
160174
}

weixin-java-open/src/test/java/me/chanjar/weixin/open/test/ApiTestModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.thoughtworks.xstream.XStream;
66
import me.chanjar.weixin.common.error.WxRuntimeException;
77
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
8+
import me.chanjar.weixin.open.api.WxOpenComponentService;
89
import me.chanjar.weixin.open.api.WxOpenMaService;
910
import me.chanjar.weixin.open.api.WxOpenMpService;
1011
import me.chanjar.weixin.open.api.WxOpenService;
@@ -33,6 +34,7 @@ public void configure(Binder binder) {
3334

3435
binder.bind(TestConfigStorage.class).toInstance(config);
3536
binder.bind(WxOpenService.class).toInstance(service);
37+
binder.bind(WxOpenComponentService.class).toInstance(service.getWxOpenComponentService());
3638

3739
if (config.getTestMpAppId() != null && !config.getTestMpAppId().isEmpty()) {
3840
//如果配置了测试公众号,则构建公众号服务依赖

0 commit comments

Comments
 (0)