From ac67482a95e1d81366742ddf1d8e796febca6266 Mon Sep 17 00:00:00 2001 From: hanwei59 Date: Thu, 14 Nov 2019 09:46:54 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20#1123=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=B0=8F=E7=A8=8B=E5=BA=8F=E2=80=9C=E6=89=AB?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E9=93=BE=E6=8E=A5=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=B0=8F=E7=A8=8B=E5=BA=8F=E2=80=9D=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E7=9A=84=E4=BA=94=E4=B8=AA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/open/api/WxOpenMaService.java | 53 +++++++++++++++- .../open/api/impl/WxOpenMaServiceImpl.java | 62 +++++++++++++++++++ .../result/WxDownlooadQrcodeJumpResult.java | 30 +++++++++ .../bean/result/WxGetQrcodeJumpResult.java | 40 ++++++++++++ .../open/bean/result/WxQrcodeJumpRule.java | 43 +++++++++++++ 5 files changed, 225 insertions(+), 3 deletions(-) create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxDownlooadQrcodeJumpResult.java create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxGetQrcodeJumpResult.java create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxQrcodeJumpRule.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 78177a3c..2b6e2d13 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 @@ -167,10 +167,33 @@ public interface WxOpenMaService extends WxMaService { /** * 14.设置小程序“扫普通链接二维码打开小程序”能力 - *

- * TODO 暂时不实现 - *

+ * + * https://mp.weixin.qq.com/debug/wxadoc/introduction/qrcode.html + */ + /** + * 14.1 增加或修改二维码规则 + */ + String API_QRCODE_JUMP_ADD = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd"; + + /** + * 14.2 获取已设置的二维码规则 */ + String API_QRCODE_JUMP_GET = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpget"; + + /** + * 14.3 获取校验文件名称及内容 + */ + String API_QRCODE_JUMP_DOWNLOAD = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdownload"; + + /** + * 14.4 删除已设置的二维码规则 + */ + String API_QRCODE_JUMP_DELETE = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdelete"; + + /** + * 14.5 发布已设置的二维码规则 + */ + String API_QRCODE_JUMP_PUBLISH = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumppublish"; /** * 15.小程序审核撤回 @@ -421,4 +444,28 @@ public interface WxOpenMaService extends WxMaService { */ Boolean speedAudit(Long auditid) throws WxErrorException; + /** + * (1)增加或修改二维码规则 + */ + WxOpenResult addQrcodeJump(WxQrcodeJumpRule wxQrcodeJumpRule) throws WxErrorException; + + /** + * (2)获取已设置的二维码规则 + */ + WxGetQrcodeJumpResult getQrcodeJump() throws WxErrorException; + + /** + * (3)获取校验文件名称及内容 + */ + WxDownlooadQrcodeJumpResult downloadQrcodeJump() throws WxErrorException; + + /** + * (4)删除已设置的二维码规则 + */ + WxOpenResult deleteQrcodeJump(String prefix) throws WxErrorException; + + /** + * (5)发布已设置的二维码规则 + */ + WxOpenResult publishQrcodeJump(String prefix) 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 230968d5..1d30a57f 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 @@ -548,6 +548,68 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ } + /** + * (1)增加或修改二维码规则 + * @param wxQrcodeJumpRule + * @return + * @throws WxErrorException + */ + @Override + public WxOpenResult addQrcodeJump(WxQrcodeJumpRule wxQrcodeJumpRule) throws WxErrorException { + String response = post(API_QRCODE_JUMP_ADD, GSON.toJson(wxQrcodeJumpRule)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * (2)获取已设置的二维码规则 + * @return + * @throws WxErrorException + */ + @Override + public WxGetQrcodeJumpResult getQrcodeJump() throws WxErrorException { + String response = post(API_QRCODE_JUMP_GET, "{}"); + return WxMaGsonBuilder.create().fromJson(response, WxGetQrcodeJumpResult.class); + } + + /** + * (3)获取校验文件名称及内容 + * @return + * @throws WxErrorException + */ + @Override + public WxDownlooadQrcodeJumpResult downloadQrcodeJump() throws WxErrorException { + String response = post(API_QRCODE_JUMP_DOWNLOAD, "{}"); + return WxMaGsonBuilder.create().fromJson(response, WxDownlooadQrcodeJumpResult.class); + } + + /** + * (4)删除已设置的二维码规则 + * @param prefix + * @return + * @throws WxErrorException + */ + @Override + public WxOpenResult deleteQrcodeJump(String prefix) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("prefix", prefix); + String response = post(API_QRCODE_JUMP_DELETE, GSON.toJson(params)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + + /** + * (5)发布已设置的二维码规则 + * @param prefix + * @return + * @throws WxErrorException + */ + @Override + public WxOpenResult publishQrcodeJump(String prefix) throws WxErrorException { + JsonObject params = new JsonObject(); + params.addProperty("prefix", prefix); + String response = post(API_QRCODE_JUMP_PUBLISH, GSON.toJson(params)); + return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); + } + /** * 将字符串对象转化为GsonArray对象 * diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxDownlooadQrcodeJumpResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxDownlooadQrcodeJumpResult.java new file mode 100644 index 00000000..3bdc532b --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxDownlooadQrcodeJumpResult.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; + +/** + * 二维码规则的校验文件名称及内容 + * + * @author hanwei59 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxDownlooadQrcodeJumpResult extends WxOpenResult { + + //文件名称 + @SerializedName("file_name") + private String fileName; + + //文件内容 + @SerializedName("file_content") + private String fileContent; + + @Override + public String toString() { + return WxOpenGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxGetQrcodeJumpResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxGetQrcodeJumpResult.java new file mode 100644 index 00000000..f47e8be6 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxGetQrcodeJumpResult.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder; + +import java.util.List; + +/** + * 已设置的二维码规则信息 + * + * @author hanwei59 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxGetQrcodeJumpResult extends WxOpenResult { + + //二维码规则详情,数组形式 + @SerializedName("rule_list") + List ruleList; + + //是否已经打开二维码跳转链接设置 + @SerializedName("qrcodejump_open") + private String qrcodejumpOpen; + + //本月还可发布的次数 + @SerializedName("qrcodejump_pub_quota") + private Integer qrcodejumpPubQuota; + + //二维码规则数量 + @SerializedName("list_size") + private Integer listSize; + + @Override + public String toString() { + return WxOpenGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxQrcodeJumpRule.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxQrcodeJumpRule.java new file mode 100644 index 00000000..eb8a074b --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxQrcodeJumpRule.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.util.List; + +/** + * 二维码规则 + * + * hanwei59 + */ +@Data +public class WxQrcodeJumpRule { + + //二维码规则 + @SerializedName("prefix") + private String prefix; + + //是否独占符合二维码前缀匹配规则的所有子规则:1为不占用,2为占用 + //详细说明:https://mp.weixin.qq.com/debug/wxadoc/introduction/qrcode.html#前缀占用规则 + @SerializedName("permit_sub_rule") + private String permitSubRule; + + //小程序功能页面 + @SerializedName("path") + private String path; + + //测试范围: + //1为开发版(配置只对开发者生效) + //2为体验版(配置对管理员、体验者生效) + //3为线上版本(配置对管理员、开发者和体验者生效) + @SerializedName("open_version") + private String openVersion; + + //测试链接(选填)可填写不多于5个用于测试的二维码完整链接,此链接必须符合已填写的二维码规则。 + @SerializedName("debug_url") + private List debugUrl; + + //编辑标志位,0表示新增二维码规则,1表示修改已有二维码规则 + @SerializedName("is_edit") + private String isEdit; +}