1
0
mirror of synced 2025-12-24 02:57:55 +08:00

🆕 #2674【企业微信】增加家校应用健康上报部分接口

This commit is contained in:
0katekate0
2022-05-31 20:14:20 +08:00
committed by GitHub
parent 42122ce548
commit 3952fcdd33
10 changed files with 441 additions and 1 deletions

View File

@@ -168,7 +168,14 @@ public class WxCpMsgAuditTest {
return;
}
// 拉取媒体文件
/**
* 拉取媒体文件
*
* 注意:
* 1、根据上面返回的文件类型拼接好存放文件的绝对路径即可。此时绝对路径写入文件流来达到获取媒体文件的目的。
* 2、拉取完媒体文件之后此时文件已经存在绝对路径可以通过mq异步上传到对象存储
* 3、比如可以上传到阿里云oss或者腾讯云cos
*/
String targetPath = path + md5Sum + suffix;
cpService.getMsgAuditService().getMediaFile(sdkFileId, null, null, 1000L, targetPath);

View File

@@ -0,0 +1,66 @@
package me.chanjar.weixin.cp.api;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.school.health.WxCpGetHealthReportStat;
import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobIds;
import me.chanjar.weixin.cp.bean.school.health.WxCpGetReportJobInfo;
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
import org.testng.annotations.Test;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 企业微信家校应用 健康上报接口.
* https://developer.work.weixin.qq.com/document/path/93676
*
* @author <a href="https://github.com/0katekate0">Wang_Wong</a>
* @date: 2022/5/31 9:10
*/
@Slf4j
public class WxCpSchoolHealthTest {
private static WxCpConfigStorage wxCpConfigStorage;
private static WxCpService cpService;
@Test
public void test() throws WxErrorException {
InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml");
WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream);
wxCpConfigStorage = config;
cpService = new WxCpServiceImpl();
cpService.setWxCpConfigStorage(config);
String currDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
/**
* 获取健康上报任务ID列表
* https://developer.work.weixin.qq.com/document/path/93677
*/
WxCpGetReportJobIds reportJobids = cpService.getSchoolHealthService().getReportJobIds(null, null);
log.info("返回的reportJobids为{}", reportJobids.toJson());
/**
* 获取健康上报任务详情
* https://developer.work.weixin.qq.com/document/path/93678
*/
WxCpGetReportJobInfo reportJobInfo = cpService.getSchoolHealthService().getReportJobInfo(null, currDate);
log.info("返回的reportJobInfo为{}", reportJobInfo.toJson());
/**
* 获取健康上报使用统计
* https://developer.work.weixin.qq.com/document/path/93676
*/
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
WxCpGetHealthReportStat healthReportStat = cpService.getSchoolHealthService().getHealthReportStat(date);
log.info("返回的healthReportStat为{}", healthReportStat.toJson());
}
}