Skip to content

Commit f83c55c

Browse files
authored
🆕 #2658 【开放平台】第三方平台小程序用户隐私保护指引模块增加申请隐私相关接口
1 parent dbf9622 commit f83c55c

File tree

7 files changed

+215
-9
lines changed

7 files changed

+215
-9
lines changed

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaWeDriveServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
1010
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
1111
import org.testng.annotations.Test;
12-
import sun.misc.BASE64Encoder;
1312

1413
import java.io.File;
1514
import java.io.FileInputStream;
1615
import java.io.InputStream;
1716
import java.util.ArrayList;
17+
import java.util.Base64;
1818
import java.util.List;
1919

2020
/**
@@ -140,7 +140,7 @@ public void test() throws Exception {
140140
byte[] buffer = new byte[(int)file.length()];
141141
inputFile.read(buffer);
142142
inputFile.close();
143-
String encodeBase64Content = new BASE64Encoder().encode(buffer);
143+
String encodeBase64Content = Base64.getEncoder().encodeToString(buffer);
144144
fileUploadRequest.setFileBase64Content(encodeBase64Content);
145145

146146
WxCpFileUpload fileUpload = cpService.getOaWeDriveService().fileUpload(fileUploadRequest);

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.AllArgsConstructor;
44
import lombok.Data;
5+
import lombok.NoArgsConstructor;
56

67
/**
78
* <pre>
@@ -12,6 +13,7 @@
1213
* @author Element
1314
*/
1415
@Data
16+
@NoArgsConstructor
1517
@AllArgsConstructor
1618
public class WxMaCodeLineColor {
1719
private String r = "0", g = "0", b = "0";

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package me.chanjar.weixin.open.api;
22

33
import me.chanjar.weixin.common.error.WxErrorException;
4-
import me.chanjar.weixin.open.bean.ma.privacy.GetPrivacySettingResult;
5-
import me.chanjar.weixin.open.bean.ma.privacy.SetPrivacySetting;
6-
import me.chanjar.weixin.open.bean.ma.privacy.UploadPrivacyFileResult;
4+
import me.chanjar.weixin.open.bean.ma.privacy.*;
75
import org.jetbrains.annotations.Nullable;
86

97
/**
10-
* 微信第三方平台 小程序用户隐私保护指引接口
8+
* 微信第三方平台 小程序用户隐私保护指引接口 / 申请隐私接口(从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。)
119
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html
10+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/apply_api/get_privacy_interface.html
1211
*
1312
* @author <a href="https://www.sacoc.cn">广州跨界</a>
1413
*/
@@ -29,6 +28,16 @@ public interface WxOpenMaPrivacyService {
2928
*/
3029
String OPEN_UPLOAD_PRIVACY_FILE = "https://api.weixin.qq.com/cgi-bin/component/uploadprivacyextfile";
3130

31+
/**
32+
* 4 获取接口列表 从2022年4月18日开始,部分小程序前端 api 需申请后
33+
*/
34+
String GET_PRIVATE_INTERFACE = "https://api.weixin.qq.com/wxa/security/get_privacy_interface";
35+
36+
/**
37+
* 5 申请接口 从2022年4月18日开始,部分小程序前端 api 需申请后
38+
*/
39+
String APPLY_PRIVATE_INTERFACE = "https://api.weixin.qq.com/wxa/security/apply_privacy_interface";
40+
3241

3342
/**
3443
* 查询小程序用户隐私保护指引
@@ -62,4 +71,27 @@ public interface WxOpenMaPrivacyService {
6271
* @throws WxErrorException 如果出错,抛出此异常
6372
*/
6473
UploadPrivacyFileResult uploadPrivacyFile(String content) throws WxErrorException;
74+
75+
76+
/**
77+
* 隐私接口-获取接口列表
78+
* 从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。
79+
* 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/apply_api/get_privacy_interface.html
80+
*
81+
* @return 获取结果
82+
* @throws WxErrorException 如果出错,抛出此异常
83+
*/
84+
GetPrivacyInterfaceResult getPrivacyInterface() throws WxErrorException;
85+
86+
87+
/**
88+
* 隐私接口-申请接口
89+
* 从2022年4月18日开始,部分小程序前端 api 需申请后,方可使用。该接口用于获取“需申请并审核通过”后才可使用的接口列表。
90+
* 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/apply_api/get_privacy_interface.html
91+
*
92+
* @param dto 请求参数
93+
* @return 获取结果
94+
* @throws WxErrorException 如果出错,抛出此异常
95+
*/
96+
ApplyPrivacyInterfaceResult applyPrivacyInterface(ApplyPrivacyInterface dto) throws WxErrorException;
6597
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import me.chanjar.weixin.common.error.WxError;
77
import me.chanjar.weixin.common.error.WxErrorException;
88
import me.chanjar.weixin.open.api.WxOpenMaPrivacyService;
9-
import me.chanjar.weixin.open.bean.ma.privacy.GetPrivacySettingResult;
10-
import me.chanjar.weixin.open.bean.ma.privacy.SetPrivacySetting;
11-
import me.chanjar.weixin.open.bean.ma.privacy.UploadPrivacyFileResult;
9+
import me.chanjar.weixin.open.bean.ma.privacy.*;
1210
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
1311
import org.jetbrains.annotations.Nullable;
1412

@@ -52,4 +50,16 @@ public UploadPrivacyFileResult uploadPrivacyFile(String content) throws WxErrorE
5250
// return WxOpenGsonBuilder.create().fromJson(json, UploadPrivacyFileResult.class);
5351
throw new WxErrorException(new WxError(5003, "暂未实现用户隐私指引内容上传"));
5452
}
53+
54+
@Override
55+
public GetPrivacyInterfaceResult getPrivacyInterface() throws WxErrorException {
56+
String json = wxMaService.get(GET_PRIVATE_INTERFACE, "");
57+
return WxOpenGsonBuilder.create().fromJson(json, GetPrivacyInterfaceResult.class);
58+
}
59+
60+
@Override
61+
public ApplyPrivacyInterfaceResult applyPrivacyInterface(ApplyPrivacyInterface dto) throws WxErrorException {
62+
String json = wxMaService.post(APPLY_PRIVATE_INTERFACE, dto);
63+
return WxOpenGsonBuilder.create().fromJson(json, ApplyPrivacyInterfaceResult.class);
64+
}
5565
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package me.chanjar.weixin.open.bean.ma.privacy;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
7+
import java.util.List;
8+
9+
/**
10+
* 申请隐私接口
11+
*
12+
* @author <a href="https://www.sacoc.cn">广州跨界</a>
13+
*/
14+
@Getter
15+
@Setter
16+
public class ApplyPrivacyInterface {
17+
18+
/**
19+
* 接口英文名称,如:wx.chooseAddress/wx.choosePoi/wx.getLocation/wx.onLocationChange/wx.chooseLocation
20+
*/
21+
@SerializedName("api_name")
22+
private String apiName;
23+
24+
/**
25+
* 申请说原因,不超过300个字符;需要以utf-8编码提交,否则会出现审核失败
26+
*/
27+
@SerializedName("content")
28+
private String content;
29+
30+
/**
31+
* (辅助网页)例如,上传官网网页链接用于辅助审核
32+
*/
33+
@SerializedName("url_list")
34+
private List<String> urlList;
35+
36+
/**
37+
* (辅助图片)填写图片的url ,最多10个
38+
*/
39+
@SerializedName("pic_list")
40+
private List<String> picList;
41+
42+
/**
43+
* (辅助视频)填写视频的链接 ,最多支持1个;视频格式只支持mp4格式
44+
*/
45+
@SerializedName("video_list")
46+
private List<String> videoList;
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.chanjar.weixin.open.bean.ma.privacy;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import me.chanjar.weixin.open.bean.result.WxOpenResult;
7+
8+
/**
9+
* 获取接口列表 响应
10+
*
11+
* @author <a href="https://www.sacoc.cn">广州跨界</a>
12+
*/
13+
@Getter
14+
@Setter
15+
public class ApplyPrivacyInterfaceResult extends WxOpenResult {
16+
17+
/**
18+
* 审核ID
19+
*/
20+
@SerializedName("audit_id")
21+
private Long auditId;
22+
23+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package me.chanjar.weixin.open.bean.ma.privacy;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import me.chanjar.weixin.open.bean.result.WxOpenResult;
7+
import org.springframework.lang.Nullable;
8+
9+
import java.util.List;
10+
11+
/**
12+
* 获取接口列表 响应
13+
*
14+
* @author <a href="https://www.sacoc.cn">广州跨界</a>
15+
*/
16+
@Getter
17+
@Setter
18+
public class GetPrivacyInterfaceResult extends WxOpenResult {
19+
20+
/**
21+
* 隐私接口列表
22+
*/
23+
@SerializedName("interface_list")
24+
private List<Interface> interfaceList;
25+
26+
27+
/**
28+
* 隐私接口
29+
*/
30+
@Getter
31+
@Setter
32+
public static class Interface {
33+
34+
/**
35+
* 接口英文名称,如:wx.chooseAddress/wx.choosePoi/wx.getLocation/wx.onLocationChange/wx.chooseLocation
36+
*/
37+
@SerializedName("api_name")
38+
private String apiName;
39+
40+
/**
41+
* 接口中文名称,如:获取用户收货地址/选择位置,支持模糊定位(精确到市)和精确定位混选/获取当前的地理位置、速度/监听实时地理位置变化事件/打开地图选择位置
42+
*/
43+
@SerializedName("api_ch_name")
44+
private String apiChName;
45+
46+
/**
47+
* api描述
48+
*/
49+
@SerializedName("api_desc")
50+
private String apiDesc;
51+
52+
/**
53+
* 申请时间 ,该字段发起申请后才会有
54+
*/
55+
@Nullable
56+
@SerializedName("apply_time")
57+
private String applyTime;
58+
59+
/**
60+
* 接口状态,该字段发起申请后才会有,1待申请开通,2无权限,3申请中,4申请失败,5已开通
61+
*/
62+
@Nullable
63+
@SerializedName("status")
64+
private String status;
65+
66+
/**
67+
* 申请单号,该字段发起申请后才会有
68+
*/
69+
@Nullable
70+
@SerializedName("audit_id")
71+
private String auditId;
72+
73+
/**
74+
* 申请被驳回原因或者无权限,该字段申请驳回时才会有
75+
*/
76+
@Nullable
77+
@SerializedName("fail_reason")
78+
private String failReason;
79+
80+
/**
81+
* api文档链接
82+
*/
83+
@SerializedName("fail_reapi_linkason")
84+
private String apiLink;
85+
86+
/**
87+
* 分组名,如:地理位置
88+
*/
89+
@SerializedName("group_name")
90+
private String groupName;
91+
}
92+
}

0 commit comments

Comments
 (0)