mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #1723 企业微信增加查询应用消息发送统计的接口
This commit is contained in:
@@ -4,6 +4,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
|
||||
|
||||
/**
|
||||
* 消息推送接口.
|
||||
@@ -24,6 +25,21 @@ public interface WxCpMessageService {
|
||||
*/
|
||||
WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 查询应用消息发送统计
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/message/get_statistics?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/92369
|
||||
* </pre>
|
||||
*
|
||||
* @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。
|
||||
* @return 统计结果
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 互联企业的应用支持推送文本、图片、视频、文件、图文等类型。
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.WxCpMessageService;
|
||||
@@ -7,7 +8,9 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
|
||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 消息推送接口实现类.
|
||||
@@ -27,7 +30,13 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
|
||||
}
|
||||
|
||||
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
|
||||
.getApiUrl(WxCpApiPathConsts.Message.MESSAGE_SEND), message.toJson()));
|
||||
.getApiUrl(Message.MESSAGE_SEND), message.toJson()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException {
|
||||
return WxCpMessageSendStatistics.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(Message.GET_STATISTICS),
|
||||
WxCpGsonBuilder.create().toJson(ImmutableMap.of("time_type", timeType))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,6 +47,6 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
|
||||
}
|
||||
|
||||
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
|
||||
.getApiUrl(WxCpApiPathConsts.Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
|
||||
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user