Skip to content

Commit 7ffc1b3

Browse files
qw8881569Binary Wang
authored andcommitted
🆕【开放平台】添加获取换绑管理员 URL 的接口
1 parent 8bb4a21 commit 7ffc1b3

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
55
import me.chanjar.weixin.open.bean.result.*;
66

7+
import java.io.UnsupportedEncodingException;
78
import java.util.List;
89

910
/**
@@ -78,6 +79,8 @@ public interface WxOpenMaBasicService {
7879
*/
7980
String OPEN_GET_ORDER_PATH_INFO = "https://api.weixin.qq.com/wxa/security/getorderpathinfo";
8081

82+
String URL_COMPONENT_REBIND_ADMIN = "https://mp.weixin.qq.com/wxopen/componentrebindadmin?appid=%s&component_appid=%s&redirect_uri=%s";
83+
8184

8285
/**
8386
* 1.获取小程序的信息
@@ -148,6 +151,14 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
148151
*/
149152
WxOpenResult modifySignature(String signature) throws WxErrorException;
150153

154+
/**
155+
* 7.1 获取换绑管理员URL
156+
* @param redirectUri 跳转URL
157+
* @param appId 公众号的 appid
158+
* @return 换绑管理员URL
159+
*/
160+
String getComponentRebindAdminUrl(String redirectUri, String appId) throws UnsupportedEncodingException;
161+
151162
/**
152163
* 7.3 管理员换绑
153164
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import me.chanjar.weixin.open.bean.result.*;
1212
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
1313

14+
import java.io.UnsupportedEncodingException;
1415
import java.util.HashMap;
1516
import java.util.List;
1617
import java.util.Map;
@@ -99,6 +100,11 @@ public WxOpenResult modifySignature(String signature) throws WxErrorException {
99100
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
100101
}
101102

103+
@Override
104+
public String getComponentRebindAdminUrl(String redirectUri, String appId) {
105+
return "";
106+
}
107+
102108
@Override
103109
public WxOpenResult componentRebindAdmin(String taskid) throws WxErrorException {
104110
JsonObject params = new JsonObject();

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import com.google.gson.JsonArray;
55
import com.google.gson.JsonObject;
6+
import lombok.SneakyThrows;
67
import me.chanjar.weixin.common.error.WxErrorException;
8+
import me.chanjar.weixin.open.api.WxOpenComponentService;
79
import me.chanjar.weixin.open.api.WxOpenMaBasicService;
810
import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
911
import me.chanjar.weixin.open.bean.result.*;
1012
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
1113

14+
import java.io.UnsupportedEncodingException;
15+
import java.net.URLEncoder;
1216
import java.util.HashMap;
1317
import java.util.List;
1418
import java.util.Map;
@@ -21,9 +25,11 @@
2125
public class WxOpenMaBasicServiceImpl implements WxOpenMaBasicService {
2226

2327
private final WxMaService wxMaService;
28+
private final WxOpenComponentService wxOpenComponentService;
2429

25-
public WxOpenMaBasicServiceImpl(WxMaService wxMaService) {
30+
public WxOpenMaBasicServiceImpl(WxMaService wxMaService, WxOpenComponentService wxOpenComponentService) {
2631
this.wxMaService = wxMaService;
32+
this.wxOpenComponentService = wxOpenComponentService;
2733
}
2834

2935

@@ -81,6 +87,15 @@ public WxOpenResult modifySignature(String signature) throws WxErrorException {
8187
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
8288
}
8389

90+
@SneakyThrows
91+
@Override
92+
public String getComponentRebindAdminUrl(String redirectUri, String appId) {
93+
String componentAppId = wxOpenComponentService.getWxOpenConfigStorage().getComponentAppId();
94+
String encoded = URLEncoder.encode(redirectUri, "UTF-8");
95+
return String.format(URL_COMPONENT_REBIND_ADMIN, appId, componentAppId, encoded);
96+
}
97+
98+
8499
@Override
85100
public WxOpenResult componentRebindAdmin(String taskid) throws WxErrorException {
86101
JsonObject params = new JsonObject();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public WxOpenMaServiceImpl(WxOpenComponentService wxOpenComponentService, String
6363
this.wxOpenComponentService = wxOpenComponentService;
6464
this.appId = appId;
6565
this.wxMaConfig = wxMaConfig;
66-
this.basicService = new WxOpenMaBasicServiceImpl(this);
66+
this.basicService = new WxOpenMaBasicServiceImpl(this, wxOpenComponentService);
6767
this.authService = new WxOpenMaAuthServiceImpl(this);
6868
this.icpService = new WxOpenMaIcpServiceImpl(this);
6969
this.privacyService = new WxOpenMaPrivacyServiceImpl(this);

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/authandicp/WxOpenSubmitAuthAndIcpParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public static class IcpApplets implements Serializable {
518518
* 微信小程序基本信息
519519
*/
520520
@SerializedName("base_info")
521-
private AppletsBaseInfo AppleBaseInfo;
521+
private AppletsBaseInfo baseInfo;
522522

523523
/**
524524
* 小程序负责人信息

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/icp/WxOpenApplyIcpFilingParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static class Applets implements Serializable {
313313
* 微信小程序基本信息
314314
*/
315315
@SerializedName("base_info")
316-
private AppletsBaseInfo basInfo;
316+
private AppletsBaseInfo baseInfo;
317317

318318
/**
319319
* 小程序负责人信息

0 commit comments

Comments
 (0)