Skip to content

Commit 990dbba

Browse files
qw8881569Binary Wang
authored andcommitted
🎨 【开放平台】重构小程序认证及备案相关接口
1 parent d85e04a commit 990dbba

18 files changed

+1292
-76
lines changed

spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/properties/WxOpenProperties.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ public static class ConfigStorage implements Serializable {
108108
*/
109109
private int maxRetryTimes = 5;
110110

111+
/**
112+
* 连接超时时间,单位毫秒
113+
*/
114+
private int connectionTimeout = 5000;
115+
116+
/**
117+
* 读数据超时时间,即socketTimeout,单位毫秒
118+
*/
119+
private int soTimeout = 1;
120+
121+
/**
122+
* 从连接池获取链接的超时时间,单位毫秒
123+
*/
124+
private int connectionRequestTimeout = 5000;
125+
111126
}
112127

113128
public enum StorageType {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package me.chanjar.weixin.open.api;
2+
3+
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.open.bean.authandicp.WxOpenQueryAuthAndIcpResult;
5+
import me.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpParam;
6+
import me.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpResult;
7+
8+
/**
9+
* 微信第三方平台 小程序认证及备案
10+
* @author 痴货
11+
* @createTime 2025/06/18 23:00
12+
*/
13+
public interface WxOpenMaAuthAndIcpService {
14+
15+
String QUERY_AUTH_AND_ICP = "https://api.weixin.qq.com/wxa/sec/query_auth_and_icp";
16+
17+
String SUBMIT_AUTH_AND_ICP = "https://api.weixin.qq.com/wxa/sec/submit_auth_and_icp";
18+
19+
/**
20+
* 查询小程序认证及备案进度。
21+
* @param procedureId 小程序认证及备案任务流程id
22+
* @return 小程序认证及备案进度
23+
*/
24+
WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException;
25+
26+
/**
27+
* 提交小程序认证及备案信息。
28+
* @param param 提交小程序认证及备案信息参数
29+
* @return 提交结果
30+
*/
31+
WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException;
32+
}

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,23 @@ public interface WxOpenMaBasicService {
5353
*/
5454
String OPEN_GET_ALL_CATEGORIES = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories";
5555
/**
56-
* 8.2 添加类目
56+
* 8.2 获取不同类型主体可设置的类目
57+
*/
58+
String OPEN_GET_ALL_CATEGORIES_BY_TYPE = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategoriesbytype";
59+
/**
60+
* 8.3 添加类目
5761
*/
5862
String OPEN_ADD_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory";
5963
/**
60-
* 8.3 删除类目
64+
* 8.4 删除类目
6165
*/
6266
String OPEN_DELETE_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory";
6367
/**
64-
* 8.4 获取账号已经设置的所有类目
68+
* 8.5 获取账号已经设置的所有类目
6569
*/
6670
String OPEN_GET_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory";
6771
/**
68-
* 8.5 修改类目
72+
* 8.6 修改类目
6973
*/
7074
String OPEN_MODIFY_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory";
7175

@@ -167,7 +171,12 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
167171
String getAllCategories() throws WxErrorException;
168172

169173
/**
170-
* 8.2添加类目
174+
* 8.2获取不同类型主体可设置的类目
175+
*/
176+
WxOpenGetAllCategoriesByTypeResult getAllCategoriesByType(String verifyType) throws WxErrorException;
177+
178+
/**
179+
* 8.3添加类目
171180
*
172181
* @param categoryList 类目列表
173182
* @return .
@@ -176,7 +185,7 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
176185
WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException;
177186

178187
/**
179-
* 8.3删除类目
188+
* 8.4删除类目
180189
*
181190
* @param first 一级类目ID
182191
* @param second 二级类目ID
@@ -186,15 +195,15 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
186195
WxOpenResult deleteCategory(int first, int second) throws WxErrorException;
187196

188197
/**
189-
* 8.4获取账号已经设置的所有类目
198+
* 8.5获取账号已经设置的所有类目
190199
*
191200
* @return .
192201
* @throws WxErrorException .
193202
*/
194203
WxFastMaBeenSetCategoryResult getCategory() throws WxErrorException;
195204

196205
/**
197-
* 8.5修改类目
206+
* 8.6修改类目
198207
*
199208
* @param category 实体
200209
* @return .

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ public interface WxOpenMaIcpService {
119119
*/
120120
WxOpenIcpVerifyTaskResult queryIcpVerifyTask(String taskId) throws WxErrorException;
121121

122-
/**
123-
* 发起小程序管理员人脸核身
124-
*
125-
* @return 人脸核验任务结果
126-
* @throws WxErrorException e
127-
*/
128-
WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask() throws WxErrorException;
129-
130122
/**
131123
* 发起小程序管理员人脸核身
132124
*
@@ -227,21 +219,4 @@ public interface WxOpenMaIcpService {
227219
*/
228220
File getIcpMedia(String mediaId) throws WxErrorException;
229221

230-
/**
231-
* 申请小程序认证及备案
232-
*
233-
* @param param 参数
234-
* @return r
235-
* @throws WxErrorException e
236-
*/
237-
WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException;
238-
239-
/**
240-
* 查询小程序认证及备案进度
241-
* @param procedureId 小程序认证及备案任务流程id
242-
* @return r
243-
* @throws WxErrorException e
244-
*/
245-
WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException;
246-
247222
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,13 @@ WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, Li
731731
*/
732732
WxOpenMaIcpService getIcpService();
733733

734+
/**
735+
* 小程序认证及备案服务
736+
*
737+
* @return 小程序认证及备案服务
738+
*/
739+
WxOpenMaAuthAndIcpService getAuthAndIcpService();
740+
734741
/**
735742
* 小程序用户隐私保护指引服务
736743
*

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public String getAllCategories() throws WxErrorException {
112112
return get(OPEN_GET_ALL_CATEGORIES, "");
113113
}
114114

115+
@Override
116+
public WxOpenGetAllCategoriesByTypeResult getAllCategoriesByType(String verifyType) {
117+
return null;
118+
}
119+
115120
@Override
116121
public WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException {
117122
Map<String, Object> map = new HashMap<>();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package me.chanjar.weixin.open.api.impl;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
5+
import com.google.gson.JsonObject;
6+
import me.chanjar.weixin.common.error.WxErrorException;
7+
import me.chanjar.weixin.open.api.WxOpenMaAuthAndIcpService;
8+
import me.chanjar.weixin.open.bean.authandicp.WxOpenQueryAuthAndIcpResult;
9+
import me.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpParam;
10+
import me.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpResult;
11+
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
12+
13+
/**
14+
* 微信第三方平台 小程序认证及备案
15+
*
16+
* @author 痴货
17+
* @createTime 2025/06/18 23:00
18+
*/
19+
public class WxOpenMaAuthAndIcpServiceImpl implements WxOpenMaAuthAndIcpService {
20+
21+
private final WxMaService wxMaService;
22+
23+
public WxOpenMaAuthAndIcpServiceImpl(WxMaService wxMaService) {
24+
this.wxMaService = wxMaService;
25+
}
26+
27+
@Override
28+
public WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException {
29+
JsonObject params = new JsonObject();
30+
params.addProperty("procedure_id", procedureId);
31+
String response = wxMaService.post(QUERY_AUTH_AND_ICP, params);
32+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenQueryAuthAndIcpResult.class);
33+
}
34+
35+
@Override
36+
public WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException {
37+
String response = wxMaService.post(SUBMIT_AUTH_AND_ICP, param);
38+
return WxMaGsonBuilder.create().fromJson(response, WxOpenSubmitAuthAndIcpResult.class);
39+
}
40+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public String getAllCategories() throws WxErrorException {
9494
return wxMaService.get(OPEN_GET_ALL_CATEGORIES, "");
9595
}
9696

97+
@Override
98+
public WxOpenGetAllCategoriesByTypeResult getAllCategoriesByType(String verifyType) throws WxErrorException {
99+
JsonObject params = new JsonObject();
100+
params.addProperty("verify_type", verifyType);
101+
String response = wxMaService.post(OPEN_GET_ALL_CATEGORIES_BY_TYPE, params);
102+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenGetAllCategoriesByTypeResult.class);
103+
}
104+
97105
@Override
98106
public WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException {
99107
Map<String, Object> map = new HashMap<>();

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@ public WxOpenIcpVerifyTaskResult queryIcpVerifyTask(String taskId) throws WxErro
4646
return WxOpenGsonBuilder.create().fromJson(response, WxOpenIcpVerifyTaskResult.class);
4747
}
4848

49-
/**
50-
* 发起小程序管理员人脸核身
51-
*
52-
* @return 人脸核验任务结果
53-
* @throws WxErrorException e
54-
*/
55-
@Override
56-
public WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask() throws WxErrorException {
57-
return createIcpVerifyTask(false);
58-
}
59-
6049
/**
6150
* 发起小程序管理员人脸核身
6251
*
@@ -227,31 +216,4 @@ public File getIcpMedia(String mediaId) throws WxErrorException {
227216
}
228217
}
229218

230-
/**
231-
* 申请小程序认证及备案
232-
*
233-
* @param param 参数
234-
* @return r
235-
* @throws WxErrorException e
236-
*/
237-
@Override
238-
public WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException {
239-
String response = wxMaService.post(SUBMIT_AUTH_AND_ICP, param);
240-
return WxMaGsonBuilder.create().fromJson(response, WxOpenSubmitAuthAndIcpResult.class);
241-
}
242-
243-
/**
244-
* 查询小程序认证及备案进度
245-
*
246-
* @param procedureId 小程序认证及备案任务流程id
247-
* @return r
248-
* @throws WxErrorException e
249-
*/
250-
@Override
251-
public WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException {
252-
JsonObject params = new JsonObject();
253-
params.addProperty("procedure_id", procedureId);
254-
String response = wxMaService.post(QUERY_AUTH_AND_ICP, params);
255-
return WxOpenGsonBuilder.create().fromJson(response, WxOpenQueryAuthAndIcpResult.class);
256-
}
257219
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
5656
private final WxOpenMaShoppingOrdersService shoppingOrdersService;
5757
@Getter
5858
private final WxOpenMaEmbeddedService embeddedService;
59+
@Getter
60+
private final WxOpenMaAuthAndIcpService authAndIcpService;
5961

6062
public WxOpenMaServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) {
6163
this.wxOpenComponentService = wxOpenComponentService;
@@ -67,6 +69,7 @@ public WxOpenMaServiceImpl(WxOpenComponentService wxOpenComponentService, String
6769
this.privacyService = new WxOpenMaPrivacyServiceImpl(this);
6870
this.shoppingOrdersService = new WxOpenMaShoppingOrdersServiceImpl(this);
6971
this.embeddedService = new WxOpenMaEmbeddedServiceImpl(this);
72+
this.authAndIcpService = new WxOpenMaAuthAndIcpServiceImpl(this);
7073
initHttp();
7174
}
7275

0 commit comments

Comments
 (0)