55import me .chanjar .weixin .common .error .WxErrorException ;
66import me .chanjar .weixin .cp .bean .WxCpTpCustomizedAppDetail ;
77import me .chanjar .weixin .cp .bean .WxCpTpTemplateList ;
8+ import me .chanjar .weixin .cp .config .WxCpTpConfigStorage ;
89import me .chanjar .weixin .cp .tp .service .WxCpTpCustomizedService ;
910import me .chanjar .weixin .cp .tp .service .WxCpTpService ;
1011
@@ -24,23 +25,40 @@ public class WxCpTpCustomizedServiceImpl implements WxCpTpCustomizedService {
2425
2526 @ Override
2627 public WxCpTpTemplateList getTemplateList () throws WxErrorException {
27- String url = this .mainService .getWxCpTpConfigStorage ().getApiUrl (GET_TEMPLATE_LIST );
28- String responseText = this .mainService .get (url + "?provider_access_token="
29- + this .mainService .getWxCpProviderToken (), null , true );
28+ String responseText = this .mainService .get (getWxCpTpConfigStorage ().getApiUrl (GET_TEMPLATE_LIST )
29+ + getProviderAccessToken (), null , true );
3030 return WxCpTpTemplateList .fromJson (responseText );
3131 }
3232
3333 @ Override
3434 public WxCpTpCustomizedAppDetail getCustomizedAppDetail (String authCorpId , Integer agentId ) throws WxErrorException {
35- String url = this .mainService .getWxCpTpConfigStorage ().getApiUrl (GET_CUSTOMIZED_APP_DETAIL );
3635 JsonObject jsonObject = new JsonObject ();
3736 jsonObject .addProperty ("auth_corpid" , authCorpId );
3837 if (agentId != null ) {
3938 jsonObject .addProperty ("agentid" , agentId );
4039 }
41- String responseText = this .mainService .post (url + "?provider_access_token="
42- + this . mainService . getWxCpProviderToken (), jsonObject .toString (), true );
40+ String responseText = this .mainService .post (getWxCpTpConfigStorage (). getApiUrl ( GET_CUSTOMIZED_APP_DETAIL )
41+ + getProviderAccessToken (), jsonObject .toString (), true );
4342 return WxCpTpCustomizedAppDetail .fromJson (responseText );
4443 }
4544
45+ /**
46+ * 获取provider_access_token参数
47+ *
48+ * @return provider_access_token参数
49+ * @throws WxErrorException 微信错误异常
50+ */
51+ private String getProviderAccessToken () throws WxErrorException {
52+ return "?provider_access_token=" + mainService .getWxCpProviderToken ();
53+ }
54+
55+ /**
56+ * 获取tp参数配置
57+ *
58+ * @return config
59+ */
60+ private WxCpTpConfigStorage getWxCpTpConfigStorage () {
61+ return mainService .getWxCpTpConfigStorage ();
62+ }
63+
4664}
0 commit comments