Skip to content

Commit 3c84cee

Browse files
authored
binarywang#794 增加实现开放小程序的设置支持版本库接口;增加WxOpenResult开放平台返回类型并修改相关接口实现。
2 parents aa106de + bb9768a commit 3c84cee

File tree

9 files changed

+132
-50
lines changed

9 files changed

+132
-50
lines changed

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public interface WxOpenMaService extends WxMaService {
219219
* @return
220220
* @throws WxErrorException
221221
*/
222-
String bindTester(String wechatid) throws WxErrorException;
222+
WxOpenResult bindTester(String wechatid) throws WxErrorException;
223223

224224
/**
225225
* 解除绑定小程序体验者
@@ -228,7 +228,7 @@ public interface WxOpenMaService extends WxMaService {
228228
* @return
229229
* @throws WxErrorException
230230
*/
231-
String unbindTester(String wechatid) throws WxErrorException;
231+
WxOpenResult unbindTester(String wechatid) throws WxErrorException;
232232

233233
/**
234234
* 获得体验者列表
@@ -248,7 +248,7 @@ public interface WxOpenMaService extends WxMaService {
248248
* @return
249249
* @throws WxErrorException
250250
*/
251-
String codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException;
251+
WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException;
252252

253253
/**
254254
* 获取体验小程序的体验二维码
@@ -294,31 +294,31 @@ public interface WxOpenMaService extends WxMaService {
294294
* @return
295295
* @throws WxErrorException
296296
*/
297-
String getAuditStatus(Long auditid) throws WxErrorException;
297+
WxOpenMaQueryAuditResult getAuditStatus(Long auditid) throws WxErrorException;
298298

299299
/**
300300
* 查询最新一次提交的审核状态(仅供第三方代小程序调用)
301301
*
302302
* @return
303303
* @throws WxErrorException
304304
*/
305-
String getLatestAuditStatus() throws WxErrorException;
305+
WxOpenMaQueryAuditResult getLatestAuditStatus() throws WxErrorException;
306306

307307
/**
308308
* 发布已通过审核的小程序(仅供第三方代小程序调用)
309309
*
310310
* @return
311311
* @throws WxErrorException
312312
*/
313-
String releaesAudited() throws WxErrorException;
313+
WxOpenResult releaesAudited() throws WxErrorException;
314314

315315
/**
316316
* 11. 小程序版本回退(仅供第三方代小程序调用)
317317
*
318318
* @return
319319
* @throws WxErrorException
320320
*/
321-
String revertCodeReleaes() throws WxErrorException;
321+
WxOpenResult revertCodeReleaes() throws WxErrorException;
322322

323323
/**
324324
* 15. 小程序审核撤回
@@ -329,6 +329,21 @@ public interface WxOpenMaService extends WxMaService {
329329
* @return
330330
* @throws WxErrorException
331331
*/
332-
String undoCodeAudit() throws WxErrorException;
332+
WxOpenResult undoCodeAudit() throws WxErrorException;
333+
334+
/**
335+
* 查询当前设置的最低基础库版本及各版本用户占比 (仅供第三方代小程序调用)
336+
* @return
337+
* @throws WxErrorException
338+
*/
339+
String getSupportVersion() throws WxErrorException;
340+
341+
/**
342+
* 设置最低基础库版本(仅供第三方代小程序调用)
343+
* @param version
344+
* @return
345+
* @throws WxErrorException
346+
*/
347+
String setSupportVersion(String version) throws WxErrorException;
333348

334349
}

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

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ public String getAccountBasicInfo() throws WxErrorException {
146146
* @throws WxErrorException
147147
*/
148148
@Override
149-
public String bindTester(String wechatid) throws WxErrorException {
149+
public WxOpenResult bindTester(String wechatid) throws WxErrorException {
150150
JsonObject paramJson = new JsonObject();
151151
paramJson.addProperty("wechatid", wechatid);
152152
String response = post(API_BIND_TESTER, GSON.toJson(paramJson));
153-
return response;
153+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
154154
}
155155

156156
/**
@@ -161,11 +161,11 @@ public String bindTester(String wechatid) throws WxErrorException {
161161
* @throws WxErrorException
162162
*/
163163
@Override
164-
public String unbindTester(String wechatid) throws WxErrorException {
164+
public WxOpenResult unbindTester(String wechatid) throws WxErrorException {
165165
JsonObject paramJson = new JsonObject();
166166
paramJson.addProperty("wechatid", wechatid);
167167
String response = post(API_UNBIND_TESTER, GSON.toJson(paramJson));
168-
return response;
168+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
169169
}
170170

171171
/**
@@ -193,15 +193,15 @@ public WxOpenMaTesterListResult getTesterList() throws WxErrorException {
193193
* @throws WxErrorException
194194
*/
195195
@Override
196-
public String codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException {
196+
public WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException {
197197
JsonObject params = new JsonObject();
198198
params.addProperty("template_id", templateId);
199199
params.addProperty("user_version", userVersion);
200200
params.addProperty("user_desc", userDesc);
201201
//注意:ext_json必须是字符串类型
202202
params.addProperty("ext_json", GSON.toJson(extInfo));
203203
String response = post(API_CODE_COMMIT, GSON.toJson(params));
204-
return response;
204+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
205205
}
206206

207207
/**
@@ -265,11 +265,11 @@ public WxOpenMaSubmitAuditResult submitAudit(WxOpenMaSubmitAuditMessage submitAu
265265
* @throws WxErrorException
266266
*/
267267
@Override
268-
public String getAuditStatus(Long auditid) throws WxErrorException {
268+
public WxOpenMaQueryAuditResult getAuditStatus(Long auditid) throws WxErrorException {
269269
JsonObject params = new JsonObject();
270270
params.addProperty("auditid", auditid);
271271
String response = post(API_GET_AUDIT_STATUS, GSON.toJson(params));
272-
return response;
272+
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaQueryAuditResult.class);
273273
}
274274

275275
/**
@@ -279,9 +279,9 @@ public String getAuditStatus(Long auditid) throws WxErrorException {
279279
* @throws WxErrorException
280280
*/
281281
@Override
282-
public String getLatestAuditStatus() throws WxErrorException {
282+
public WxOpenMaQueryAuditResult getLatestAuditStatus() throws WxErrorException {
283283
String response = get(API_GET_LATEST_AUDIT_STATUS, null);
284-
return response;
284+
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaQueryAuditResult.class);
285285
}
286286

287287
/**
@@ -294,10 +294,10 @@ public String getLatestAuditStatus() throws WxErrorException {
294294
* @throws WxErrorException
295295
*/
296296
@Override
297-
public String releaesAudited() throws WxErrorException {
297+
public WxOpenResult releaesAudited() throws WxErrorException {
298298
JsonObject params = new JsonObject();
299299
String response = post(API_RELEASE, GSON.toJson(params));
300-
return response;
300+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
301301
}
302302

303303
/**
@@ -307,9 +307,9 @@ public String releaesAudited() throws WxErrorException {
307307
* @throws WxErrorException
308308
*/
309309
@Override
310-
public String revertCodeReleaes() throws WxErrorException {
310+
public WxOpenResult revertCodeReleaes() throws WxErrorException {
311311
String response = get(API_REVERT_CODE_RELEASE, null);
312-
return response;
312+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
313313
}
314314

315315
/**
@@ -322,8 +322,36 @@ public String revertCodeReleaes() throws WxErrorException {
322322
* @throws WxErrorException
323323
*/
324324
@Override
325-
public String undoCodeAudit() throws WxErrorException {
325+
public WxOpenResult undoCodeAudit() throws WxErrorException {
326326
String response = get(API_UNDO_CODE_AUDIT, null);
327+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
328+
}
329+
330+
/**
331+
* 查询当前设置的最低基础库版本及各版本用户占比 (仅供第三方代小程序调用)
332+
*
333+
* @return
334+
* @throws WxErrorException
335+
*/
336+
@Override
337+
public String getSupportVersion() throws WxErrorException {
338+
JsonObject params = new JsonObject();
339+
String response = post(API_GET_WEAPP_SUPPORT_VERSION, GSON.toJson(params));
340+
return response;
341+
}
342+
343+
/**
344+
* 设置最低基础库版本(仅供第三方代小程序调用)
345+
*
346+
* @param version
347+
* @return
348+
* @throws WxErrorException
349+
*/
350+
@Override
351+
public String setSupportVersion(String version) throws WxErrorException {
352+
JsonObject params = new JsonObject();
353+
params.addProperty("version", version);
354+
String response = post(API_SET_WEAPP_SUPPORT_VERSION, GSON.toJson(params));
327355
return response;
328356
}
329357

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.apache.commons.lang3.builder.ToStringBuilder;
77
import org.apache.commons.lang3.builder.ToStringStyle;
88

9-
import java.io.Serializable;
109
import java.util.List;
1110

1211
/**
@@ -16,10 +15,7 @@
1615
* @date 2018/9/12
1716
*/
1817
@Data
19-
public class WxOpenMaCategoryListResult implements Serializable {
20-
21-
private String errcode;
22-
private String errmsg;
18+
public class WxOpenMaCategoryListResult extends WxOpenResult {
2319

2420
@SerializedName("category_list")
2521
List<WxOpenMaCategory> categoryList;

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.google.gson.annotations.SerializedName;
44
import lombok.Data;
55

6-
import java.io.Serializable;
76
import java.util.List;
87

98
/**
@@ -13,10 +12,7 @@
1312
* @date 2018/9/12
1413
*/
1514
@Data
16-
public class WxOpenMaDomainResult implements Serializable {
17-
18-
private String errcode;
19-
private String errmsg;
15+
public class WxOpenMaDomainResult extends WxOpenResult {
2016

2117
@SerializedName("requestdomain")
2218
List<String> requestdomainList;
@@ -29,5 +25,5 @@ public class WxOpenMaDomainResult implements Serializable {
2925

3026
@SerializedName("downloaddomain")
3127
List<String> downloaddomainList;
32-
28+
3329
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.apache.commons.lang3.builder.ToStringBuilder;
66
import org.apache.commons.lang3.builder.ToStringStyle;
77

8-
import java.io.Serializable;
98
import java.util.List;
109

1110
/**
@@ -15,10 +14,7 @@
1514
* @date 2018/9/12
1615
*/
1716
@Data
18-
public class WxOpenMaPageListResult implements Serializable {
19-
20-
private String errcode;
21-
private String errmsg;
17+
public class WxOpenMaPageListResult extends WxOpenResult {
2218

2319
@SerializedName("page_list")
2420
List<String> pageList;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
/**
7+
* @author yqx
8+
* @date 2018/10/3
9+
*/
10+
@Data
11+
public class WxOpenMaQueryAuditResult extends WxOpenResult {
12+
/**
13+
* 审核编号
14+
*/
15+
@SerializedName("auditid")
16+
Long auditId;
17+
18+
/**
19+
* 审核状态:2-审核中,0-审核通过,1-审核失败
20+
*/
21+
Integer status;
22+
23+
/**
24+
* 审核失败原因
25+
*/
26+
String reason;
27+
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
import com.google.gson.annotations.SerializedName;
44
import lombok.Data;
55

6-
import java.io.Serializable;
7-
86
/**
97
* 微信开放平台小程序发布代码审核结果
108
*
119
* @author yqx
1210
* @date 2018/9/12
1311
*/
1412
@Data
15-
public class WxOpenMaSubmitAuditResult implements Serializable {
16-
17-
private String errcode;
18-
private String errmsg;
13+
public class WxOpenMaSubmitAuditResult extends WxOpenResult {
1914

2015
/**
2116
* 审核编号

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.apache.commons.lang3.builder.ToStringBuilder;
77
import org.apache.commons.lang3.builder.ToStringStyle;
88

9-
import java.io.Serializable;
109
import java.util.List;
1110

1211
/**
@@ -16,10 +15,7 @@
1615
* @date 2018/9/12
1716
*/
1817
@Data
19-
public class WxOpenMaTesterListResult implements Serializable {
20-
21-
private String errcode;
22-
private String errmsg;
18+
public class WxOpenMaTesterListResult extends WxOpenResult {
2319

2420
@SerializedName("members")
2521
List<WxOpenMaMember> membersList;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import lombok.Data;
4+
import org.apache.commons.lang3.StringUtils;
5+
import org.apache.commons.lang3.builder.ToStringBuilder;
6+
import org.apache.commons.lang3.builder.ToStringStyle;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* 基础的微信开放平台请求结果
12+
*
13+
* @author yqx
14+
* @date 2018/10/1
15+
*/
16+
@Data
17+
public class WxOpenResult implements Serializable {
18+
protected String errcode;
19+
protected String errmsg;
20+
21+
/**
22+
* 请求是否成功
23+
*
24+
* @return
25+
*/
26+
public boolean isSuccess() {
27+
return StringUtils.equalsIgnoreCase(errcode, "0");
28+
}
29+
30+
public String toString() {
31+
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
32+
}
33+
}

0 commit comments

Comments
 (0)