Skip to content

Commit ac67482

Browse files
hanwei59binarywang
authored andcommitted
#1123 增加设置小程序“扫普通链接二维码打开小程序”能力的五个接口
1 parent 2e14b54 commit ac67482

File tree

5 files changed

+225
-3
lines changed

5 files changed

+225
-3
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java

+50-3
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,33 @@ public interface WxOpenMaService extends WxMaService {
167167

168168
/**
169169
* 14.设置小程序“扫普通链接二维码打开小程序”能力
170-
* <p>
171-
* TODO 暂时不实现
172-
* </p>
170+
*
171+
* https://mp.weixin.qq.com/debug/wxadoc/introduction/qrcode.html
172+
*/
173+
/**
174+
* 14.1 增加或修改二维码规则
175+
*/
176+
String API_QRCODE_JUMP_ADD = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd";
177+
178+
/**
179+
* 14.2 获取已设置的二维码规则
173180
*/
181+
String API_QRCODE_JUMP_GET = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpget";
182+
183+
/**
184+
* 14.3 获取校验文件名称及内容
185+
*/
186+
String API_QRCODE_JUMP_DOWNLOAD = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdownload";
187+
188+
/**
189+
* 14.4 删除已设置的二维码规则
190+
*/
191+
String API_QRCODE_JUMP_DELETE = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdelete";
192+
193+
/**
194+
* 14.5 发布已设置的二维码规则
195+
*/
196+
String API_QRCODE_JUMP_PUBLISH = "https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumppublish";
174197

175198
/**
176199
* 15.小程序审核撤回
@@ -421,4 +444,28 @@ public interface WxOpenMaService extends WxMaService {
421444
*/
422445
Boolean speedAudit(Long auditid) throws WxErrorException;
423446

447+
/**
448+
* (1)增加或修改二维码规则
449+
*/
450+
WxOpenResult addQrcodeJump(WxQrcodeJumpRule wxQrcodeJumpRule) throws WxErrorException;
451+
452+
/**
453+
* (2)获取已设置的二维码规则
454+
*/
455+
WxGetQrcodeJumpResult getQrcodeJump() throws WxErrorException;
456+
457+
/**
458+
* (3)获取校验文件名称及内容
459+
*/
460+
WxDownlooadQrcodeJumpResult downloadQrcodeJump() throws WxErrorException;
461+
462+
/**
463+
* (4)删除已设置的二维码规则
464+
*/
465+
WxOpenResult deleteQrcodeJump(String prefix) throws WxErrorException;
466+
467+
/**
468+
* (5)发布已设置的二维码规则
469+
*/
470+
WxOpenResult publishQrcodeJump(String prefix) throws WxErrorException;
424471
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java

+62
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,68 @@ public Boolean speedAudit(Long auditid) throws WxErrorException {
548548
}
549549

550550

551+
/**
552+
* (1)增加或修改二维码规则
553+
* @param wxQrcodeJumpRule
554+
* @return
555+
* @throws WxErrorException
556+
*/
557+
@Override
558+
public WxOpenResult addQrcodeJump(WxQrcodeJumpRule wxQrcodeJumpRule) throws WxErrorException {
559+
String response = post(API_QRCODE_JUMP_ADD, GSON.toJson(wxQrcodeJumpRule));
560+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
561+
}
562+
563+
/**
564+
* (2)获取已设置的二维码规则
565+
* @return
566+
* @throws WxErrorException
567+
*/
568+
@Override
569+
public WxGetQrcodeJumpResult getQrcodeJump() throws WxErrorException {
570+
String response = post(API_QRCODE_JUMP_GET, "{}");
571+
return WxMaGsonBuilder.create().fromJson(response, WxGetQrcodeJumpResult.class);
572+
}
573+
574+
/**
575+
* (3)获取校验文件名称及内容
576+
* @return
577+
* @throws WxErrorException
578+
*/
579+
@Override
580+
public WxDownlooadQrcodeJumpResult downloadQrcodeJump() throws WxErrorException {
581+
String response = post(API_QRCODE_JUMP_DOWNLOAD, "{}");
582+
return WxMaGsonBuilder.create().fromJson(response, WxDownlooadQrcodeJumpResult.class);
583+
}
584+
585+
/**
586+
* (4)删除已设置的二维码规则
587+
* @param prefix
588+
* @return
589+
* @throws WxErrorException
590+
*/
591+
@Override
592+
public WxOpenResult deleteQrcodeJump(String prefix) throws WxErrorException {
593+
JsonObject params = new JsonObject();
594+
params.addProperty("prefix", prefix);
595+
String response = post(API_QRCODE_JUMP_DELETE, GSON.toJson(params));
596+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
597+
}
598+
599+
/**
600+
* (5)发布已设置的二维码规则
601+
* @param prefix
602+
* @return
603+
* @throws WxErrorException
604+
*/
605+
@Override
606+
public WxOpenResult publishQrcodeJump(String prefix) throws WxErrorException {
607+
JsonObject params = new JsonObject();
608+
params.addProperty("prefix", prefix);
609+
String response = post(API_QRCODE_JUMP_PUBLISH, GSON.toJson(params));
610+
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
611+
}
612+
551613
/**
552614
* 将字符串对象转化为GsonArray对象
553615
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
7+
8+
/**
9+
* 二维码规则的校验文件名称及内容
10+
*
11+
* @author <a href="https://github.com/hanwei59">hanwei59</a>
12+
*/
13+
@Data
14+
@EqualsAndHashCode(callSuper = true)
15+
public class WxDownlooadQrcodeJumpResult extends WxOpenResult {
16+
17+
//文件名称
18+
@SerializedName("file_name")
19+
private String fileName;
20+
21+
//文件内容
22+
@SerializedName("file_content")
23+
private String fileContent;
24+
25+
@Override
26+
public String toString() {
27+
return WxOpenGsonBuilder.create().toJson(this);
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
7+
8+
import java.util.List;
9+
10+
/**
11+
* 已设置的二维码规则信息
12+
*
13+
* @author <a href="https://github.com/hanwei59">hanwei59</a>
14+
*/
15+
@Data
16+
@EqualsAndHashCode(callSuper = true)
17+
public class WxGetQrcodeJumpResult extends WxOpenResult {
18+
19+
//二维码规则详情,数组形式
20+
@SerializedName("rule_list")
21+
List<WxQrcodeJumpRule> ruleList;
22+
23+
//是否已经打开二维码跳转链接设置
24+
@SerializedName("qrcodejump_open")
25+
private String qrcodejumpOpen;
26+
27+
//本月还可发布的次数
28+
@SerializedName("qrcodejump_pub_quota")
29+
private Integer qrcodejumpPubQuota;
30+
31+
//二维码规则数量
32+
@SerializedName("list_size")
33+
private Integer listSize;
34+
35+
@Override
36+
public String toString() {
37+
return WxOpenGsonBuilder.create().toJson(this);
38+
}
39+
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 二维码规则
10+
*
11+
* <a href="https://github.com/hanwei59">hanwei59</a>
12+
*/
13+
@Data
14+
public class WxQrcodeJumpRule {
15+
16+
//二维码规则
17+
@SerializedName("prefix")
18+
private String prefix;
19+
20+
//是否独占符合二维码前缀匹配规则的所有子规则:1为不占用,2为占用
21+
//详细说明:https://mp.weixin.qq.com/debug/wxadoc/introduction/qrcode.html#前缀占用规则
22+
@SerializedName("permit_sub_rule")
23+
private String permitSubRule;
24+
25+
//小程序功能页面
26+
@SerializedName("path")
27+
private String path;
28+
29+
//测试范围:
30+
//1为开发版(配置只对开发者生效)
31+
//2为体验版(配置对管理员、体验者生效)
32+
//3为线上版本(配置对管理员、开发者和体验者生效)
33+
@SerializedName("open_version")
34+
private String openVersion;
35+
36+
//测试链接(选填)可填写不多于5个用于测试的二维码完整链接,此链接必须符合已填写的二维码规则。
37+
@SerializedName("debug_url")
38+
private List<String> debugUrl;
39+
40+
//编辑标志位,0表示新增二维码规则,1表示修改已有二维码规则
41+
@SerializedName("is_edit")
42+
private String isEdit;
43+
}

0 commit comments

Comments
 (0)