| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.toutiao.api; | package com.iformall.service.toutiao.api; | ||||
| import com.iformall.service.toutiao.api.bean.TtOpenResult; | |||||
| import com.iformall.service.toutiao.miniapp.TtMaService; | import com.iformall.service.toutiao.miniapp.TtMaService; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | ||||
| @@ -344,7 +345,7 @@ public interface TtOpenMaService extends TtMaService { | |||||
| * @param userDesc 用户定义版本描述 | * @param userDesc 用户定义版本描述 | ||||
| * @param extInfo 第三方自定义的配置 | * @param extInfo 第三方自定义的配置 | ||||
| */ | */ | ||||
| WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException; | |||||
| TtOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException; | |||||
| /** | /** | ||||
| * 获取体验小程序的体验二维码 | * 获取体验小程序的体验二维码 | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.service.toutiao.api.bean; | |||||
| import lombok.Data; | |||||
| import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenResult; | |||||
| import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import java.io.Serializable; | |||||
| /** | |||||
| * 基础的微信开放平台请求结果. | |||||
| * | |||||
| * @author yqx | |||||
| * @date 2018/10/1 | |||||
| */ | |||||
| @Data | |||||
| public class TtOpenResult implements Serializable { | |||||
| private static final long serialVersionUID = -3419554656499566410L; | |||||
| protected String errno; | |||||
| protected String message; | |||||
| /** | |||||
| * 请求是否成功. | |||||
| */ | |||||
| public boolean isSuccess() { | |||||
| return StringUtils.equalsIgnoreCase(errno, "0"); | |||||
| } | |||||
| public static WxOpenResult fromJson(String json) { | |||||
| return TtOpenGsonBuilder.create().fromJson(json, WxOpenResult.class); | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return TtOpenGsonBuilder.create().toJson(this); | |||||
| } | |||||
| } | |||||
| @@ -7,6 +7,8 @@ import com.google.gson.JsonArray; | |||||
| import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
| import com.iformall.service.toutiao.api.TtOpenComponentService; | import com.iformall.service.toutiao.api.TtOpenComponentService; | ||||
| import com.iformall.service.toutiao.api.TtOpenMaService; | import com.iformall.service.toutiao.api.TtOpenMaService; | ||||
| import com.iformall.service.toutiao.api.bean.TtOpenGsonBuilder; | |||||
| import com.iformall.service.toutiao.api.bean.TtOpenResult; | |||||
| import com.iformall.service.toutiao.miniapp.impl.TtMaServiceImpl; | import com.iformall.service.toutiao.miniapp.impl.TtMaServiceImpl; | ||||
| import lombok.extern.java.Log; | import lombok.extern.java.Log; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -289,7 +291,7 @@ public class TtOpenMaServiceImpl extends TtMaServiceImpl implements TtOpenMaServ | |||||
| * @throws WxErrorException | * @throws WxErrorException | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException { | |||||
| public TtOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException { | |||||
| String uri = API_CODE_COMMIT + "?component_appid=" + ttOpenComponentService.getWxOpenConfigStorage().getComponentAppId(); | String uri = API_CODE_COMMIT + "?component_appid=" + ttOpenComponentService.getWxOpenConfigStorage().getComponentAppId(); | ||||
| JsonObject params = new JsonObject(); | JsonObject params = new JsonObject(); | ||||
| @@ -302,7 +304,7 @@ public class TtOpenMaServiceImpl extends TtMaServiceImpl implements TtOpenMaServ | |||||
| String response = ttOpenComponentService.postByAppAccessToken(appId,uri,GSON.toJson(params),"authorizer_access_token"); | String response = ttOpenComponentService.postByAppAccessToken(appId,uri,GSON.toJson(params),"authorizer_access_token"); | ||||
| log.info("response--------------"+response); | log.info("response--------------"+response); | ||||
| return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); | |||||
| return TtOpenGsonBuilder.create().fromJson(response, TtOpenResult.class); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -22,6 +22,7 @@ import com.iformall.enums.*; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.toutiao.FmTtOpenService; | import com.iformall.service.toutiao.FmTtOpenService; | ||||
| import com.iformall.service.toutiao.api.TtOpenMaService; | import com.iformall.service.toutiao.api.TtOpenMaService; | ||||
| import com.iformall.service.toutiao.api.bean.TtOpenResult; | |||||
| import com.iformall.service.toutiao.miniapp.TtMaService; | import com.iformall.service.toutiao.miniapp.TtMaService; | ||||
| import com.iformall.service.wechat.FmOpenService; | import com.iformall.service.wechat.FmOpenService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| @@ -623,7 +624,7 @@ public class WxWeappInfoController extends BaseController { | |||||
| } | } | ||||
| logger.info("NEW: " + extInfo.toString()); | logger.info("NEW: " + extInfo.toString()); | ||||
| TtOpenMaService openMaService = openService.getTtOpenComponentService().getTtMaServiceByAppid(appinfo.getAppId()); | TtOpenMaService openMaService = openService.getTtOpenComponentService().getTtMaServiceByAppid(appinfo.getAppId()); | ||||
| WxOpenResult openRet = openMaService.codeCommit(templateId, userVersion, userDesc, extInfo); | |||||
| TtOpenResult openRet = openMaService.codeCommit(templateId, userVersion, userDesc, extInfo); | |||||
| logger.info(openRet.toString()); | logger.info(openRet.toString()); | ||||
| if (openRet.isSuccess()) { | if (openRet.isSuccess()) { | ||||
| codeCommitStatus = true; | codeCommitStatus = true; | ||||