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
privateintmaxRetryTimes = 5;
110110

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

113128
publicenumStorageType{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
packageme.chanjar.weixin.open.api;
2+
3+
importme.chanjar.weixin.common.error.WxErrorException;
4+
importme.chanjar.weixin.open.bean.authandicp.WxOpenQueryAuthAndIcpResult;
5+
importme.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpParam;
6+
importme.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpResult;
7+
8+
/**
9+
* 微信第三方平台 小程序认证及备案
10+
* @author 痴货
11+
* @createTime 2025/06/18 23:00
12+
*/
13+
publicinterfaceWxOpenMaAuthAndIcpService{
14+
15+
StringQUERY_AUTH_AND_ICP = "https://api.weixin.qq.com/wxa/sec/query_auth_and_icp";
16+
17+
StringSUBMIT_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+
WxOpenQueryAuthAndIcpResultqueryAuthAndIcp(StringprocedureId) throwsWxErrorException;
25+
26+
/**
27+
* 提交小程序认证及备案信息。
28+
* @param param 提交小程序认证及备案信息参数
29+
* @return 提交结果
30+
*/
31+
WxOpenSubmitAuthAndIcpResultsubmitAuthAndIcp(WxOpenSubmitAuthAndIcpParamparam) throwsWxErrorException;
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
StringOPEN_GET_ALL_CATEGORIES = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories";
5555
/**
56-
* 8.2 添加类目
56+
* 8.2 获取不同类型主体可设置的类目
57+
*/
58+
StringOPEN_GET_ALL_CATEGORIES_BY_TYPE = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategoriesbytype";
59+
/**
60+
* 8.3 添加类目
5761
*/
5862
StringOPEN_ADD_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory";
5963
/**
60-
* 8.3 删除类目
64+
* 8.4 删除类目
6165
*/
6266
StringOPEN_DELETE_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory";
6367
/**
64-
* 8.4 获取账号已经设置的所有类目
68+
* 8.5 获取账号已经设置的所有类目
6569
*/
6670
StringOPEN_GET_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory";
6771
/**
68-
* 8.5 修改类目
72+
* 8.6 修改类目
6973
*/
7074
StringOPEN_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
StringgetAllCategories() throwsWxErrorException;
168172

169173
/**
170-
* 8.2添加类目
174+
* 8.2获取不同类型主体可设置的类目
175+
*/
176+
WxOpenGetAllCategoriesByTypeResultgetAllCategoriesByType(StringverifyType) throwsWxErrorException;
177+
178+
/**
179+
* 8.3添加类目
171180
*
172181
* @param categoryList 类目列表
173182
* @return .
@@ -176,7 +185,7 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
176185
WxOpenResultaddCategory(List<WxFastMaCategory> categoryList) throwsWxErrorException;
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
WxOpenResultdeleteCategory(intfirst, intsecond) throwsWxErrorException;
187196

188197
/**
189-
* 8.4获取账号已经设置的所有类目
198+
* 8.5获取账号已经设置的所有类目
190199
*
191200
* @return .
192201
* @throws WxErrorException .
193202
*/
194203
WxFastMaBeenSetCategoryResultgetCategory() throwsWxErrorException;
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
WxOpenIcpVerifyTaskResultqueryIcpVerifyTask(StringtaskId) throwsWxErrorException;
121121

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

230-
/**
231-
* 申请小程序认证及备案
232-
*
233-
* @param param 参数
234-
* @return r
235-
* @throws WxErrorException e
236-
*/
237-
WxOpenSubmitAuthAndIcpResultsubmitAuthAndIcp(WxOpenSubmitAuthAndIcpParamparam) throwsWxErrorException;
238-
239-
/**
240-
* 查询小程序认证及备案进度
241-
* @param procedureId 小程序认证及备案任务流程id
242-
* @return r
243-
* @throws WxErrorException e
244-
*/
245-
WxOpenQueryAuthAndIcpResultqueryAuthAndIcp(StringprocedureId) throwsWxErrorException;
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
WxOpenMaIcpServicegetIcpService();
733733

734+
/**
735+
* 小程序认证及备案服务
736+
*
737+
* @return 小程序认证及备案服务
738+
*/
739+
WxOpenMaAuthAndIcpServicegetAuthAndIcpService();
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
returnget(OPEN_GET_ALL_CATEGORIES, "");
113113
}
114114

115+
@Override
116+
publicWxOpenGetAllCategoriesByTypeResultgetAllCategoriesByType(StringverifyType){
117+
returnnull;
118+
}
119+
115120
@Override
116121
publicWxOpenResultaddCategory(List<WxFastMaCategory> categoryList) throwsWxErrorException{
117122
Map<String, Object> map = newHashMap<>();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
packageme.chanjar.weixin.open.api.impl;
2+
3+
importcn.binarywang.wx.miniapp.api.WxMaService;
4+
importcn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
5+
importcom.google.gson.JsonObject;
6+
importme.chanjar.weixin.common.error.WxErrorException;
7+
importme.chanjar.weixin.open.api.WxOpenMaAuthAndIcpService;
8+
importme.chanjar.weixin.open.bean.authandicp.WxOpenQueryAuthAndIcpResult;
9+
importme.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpParam;
10+
importme.chanjar.weixin.open.bean.authandicp.WxOpenSubmitAuthAndIcpResult;
11+
importme.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
12+
13+
/**
14+
* 微信第三方平台 小程序认证及备案
15+
*
16+
* @author 痴货
17+
* @createTime 2025/06/18 23:00
18+
*/
19+
publicclassWxOpenMaAuthAndIcpServiceImplimplementsWxOpenMaAuthAndIcpService{
20+
21+
privatefinalWxMaServicewxMaService;
22+
23+
publicWxOpenMaAuthAndIcpServiceImpl(WxMaServicewxMaService){
24+
this.wxMaService = wxMaService;
25+
}
26+
27+
@Override
28+
publicWxOpenQueryAuthAndIcpResultqueryAuthAndIcp(StringprocedureId) throwsWxErrorException{
29+
JsonObjectparams = newJsonObject();
30+
params.addProperty("procedure_id", procedureId);
31+
Stringresponse = wxMaService.post(QUERY_AUTH_AND_ICP, params);
32+
returnWxOpenGsonBuilder.create().fromJson(response, WxOpenQueryAuthAndIcpResult.class);
33+
}
34+
35+
@Override
36+
publicWxOpenSubmitAuthAndIcpResultsubmitAuthAndIcp(WxOpenSubmitAuthAndIcpParamparam) throwsWxErrorException{
37+
Stringresponse = wxMaService.post(SUBMIT_AUTH_AND_ICP, param);
38+
returnWxMaGsonBuilder.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
returnwxMaService.get(OPEN_GET_ALL_CATEGORIES, "");
9595
}
9696

97+
@Override
98+
publicWxOpenGetAllCategoriesByTypeResultgetAllCategoriesByType(StringverifyType) throwsWxErrorException{
99+
JsonObjectparams = newJsonObject();
100+
params.addProperty("verify_type", verifyType);
101+
Stringresponse = wxMaService.post(OPEN_GET_ALL_CATEGORIES_BY_TYPE, params);
102+
returnWxOpenGsonBuilder.create().fromJson(response, WxOpenGetAllCategoriesByTypeResult.class);
103+
}
104+
97105
@Override
98106
publicWxOpenResultaddCategory(List<WxFastMaCategory> categoryList) throwsWxErrorException{
99107
Map<String, Object> map = newHashMap<>();

‎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
returnWxOpenGsonBuilder.create().fromJson(response, WxOpenIcpVerifyTaskResult.class);
4747
}
4848

49-
/**
50-
* 发起小程序管理员人脸核身
51-
*
52-
* @return 人脸核验任务结果
53-
* @throws WxErrorException e
54-
*/
55-
@Override
56-
publicWxOpenIcpCreateIcpVerifyTaskResultcreateIcpVerifyTask() throwsWxErrorException{
57-
returncreateIcpVerifyTask(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-
publicWxOpenSubmitAuthAndIcpResultsubmitAuthAndIcp(WxOpenSubmitAuthAndIcpParamparam) throwsWxErrorException{
239-
Stringresponse = wxMaService.post(SUBMIT_AUTH_AND_ICP, param);
240-
returnWxMaGsonBuilder.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-
publicWxOpenQueryAuthAndIcpResultqueryAuthAndIcp(StringprocedureId) throwsWxErrorException{
252-
JsonObjectparams = newJsonObject();
253-
params.addProperty("procedure_id", procedureId);
254-
Stringresponse = wxMaService.post(QUERY_AUTH_AND_ICP, params);
255-
returnWxOpenGsonBuilder.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
privatefinalWxOpenMaShoppingOrdersServiceshoppingOrdersService;
5757
@Getter
5858
privatefinalWxOpenMaEmbeddedServiceembeddedService;
59+
@Getter
60+
privatefinalWxOpenMaAuthAndIcpServiceauthAndIcpService;
5961

6062
publicWxOpenMaServiceImpl(WxOpenComponentServicewxOpenComponentService, StringappId, WxMaConfigwxMaConfig){
6163
this.wxOpenComponentService = wxOpenComponentService;
@@ -67,6 +69,7 @@ public WxOpenMaServiceImpl(WxOpenComponentService wxOpenComponentService, String
6769
this.privacyService = newWxOpenMaPrivacyServiceImpl(this);
6870
this.shoppingOrdersService = newWxOpenMaShoppingOrdersServiceImpl(this);
6971
this.embeddedService = newWxOpenMaEmbeddedServiceImpl(this);
72+
this.authAndIcpService = newWxOpenMaAuthAndIcpServiceImpl(this);
7073
initHttp();
7174
}
7275

0 commit comments

Comments
(0)