Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【企业微信】增加家校沟通-基础接口支持 #2719

Merged
merged 4 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
获取「学校通知」二维码接口
  • Loading branch information
0katekate0 committed Jun 27, 2022
commit b3ac18efb28c264cd711c4757131b9725a9a8361
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ public interface WxCpSchoolUserService {
*/
WxCpDepartmentList listDepartment(Integer id) throws WxErrorException;

/**
* 获取「学校通知」二维码
* 学校可通过此接口获取「学校通知」二维码,家长可通过扫描此二维码关注「学校通知」并接收学校推送的消息。
* 请求方式:GET(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_subscribe_qr_code?access_token=ACCESS_TOKEN
*
* @return
* @throws WxErrorException
*/
WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException;

/**
* 修改自动升年级的配置
* 请求方式: POST(HTTPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.List;

import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.GET_SUBSCRIBE_QR_CODE;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*;

/**
Expand Down Expand Up @@ -132,6 +133,13 @@ public WxCpDepartmentList listDepartment(Integer id) throws WxErrorException {
return WxCpDepartmentList.fromJson(responseContent);
}

@Override
public WxCpSubscribeQrCode getSubscribeQrCode() throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_SUBSCRIBE_QR_CODE);
String responseContent = this.cpService.get(apiUrl, null);
return WxCpSubscribeQrCode.fromJson(responseContent);
}

@Override
public WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_UPGRADE_INFO);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package me.chanjar.weixin.cp.bean.school.user;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;

/**
* 获取「学校通知」二维码 返回结果.
*
* @author Wang_Wong
*/
@Data
public class WxCpSubscribeQrCode extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = -5028321625140879571L;

@SerializedName("qrcode_big")
private String qrCodeBig;

@SerializedName("qrcode_middle")
private String qrCodeMiddle;

@SerializedName("qrcode_thumb")
private String qrCodeThumb;

public static WxCpSubscribeQrCode fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpSubscribeQrCode.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ interface ExternalContact {

String UPLOAD_ATTACHMENT = "/cgi-bin/media/upload_attachment";

String GET_SUBSCRIBE_QR_CODE = "/cgi-bin/externalcontact/get_subscribe_qr_code";

String ADD_INTERCEPT_RULE = "/cgi-bin/externalcontact/add_intercept_rule";
String UPDATE_INTERCEPT_RULE = "/cgi-bin/externalcontact/update_intercept_rule";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ public void test() throws WxErrorException {

final String userId = "WangKai";

/**
* 获取「学校通知」二维码
* https://developer.work.weixin.qq.com/document/path/92320
*/
String str6 = "{\n" +
" \"errcode\": 0,\n" +
" \"errmsg\": \"ok\",\n" +
" \"qrcode_big\":\"http://p.qpic.cn/wwhead/XXXX\",\n" +
" \"qrcode_middle\":\"http://p.qpic.cn/wwhead/XXXX\",\n" +
" \"qrcode_thumb\":\"http://p.qpic.cn/wwhead/XXXX\"\n" +
"}";

WxCpSubscribeQrCode cpSubscribeQrCode = WxCpSubscribeQrCode.fromJson(str6);
log.info("cpSubscribeQrCode:{}", cpSubscribeQrCode.toJson());

WxCpSubscribeQrCode subscribeQrCode = cpService.getSchoolUserService().getSubscribeQrCode();
log.info("subscribeQrCode:{}", subscribeQrCode.toJson());

/**
* 修改自动升年级的配置
Expand Down