@@ -86,6 +86,7 @@ public class WxMpServiceImpl implements WxMpService {
8686
8787 protected WxSessionManager sessionManager = new StandardSessionManager ();
8888
89+ @ Override
8990 public boolean checkSignature (String timestamp , String nonce , String signature ) {
9091 try {
9192 return SHA1 .gen (wxMpConfigStorage .getToken (), timestamp , nonce ).equals (signature );
@@ -94,10 +95,12 @@ public boolean checkSignature(String timestamp, String nonce, String signature)
9495 }
9596 }
9697
98+ @ Override
9799 public String getAccessToken () throws WxErrorException {
98100 return getAccessToken (false );
99101 }
100102
103+ @ Override
101104 public String getAccessToken (boolean forceRefresh ) throws WxErrorException {
102105 if (forceRefresh ) {
103106 wxMpConfigStorage .expireAccessToken ();
@@ -137,10 +140,12 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
137140 return wxMpConfigStorage .getAccessToken ();
138141 }
139142
143+ @ Override
140144 public String getJsapiTicket () throws WxErrorException {
141145 return getJsapiTicket (false );
142146 }
143147
148+ @ Override
144149 public String getJsapiTicket (boolean forceRefresh ) throws WxErrorException {
145150 if (forceRefresh ) {
146151 wxMpConfigStorage .expireJsapiTicket ();
@@ -161,6 +166,7 @@ public String getJsapiTicket(boolean forceRefresh) throws WxErrorException {
161166 return wxMpConfigStorage .getJsapiTicket ();
162167 }
163168
169+ @ Override
164170 public WxJsapiSignature createJsapiSignature (String url ) throws WxErrorException {
165171 long timestamp = System .currentTimeMillis () / 1000 ;
166172 String noncestr = RandomUtils .getRandomStr ();
@@ -184,11 +190,13 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
184190 }
185191 }
186192
193+ @ Override
187194 public void customMessageSend (WxMpCustomMessage message ) throws WxErrorException {
188195 String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send" ;
189196 execute (new SimplePostRequestExecutor (), url , message .toJson ());
190197 }
191198
199+ @ Override
192200 public void menuCreate (WxMenu menu ) throws WxErrorException {
193201 if (menu .getMatchRule () != null ) {
194202 String url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional" ;
@@ -199,16 +207,19 @@ public void menuCreate(WxMenu menu) throws WxErrorException {
199207 }
200208 }
201209
210+ @ Override
202211 public void menuDelete () throws WxErrorException {
203212 String url = "https://api.weixin.qq.com/cgi-bin/menu/delete" ;
204213 execute (new SimpleGetRequestExecutor (), url , null );
205214 }
206215
216+ @ Override
207217 public void menuDelete (String menuid ) throws WxErrorException {
208218 String url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional" ;
209219 execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
210220 }
211221
222+ @ Override
212223 public WxMenu menuGet () throws WxErrorException {
213224 String url = "https://api.weixin.qq.com/cgi-bin/menu/get" ;
214225 try {
@@ -223,6 +234,7 @@ public WxMenu menuGet() throws WxErrorException {
223234 }
224235 }
225236
237+ @ Override
226238 public WxMenu menuTryMatch (String userid ) throws WxErrorException {
227239 String url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch" ;
228240 try {
@@ -237,25 +249,30 @@ public WxMenu menuTryMatch(String userid) throws WxErrorException {
237249 }
238250 }
239251
252+ @ Override
240253 public WxMediaUploadResult mediaUpload (String mediaType , String fileType , InputStream inputStream ) throws WxErrorException , IOException {
241254 return mediaUpload (mediaType , FileUtils .createTmpFile (inputStream , UUID .randomUUID ().toString (), fileType ));
242255 }
243256
257+ @ Override
244258 public WxMediaUploadResult mediaUpload (String mediaType , File file ) throws WxErrorException {
245259 String url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?type=" + mediaType ;
246260 return execute (new MediaUploadRequestExecutor (), url , file );
247261 }
248262
263+ @ Override
249264 public File mediaDownload (String media_id ) throws WxErrorException {
250265 String url = "http://file.api.weixin.qq.com/cgi-bin/media/get" ;
251266 return execute (new MediaDownloadRequestExecutor (wxMpConfigStorage .getTmpDirFile ()), url , "media_id=" + media_id );
252267 }
253268
269+ @ Override
254270 public WxMpMaterialUploadResult materialFileUpload (String mediaType , WxMpMaterial material ) throws WxErrorException {
255271 String url = "https://api.weixin.qq.com/cgi-bin/material/add_material?type=" + mediaType ;
256272 return execute (new MaterialUploadRequestExecutor (), url , material );
257273 }
258274
275+ @ Override
259276 public WxMpMaterialUploadResult materialNewsUpload (WxMpMaterialNews news ) throws WxErrorException {
260277 if (news == null || news .isEmpty ()) {
261278 throw new IllegalArgumentException ("news is empty!" );
@@ -265,21 +282,25 @@ public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws
265282 return WxMpMaterialUploadResult .fromJson (responseContent );
266283 }
267284
285+ @ Override
268286 public InputStream materialImageOrVoiceDownload (String media_id ) throws WxErrorException {
269287 String url = "https://api.weixin.qq.com/cgi-bin/material/get_material" ;
270288 return execute (new MaterialVoiceAndImageDownloadRequestExecutor (wxMpConfigStorage .getTmpDirFile ()), url , media_id );
271289 }
272290
291+ @ Override
273292 public WxMpMaterialVideoInfoResult materialVideoInfo (String media_id ) throws WxErrorException {
274293 String url = "https://api.weixin.qq.com/cgi-bin/material/get_material" ;
275294 return execute (new MaterialVideoInfoRequestExecutor (), url , media_id );
276295 }
277296
297+ @ Override
278298 public WxMpMaterialNews materialNewsInfo (String media_id ) throws WxErrorException {
279299 String url = "https://api.weixin.qq.com/cgi-bin/material/get_material" ;
280300 return execute (new MaterialNewsInfoRequestExecutor (), url , media_id );
281301 }
282302
303+ @ Override
283304 public boolean materialNewsUpdate (WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate ) throws WxErrorException {
284305 String url = "https://api.weixin.qq.com/cgi-bin/material/update_news" ;
285306 String responseText = post (url , wxMpMaterialArticleUpdate .toJson ());
@@ -291,11 +312,13 @@ public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleU
291312 }
292313 }
293314
315+ @ Override
294316 public boolean materialDelete (String media_id ) throws WxErrorException {
295317 String url = "https://api.weixin.qq.com/cgi-bin/material/del_material" ;
296318 return execute (new MaterialDeleteRequestExecutor (), url , media_id );
297319 }
298320
321+ @ Override
299322 public WxMpMaterialCountResult materialCount () throws WxErrorException {
300323 String url = "https://api.weixin.qq.com/cgi-bin/material/get_materialcount" ;
301324 String responseText = get (url , null );
@@ -307,6 +330,7 @@ public WxMpMaterialCountResult materialCount() throws WxErrorException {
307330 }
308331 }
309332
333+ @ Override
310334 public WxMpMaterialNewsBatchGetResult materialNewsBatchGet (int offset , int count ) throws WxErrorException {
311335 String url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material" ;
312336 Map <String , Object > params = new HashMap <>();
@@ -322,6 +346,7 @@ public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count
322346 }
323347 }
324348
349+ @ Override
325350 public WxMpMaterialFileBatchGetResult materialFileBatchGet (String type , int offset , int count ) throws WxErrorException {
326351 String url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material" ;
327352 Map <String , Object > params = new HashMap <>();
@@ -337,30 +362,35 @@ public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offs
337362 }
338363 }
339364
365+ @ Override
340366 public WxMpMassUploadResult massNewsUpload (WxMpMassNews news ) throws WxErrorException {
341367 String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews" ;
342368 String responseContent = execute (new SimplePostRequestExecutor (), url , news .toJson ());
343369 return WxMpMassUploadResult .fromJson (responseContent );
344370 }
345371
372+ @ Override
346373 public WxMpMassUploadResult massVideoUpload (WxMpMassVideo video ) throws WxErrorException {
347374 String url = "http://file.api.weixin.qq.com/cgi-bin/media/uploadvideo" ;
348375 String responseContent = execute (new SimplePostRequestExecutor (), url , video .toJson ());
349376 return WxMpMassUploadResult .fromJson (responseContent );
350377 }
351378
379+ @ Override
352380 public WxMpMassSendResult massGroupMessageSend (WxMpMassGroupMessage message ) throws WxErrorException {
353381 String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall" ;
354382 String responseContent = execute (new SimplePostRequestExecutor (), url , message .toJson ());
355383 return WxMpMassSendResult .fromJson (responseContent );
356384 }
357385
386+ @ Override
358387 public WxMpMassSendResult massOpenIdsMessageSend (WxMpMassOpenIdsMessage message ) throws WxErrorException {
359388 String url = "https://api.weixin.qq.com/cgi-bin/message/mass/send" ;
360389 String responseContent = execute (new SimplePostRequestExecutor (), url , message .toJson ());
361390 return WxMpMassSendResult .fromJson (responseContent );
362391 }
363392
393+ @ Override
364394 public WxMpGroup groupCreate (String name ) throws WxErrorException {
365395 String url = "https://api.weixin.qq.com/cgi-bin/groups/create" ;
366396 JsonObject json = new JsonObject ();
@@ -375,6 +405,7 @@ public WxMpGroup groupCreate(String name) throws WxErrorException {
375405 return WxMpGroup .fromJson (responseContent );
376406 }
377407
408+ @ Override
378409 public List <WxMpGroup > groupGet () throws WxErrorException {
379410 String url = "https://api.weixin.qq.com/cgi-bin/groups/get" ;
380411 String responseContent = execute (new SimpleGetRequestExecutor (), url , null );
@@ -388,6 +419,7 @@ public List<WxMpGroup> groupGet() throws WxErrorException {
388419 }.getType ());
389420 }
390421
422+ @ Override
391423 public long userGetGroup (String openid ) throws WxErrorException {
392424 String url = "https://api.weixin.qq.com/cgi-bin/groups/getid" ;
393425 JsonObject o = new JsonObject ();
@@ -397,11 +429,13 @@ public long userGetGroup(String openid) throws WxErrorException {
397429 return GsonHelper .getAsLong (tmpJsonElement .getAsJsonObject ().get ("groupid" ));
398430 }
399431
432+ @ Override
400433 public void groupUpdate (WxMpGroup group ) throws WxErrorException {
401434 String url = "https://api.weixin.qq.com/cgi-bin/groups/update" ;
402435 execute (new SimplePostRequestExecutor (), url , group .toJson ());
403436 }
404437
438+ @ Override
405439 public void userUpdateGroup (String openid , long to_groupid ) throws WxErrorException {
406440 String url = "https://api.weixin.qq.com/cgi-bin/groups/members/update" ;
407441 JsonObject json = new JsonObject ();
@@ -410,6 +444,7 @@ public void userUpdateGroup(String openid, long to_groupid) throws WxErrorExcept
410444 execute (new SimplePostRequestExecutor (), url , json .toString ());
411445 }
412446
447+ @ Override
413448 public void userUpdateRemark (String openid , String remark ) throws WxErrorException {
414449 String url = "https://api.weixin.qq.com/cgi-bin/user/info/updateremark" ;
415450 JsonObject json = new JsonObject ();
@@ -418,19 +453,22 @@ public void userUpdateRemark(String openid, String remark) throws WxErrorExcepti
418453 execute (new SimplePostRequestExecutor (), url , json .toString ());
419454 }
420455
456+ @ Override
421457 public WxMpUser userInfo (String openid , String lang ) throws WxErrorException {
422458 String url = "https://api.weixin.qq.com/cgi-bin/user/info" ;
423459 lang = lang == null ? "zh_CN" : lang ;
424460 String responseContent = execute (new SimpleGetRequestExecutor (), url , "openid=" + openid + "&lang=" + lang );
425461 return WxMpUser .fromJson (responseContent );
426462 }
427463
464+ @ Override
428465 public WxMpUserList userList (String next_openid ) throws WxErrorException {
429466 String url = "https://api.weixin.qq.com/cgi-bin/user/get" ;
430467 String responseContent = execute (new SimpleGetRequestExecutor (), url , next_openid == null ? null : "next_openid=" + next_openid );
431468 return WxMpUserList .fromJson (responseContent );
432469 }
433470
471+ @ Override
434472 public WxMpQrCodeTicket qrCodeCreateTmpTicket (int scene_id , Integer expire_seconds ) throws WxErrorException {
435473 String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create" ;
436474 JsonObject json = new JsonObject ();
@@ -447,6 +485,7 @@ public WxMpQrCodeTicket qrCodeCreateTmpTicket(int scene_id, Integer expire_secon
447485 return WxMpQrCodeTicket .fromJson (responseContent );
448486 }
449487
488+ @ Override
450489 public WxMpQrCodeTicket qrCodeCreateLastTicket (int scene_id ) throws WxErrorException {
451490 String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create" ;
452491 JsonObject json = new JsonObject ();
@@ -460,6 +499,7 @@ public WxMpQrCodeTicket qrCodeCreateLastTicket(int scene_id) throws WxErrorExcep
460499 return WxMpQrCodeTicket .fromJson (responseContent );
461500 }
462501
502+ @ Override
463503 public WxMpQrCodeTicket qrCodeCreateLastTicket (String scene_str ) throws WxErrorException {
464504 String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create" ;
465505 JsonObject json = new JsonObject ();
@@ -473,6 +513,7 @@ public WxMpQrCodeTicket qrCodeCreateLastTicket(String scene_str) throws WxErrorE
473513 return WxMpQrCodeTicket .fromJson (responseContent );
474514 }
475515
516+ @ Override
476517 public File qrCodePicture (WxMpQrCodeTicket ticket ) throws WxErrorException {
477518 String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode" ;
478519 return execute (new QrCodeRequestExecutor (), url , ticket );
@@ -490,6 +531,7 @@ public String qrCodePictureUrl(String ticket) throws WxErrorException {
490531 }
491532 }
492533
534+ @ Override
493535 public String shortUrl (String long_url ) throws WxErrorException {
494536 String url = "https://api.weixin.qq.com/cgi-bin/shorturl" ;
495537 JsonObject o = new JsonObject ();
@@ -500,6 +542,7 @@ public String shortUrl(String long_url) throws WxErrorException {
500542 return tmpJsonElement .getAsJsonObject ().get ("short_url" ).getAsString ();
501543 }
502544
545+ @ Override
503546 public String templateSend (WxMpTemplateMessage templateMessage ) throws WxErrorException {
504547 String url = "https://api.weixin.qq.com/cgi-bin/message/template/send" ;
505548 String responseContent = execute (new SimplePostRequestExecutor (), url , templateMessage .toJson ());
@@ -510,6 +553,7 @@ public String templateSend(WxMpTemplateMessage templateMessage) throws WxErrorEx
510553 throw new WxErrorException (WxError .fromJson (responseContent ));
511554 }
512555
556+ @ Override
513557 public WxMpSemanticQueryResult semanticQuery (WxMpSemanticQuery semanticQuery ) throws WxErrorException {
514558 String url = "https://api.weixin.qq.com/semantic/semproxy/search" ;
515559 String responseContent = execute (new SimplePostRequestExecutor (), url , semanticQuery .toJson ());
@@ -658,10 +702,12 @@ public List<WxMpUserCumulate> getUserCumulate(Date beginDate, Date endDate) thro
658702 }.getType ());
659703 }
660704
705+ @ Override
661706 public String get (String url , String queryParam ) throws WxErrorException {
662707 return execute (new SimpleGetRequestExecutor (), url , queryParam );
663708 }
664709
710+ @ Override
665711 public String post (String url , String postData ) throws WxErrorException {
666712 return execute (new SimplePostRequestExecutor (), url , postData );
667713 }
@@ -675,6 +721,7 @@ public String post(String url, String postData) throws WxErrorException {
675721 * @return
676722 * @throws WxErrorException
677723 */
724+ @ Override
678725 public <T , E > T execute (RequestExecutor <T , E > executor , String uri , E data ) throws WxErrorException {
679726 int retryTimes = 0 ;
680727 do {
@@ -740,6 +787,7 @@ protected CloseableHttpClient getHttpclient() {
740787 return httpClient ;
741788 }
742789
790+ @ Override
743791 public void setWxMpConfigStorage (WxMpConfigStorage wxConfigProvider ) {
744792 this .wxMpConfigStorage = wxConfigProvider ;
745793
@@ -791,6 +839,7 @@ public WxMpPrepayIdResult getPrepayId(String openId, String outTradeNo, double a
791839 return getPrepayId (packageParams );
792840 }
793841
842+ @ Override
794843 public WxMpPrepayIdResult getPrepayId (final Map <String , String > parameters ) {
795844 String nonce_str = System .currentTimeMillis () + "" ;
796845
0 commit comments