|  | @@ -142,7 +142,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | @Override |  |  | @Override | 
														
													
														
															
																|  |  | public String post(String uri, String postData,String tokenKeyName) throws WxErrorException { |  |  |  | 
														
													
														
															
																|  |  |  |  |  | public String post(String uri, JsonObject postData,String tokenKeyName) throws WxErrorException { | 
														
													
														
															
																|  |  | //"component_access_token" |  |  | //"component_access_token" | 
														
													
														
															
																|  |  | return postByCommonAccessToken(uri, postData, tokenKeyName); |  |  | return postByCommonAccessToken(uri, postData, tokenKeyName); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @@ -157,9 +157,10 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | String componentAccessToken = getComponentAccessToken(false); |  |  | String componentAccessToken = getComponentAccessToken(false); | 
														
													
														
															
																|  |  | return excuteRequet(uri, accessTokenKey, componentAccessToken, null, true, RequestMethod.GET); |  |  | return excuteRequet(uri, accessTokenKey, componentAccessToken, null, true, RequestMethod.GET); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | private String postByCommonAccessToken(String uri, String postData ,String accessTokenKey)  throws WxErrorException { |  |  |  | 
														
													
														
															
																|  |  |  |  |  | private String postByCommonAccessToken(String uri, JsonObject postData ,String accessTokenKey)  throws WxErrorException { | 
														
													
														
															
																|  |  | String componentAccessToken = getComponentAccessToken(false); |  |  | String componentAccessToken = getComponentAccessToken(false); | 
														
													
														
															
																|  |  | return excuteRequet(uri, accessTokenKey, componentAccessToken, postData, true, RequestMethod.POST); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | postData.addProperty(accessTokenKey,componentAccessToken); | 
														
													
														
															
																|  |  |  |  |  | return excuteRequet(uri, accessTokenKey, componentAccessToken, postData.toString(), true, RequestMethod.POST); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | @Override |  |  | @Override | 
														
													
												
													
														
															
																|  | @@ -197,8 +198,8 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | private String createPreAuthUrl(String redirectURI) throws WxErrorException { |  |  | private String createPreAuthUrl(String redirectURI) throws WxErrorException { | 
														
													
														
															
																|  |  | JsonObject jsonObject = new JsonObject(); |  |  | JsonObject jsonObject = new JsonObject(); | 
														
													
														
															
																|  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); |  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | 
														
													
														
															
																|  |  | String responseContent = post(API_CREATE_PREAUTHCODE_URL, jsonObject.toString(),"component_access_token"); |  |  |  | 
														
													
														
															
																|  |  | log.info(responseContent +"----------responseContent"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String responseContent = post(API_CREATE_PREAUTHCODE_URL, jsonObject,"component_access_token"); | 
														
													
														
															
																|  |  |  |  |  | //    log.info(responseContent +"----------responseContent"); | 
														
													
														
															
																|  |  | jsonObject = TtOpenGsonBuilder.create().fromJson(responseContent, JsonObject.class); |  |  | jsonObject = TtOpenGsonBuilder.create().fromJson(responseContent, JsonObject.class); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | StringBuilder preAuthUrl = new StringBuilder(String.format(COMPONENT_LOGIN_PAGE_URL, |  |  | StringBuilder preAuthUrl = new StringBuilder(String.format(COMPONENT_LOGIN_PAGE_URL, | 
														
													
												
													
														
															
																|  | @@ -250,7 +251,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | JsonObject jsonObject = new JsonObject(); |  |  | JsonObject jsonObject = new JsonObject(); | 
														
													
														
															
																|  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); |  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | 
														
													
														
															
																|  |  | jsonObject.addProperty("authorization_appid", authorizationCode); |  |  | jsonObject.addProperty("authorization_appid", authorizationCode); | 
														
													
														
															
																|  |  | String responseContent = post(RETRIEVE_AUTHORIZER_TOKEN_URL, jsonObject.toString(), "component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String responseContent = post(RETRIEVE_AUTHORIZER_TOKEN_URL, jsonObject, "component_access_token"); | 
														
													
														
															
																|  |  | TtOpenRetrieveCode retrieveCode = TtOpenGsonBuilder.create().fromJson(responseContent, TtOpenRetrieveCode.class); |  |  | TtOpenRetrieveCode retrieveCode = TtOpenGsonBuilder.create().fromJson(responseContent, TtOpenRetrieveCode.class); | 
														
													
														
															
																|  |  | if(retrieveCode == null){ |  |  | if(retrieveCode == null){ | 
														
													
														
															
																|  |  | return null; |  |  | return null; | 
														
													
												
													
														
															
																|  | @@ -275,7 +276,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); |  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | 
														
													
														
															
																|  |  | jsonObject.addProperty("offset", begin); |  |  | jsonObject.addProperty("offset", begin); | 
														
													
														
															
																|  |  | jsonObject.addProperty("count", len); |  |  | jsonObject.addProperty("count", len); | 
														
													
														
															
																|  |  | String responseContent = post(API_GET_AUTHORIZER_LIST, jsonObject.toString(),"component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String responseContent = post(API_GET_AUTHORIZER_LIST, jsonObject,"component_access_token"); | 
														
													
														
															
																|  |  | WxOpenAuthorizerListResult ret = WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerListResult.class); |  |  | WxOpenAuthorizerListResult ret = WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerListResult.class); | 
														
													
														
															
																|  |  | if (ret != null && ret.getList() != null) { |  |  | if (ret != null && ret.getList() != null) { | 
														
													
														
															
																|  |  | for (Map<String, String> data : ret.getList()) { |  |  | for (Map<String, String> data : ret.getList()) { | 
														
													
												
													
														
															
																|  | @@ -295,7 +296,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); |  |  | jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | 
														
													
														
															
																|  |  | jsonObject.addProperty("authorizer_appid", authorizerAppid); |  |  | jsonObject.addProperty("authorizer_appid", authorizerAppid); | 
														
													
														
															
																|  |  | jsonObject.addProperty("option_name", optionName); |  |  | jsonObject.addProperty("option_name", optionName); | 
														
													
														
															
																|  |  | String responseContent = post(API_GET_AUTHORIZER_OPTION_URL, jsonObject.toString(),"component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String responseContent = post(API_GET_AUTHORIZER_OPTION_URL, jsonObject,"component_access_token"); | 
														
													
														
															
																|  |  | return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerOptionResult.class); |  |  | return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerOptionResult.class); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
												
													
														
															
																|  | @@ -306,7 +307,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | jsonObject.addProperty("authorizer_appid", authorizerAppid); |  |  | jsonObject.addProperty("authorizer_appid", authorizerAppid); | 
														
													
														
															
																|  |  | jsonObject.addProperty("option_name", optionName); |  |  | jsonObject.addProperty("option_name", optionName); | 
														
													
														
															
																|  |  | jsonObject.addProperty("option_value", optionValue); |  |  | jsonObject.addProperty("option_value", optionValue); | 
														
													
														
															
																|  |  | post(API_SET_AUTHORIZER_OPTION_URL, jsonObject.toString(),"component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | post(API_SET_AUTHORIZER_OPTION_URL, jsonObject,"component_access_token"); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | @Override |  |  | @Override | 
														
													
												
													
														
															
																|  | @@ -401,14 +402,14 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | public void addToTemplate(long draftId) throws WxErrorException { |  |  | public void addToTemplate(long draftId) throws WxErrorException { | 
														
													
														
															
																|  |  | JsonObject param = new JsonObject(); |  |  | JsonObject param = new JsonObject(); | 
														
													
														
															
																|  |  | param.addProperty("draft_id", draftId); |  |  | param.addProperty("draft_id", draftId); | 
														
													
														
															
																|  |  | post(ADD_TO_TEMPLATE_URL, param.toString(), "access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | post(ADD_TO_TEMPLATE_URL, param, "access_token"); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | @Override |  |  | @Override | 
														
													
														
															
																|  |  | public void deleteTemplate(long templateId) throws WxErrorException { |  |  | public void deleteTemplate(long templateId) throws WxErrorException { | 
														
													
														
															
																|  |  | JsonObject param = new JsonObject(); |  |  | JsonObject param = new JsonObject(); | 
														
													
														
															
																|  |  | param.addProperty("template_id", templateId); |  |  | param.addProperty("template_id", templateId); | 
														
													
														
															
																|  |  | post(DELETE_TEMPLATE_URL, param.toString(), "access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | post(DELETE_TEMPLATE_URL, param, "access_token"); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | @Override |  |  | @Override | 
														
													
												
													
														
															
																|  | @@ -424,11 +425,13 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | private String excuteRequet(String uri,String tokenKey,String tokenValue,String postData,boolean isCompontAccessToken,RequestMethod method) throws WxErrorException { |  |  | private String excuteRequet(String uri,String tokenKey,String tokenValue,String postData,boolean isCompontAccessToken,RequestMethod method) throws WxErrorException { | 
														
													
														
															
																|  |  | String uriWithComponentAccessToken = uri + (uri.contains("?") ? "&" : "?") + tokenKey + "=" + tokenValue; |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | try { |  |  | try { | 
														
													
														
															
																|  |  | if (method == RequestMethod.POST) { |  |  | if (method == RequestMethod.POST) { | 
														
													
														
															
																|  |  |  |  |  | String uriWithComponentAccessToken = uri; | 
														
													
														
															
																|  |  | return getTtOpenService().post(uriWithComponentAccessToken, postData); |  |  | return getTtOpenService().post(uriWithComponentAccessToken, postData); | 
														
													
														
															
																|  |  | }else { |  |  | }else { | 
														
													
														
															
																|  |  |  |  |  | String uriWithComponentAccessToken = uri + (uri.contains("?") ? "&" : "?") + tokenKey + "=" + tokenValue; | 
														
													
														
															
																|  |  | return getTtOpenService().get(uriWithComponentAccessToken, null); |  |  | return getTtOpenService().get(uriWithComponentAccessToken, null); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | } catch (WxErrorException e) { |  |  | } catch (WxErrorException e) { | 
														
													
												
													
														
															
																|  | @@ -457,7 +460,8 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | if (isCompontAccessToken && this.getWxOpenConfigStorage().autoRefreshToken()) { |  |  | if (isCompontAccessToken && this.getWxOpenConfigStorage().autoRefreshToken()) { | 
														
													
														
															
																|  |  | if (method == RequestMethod.POST) { |  |  | if (method == RequestMethod.POST) { | 
														
													
														
															
																|  |  | return this.post(uri, postData, tokenKey); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | JsonObject object = TtOpenGsonBuilder.create().fromJson(postData, JsonObject.class); | 
														
													
														
															
																|  |  |  |  |  | return this.post(uri, object, tokenKey); | 
														
													
														
															
																|  |  | }else { |  |  | }else { | 
														
													
														
															
																|  |  | return this.get(uri, tokenKey); |  |  | return this.get(uri, tokenKey); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @@ -515,7 +519,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat); |  |  | jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat); | 
														
													
														
															
																|  |  | jsonObject.addProperty("legal_persona_name", legalPersonaName); |  |  | jsonObject.addProperty("legal_persona_name", legalPersonaName); | 
														
													
														
															
																|  |  | jsonObject.addProperty("component_phone", componentPhone); |  |  | jsonObject.addProperty("component_phone", componentPhone); | 
														
													
														
															
																|  |  | String response = post(FAST_REGISTER_WEAPP_URL, jsonObject.toString(), "component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String response = post(FAST_REGISTER_WEAPP_URL, jsonObject, "component_access_token"); | 
														
													
														
															
																|  |  | return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); |  |  | return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
												
													
														
															
																|  | @@ -525,7 +529,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | 
														
													
														
															
																|  |  | jsonObject.addProperty("name", name); |  |  | jsonObject.addProperty("name", name); | 
														
													
														
															
																|  |  | jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat); |  |  | jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat); | 
														
													
														
															
																|  |  | jsonObject.addProperty("legal_persona_name", legalPersonaName); |  |  | jsonObject.addProperty("legal_persona_name", legalPersonaName); | 
														
													
														
															
																|  |  | String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject.toString(), "component_access_token"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject, "component_access_token"); | 
														
													
														
															
																|  |  | return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); |  |  | return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | } |  |  | } |