From bb9768a51706e3d174ee1bc1802b3791053d487e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=90=AF=E5=8B=8B?= Date: Sun, 14 Oct 2018 15:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9E=E7=8E=B0=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=89=88=E6=9C=AC=E5=BA=93=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9B=E5=A2=9E=E5=8A=A0WxOpenResult=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/open/api/WxOpenMaService.java | 31 +++++++--- .../open/api/impl/WxOpenMaServiceImpl.java | 58 ++++++++++++++----- .../result/WxOpenMaCategoryListResult.java | 6 +- .../bean/result/WxOpenMaDomainResult.java | 8 +-- .../bean/result/WxOpenMaPageListResult.java | 6 +- .../bean/result/WxOpenMaQueryAuditResult.java | 27 +++++++++ .../result/WxOpenMaSubmitAuditResult.java | 7 +-- .../bean/result/WxOpenMaTesterListResult.java | 6 +- .../weixin/open/bean/result/WxOpenResult.java | 33 +++++++++++ 9 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java index 72edaf45..7d688d31 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java @@ -219,7 +219,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String bindTester(String wechatid) throws WxErrorException; + WxOpenResult bindTester(String wechatid) throws WxErrorException; /** * 解除绑定小程序体验者 @@ -228,7 +228,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String unbindTester(String wechatid) throws WxErrorException; + WxOpenResult unbindTester(String wechatid) throws WxErrorException; /** * 获得体验者列表 @@ -248,7 +248,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException; + WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException; /** * 获取体验小程序的体验二维码 @@ -294,7 +294,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String getAuditStatus(Long auditid) throws WxErrorException; + WxOpenMaQueryAuditResult getAuditStatus(Long auditid) throws WxErrorException; /** * 查询最新一次提交的审核状态(仅供第三方代小程序调用) @@ -302,7 +302,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String getLatestAuditStatus() throws WxErrorException; + WxOpenMaQueryAuditResult getLatestAuditStatus() throws WxErrorException; /** * 发布已通过审核的小程序(仅供第三方代小程序调用) @@ -310,7 +310,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String releaesAudited() throws WxErrorException; + WxOpenResult releaesAudited() throws WxErrorException; /** * 11. 小程序版本回退(仅供第三方代小程序调用) @@ -318,7 +318,7 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String revertCodeReleaes() throws WxErrorException; + WxOpenResult revertCodeReleaes() throws WxErrorException; /** * 15. 小程序审核撤回 @@ -329,6 +329,21 @@ public interface WxOpenMaService extends WxMaService { * @return * @throws WxErrorException */ - String undoCodeAudit() throws WxErrorException; + WxOpenResult undoCodeAudit() throws WxErrorException; + + /** + * 查询当前设置的最低基础库版本及各版本用户占比 (仅供第三方代小程序调用) + * @return + * @throws WxErrorException + */ + String getSupportVersion() throws WxErrorException; + + /** + * 设置最低基础库版本(仅供第三方代小程序调用) + * @param version + * @return + * @throws WxErrorException + */ + String setSupportVersion(String version) throws WxErrorException; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java index cf8ed5f0..623338d0 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java @@ -146,11 +146,11 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String bindTester(String wechatid) throws WxErrorException { + public WxOpenResult bindTester(String wechatid) throws WxErrorException { JsonObject paramJson = new JsonObject(); paramJson.addProperty("wechatid", wechatid); String response = post(API_BIND_TESTER, GSON.toJson(paramJson)); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } /** @@ -161,11 +161,11 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String unbindTester(String wechatid) throws WxErrorException { + public WxOpenResult unbindTester(String wechatid) throws WxErrorException { JsonObject paramJson = new JsonObject(); paramJson.addProperty("wechatid", wechatid); String response = post(API_UNBIND_TESTER, GSON.toJson(paramJson)); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } /** @@ -193,7 +193,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException { + public WxOpenResult codeCommit(Long templateId, String userVersion, String userDesc, WxMaOpenCommitExtInfo extInfo) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("template_id", templateId); params.addProperty("user_version", userVersion); @@ -201,7 +201,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ //注意:ext_json必须是字符串类型 params.addProperty("ext_json", GSON.toJson(extInfo)); String response = post(API_CODE_COMMIT, GSON.toJson(params)); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } /** @@ -265,11 +265,11 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String getAuditStatus(Long auditid) throws WxErrorException { + public WxOpenMaQueryAuditResult getAuditStatus(Long auditid) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("auditid", auditid); String response = post(API_GET_AUDIT_STATUS, GSON.toJson(params)); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenMaQueryAuditResult.class); } /** @@ -279,9 +279,9 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String getLatestAuditStatus() throws WxErrorException { + public WxOpenMaQueryAuditResult getLatestAuditStatus() throws WxErrorException { String response = get(API_GET_LATEST_AUDIT_STATUS, null); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenMaQueryAuditResult.class); } /** @@ -294,10 +294,10 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String releaesAudited() throws WxErrorException { + public WxOpenResult releaesAudited() throws WxErrorException { JsonObject params = new JsonObject(); String response = post(API_RELEASE, GSON.toJson(params)); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } /** @@ -307,9 +307,9 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String revertCodeReleaes() throws WxErrorException { + public WxOpenResult revertCodeReleaes() throws WxErrorException { String response = get(API_REVERT_CODE_RELEASE, null); - return response; + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); } /** @@ -322,8 +322,36 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ * @throws WxErrorException */ @Override - public String undoCodeAudit() throws WxErrorException { + public WxOpenResult undoCodeAudit() throws WxErrorException { String response = get(API_UNDO_CODE_AUDIT, null); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * 查询当前设置的最低基础库版本及各版本用户占比 (仅供第三方代小程序调用) + * + * @return + * @throws WxErrorException + */ + @Override + public String getSupportVersion() throws WxErrorException { + JsonObject params = new JsonObject(); + String response = post(API_GET_WEAPP_SUPPORT_VERSION, GSON.toJson(params)); + return response; + } + + /** + * 设置最低基础库版本(仅供第三方代小程序调用) + * + * @param version + * @return + * @throws WxErrorException + */ + @Override + public String setSupportVersion(String version) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("version", version); + String response = post(API_SET_WEAPP_SUPPORT_VERSION, GSON.toJson(params)); return response; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java index af113f16..087e0dd4 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java @@ -6,7 +6,6 @@ import me.chanjar.weixin.open.bean.ma.WxOpenMaCategory; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import java.io.Serializable; import java.util.List; /** @@ -16,10 +15,7 @@ import java.util.List; * @date 2018/9/12 */ @Data -public class WxOpenMaCategoryListResult implements Serializable { - - private String errcode; - private String errmsg; +public class WxOpenMaCategoryListResult extends WxOpenResult { @SerializedName("category_list") List categoryList; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java index 79775e4b..4a9f11ad 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java @@ -3,7 +3,6 @@ package me.chanjar.weixin.open.bean.result; import com.google.gson.annotations.SerializedName; import lombok.Data; -import java.io.Serializable; import java.util.List; /** @@ -13,10 +12,7 @@ import java.util.List; * @date 2018/9/12 */ @Data -public class WxOpenMaDomainResult implements Serializable { - - private String errcode; - private String errmsg; +public class WxOpenMaDomainResult extends WxOpenResult { @SerializedName("requestdomain") List requestdomainList; @@ -29,5 +25,5 @@ public class WxOpenMaDomainResult implements Serializable { @SerializedName("downloaddomain") List downloaddomainList; - + } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java index b4c34fb2..35441b52 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java @@ -5,7 +5,6 @@ import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import java.io.Serializable; import java.util.List; /** @@ -15,10 +14,7 @@ import java.util.List; * @date 2018/9/12 */ @Data -public class WxOpenMaPageListResult implements Serializable { - - private String errcode; - private String errmsg; +public class WxOpenMaPageListResult extends WxOpenResult { @SerializedName("page_list") List pageList; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java new file mode 100644 index 00000000..e86d72e8 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * @author yqx + * @date 2018/10/3 + */ +@Data +public class WxOpenMaQueryAuditResult extends WxOpenResult { + /** + * 审核编号 + */ + @SerializedName("auditid") + Long auditId; + + /** + * 审核状态:2-审核中,0-审核通过,1-审核失败 + */ + Integer status; + + /** + * 审核失败原因 + */ + String reason; +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java index 77f150c2..abf27417 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaSubmitAuditResult.java @@ -3,8 +3,6 @@ package me.chanjar.weixin.open.bean.result; import com.google.gson.annotations.SerializedName; import lombok.Data; -import java.io.Serializable; - /** * 微信开放平台小程序发布代码审核结果 * @@ -12,10 +10,7 @@ import java.io.Serializable; * @date 2018/9/12 */ @Data -public class WxOpenMaSubmitAuditResult implements Serializable { - - private String errcode; - private String errmsg; +public class WxOpenMaSubmitAuditResult extends WxOpenResult { /** * 审核编号 diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java index 91c4af2a..aa2fedc5 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaTesterListResult.java @@ -6,7 +6,6 @@ import me.chanjar.weixin.open.bean.ma.WxOpenMaMember; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import java.io.Serializable; import java.util.List; /** @@ -16,10 +15,7 @@ import java.util.List; * @date 2018/9/12 */ @Data -public class WxOpenMaTesterListResult implements Serializable { - - private String errcode; - private String errmsg; +public class WxOpenMaTesterListResult extends WxOpenResult { @SerializedName("members") List membersList; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java new file mode 100644 index 00000000..d12a68f7 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenResult.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.open.bean.result; + +import lombok.Data; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serializable; + +/** + * 基础的微信开放平台请求结果 + * + * @author yqx + * @date 2018/10/1 + */ +@Data +public class WxOpenResult implements Serializable { + protected String errcode; + protected String errmsg; + + /** + * 请求是否成功 + * + * @return + */ + public boolean isSuccess() { + return StringUtils.equalsIgnoreCase(errcode, "0"); + } + + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } +}