mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
添加图文分析数据接口
This commit is contained in:
parent
f0cd7dd63a
commit
14fb63d6de
@ -1,18 +1,22 @@
|
|||||||
package me.chanjar.weixin.mp.api;
|
package me.chanjar.weixin.mp.api;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计分析相关接口
|
* 统计分析相关接口
|
||||||
* Created by Binary Wang on 2016/8/23.
|
* Created by Binary Wang on 2016/8/23.
|
||||||
* @author binarywang (https://github.com/binarywang)
|
* @author binarywang (https://github.com/binarywang)
|
||||||
*/
|
*/
|
||||||
public interface WxMpDataCubeService {
|
public interface WxMpDataCubeService {
|
||||||
|
//*******************用户分析数据接口***********************//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 获取用户增减数据
|
* 获取用户增减数据
|
||||||
@ -23,7 +27,7 @@ public interface WxMpDataCubeService {
|
|||||||
* @param beginDate 开始时间
|
* @param beginDate 开始时间
|
||||||
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
|
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
|
||||||
*/
|
*/
|
||||||
List<WxMpUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException;
|
List<WxDataCubeUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -35,5 +39,75 @@ public interface WxMpDataCubeService {
|
|||||||
* @param beginDate 开始时间
|
* @param beginDate 开始时间
|
||||||
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
|
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
|
||||||
*/
|
*/
|
||||||
List<WxMpUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException;
|
List<WxDataCubeUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
//*******************图文分析数据接口***********************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文群发每日数据(getarticlesummary)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getarticlesummary?access_token=ACCESS_TOKEN
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleResult> getArticleSummary(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文群发总数据(getarticletotal)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getarticletotal?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleTotal> getArticleTotal(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文统计数据(getuserread)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getuserread?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度3天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleResult> getUserRead(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文统计分时数据(getuserreadhour)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getuserreadhour?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleResult> getUserReadHour(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文分享转发数据(getusershare)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getusershare?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度7天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleResult> getUserShare(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 获取图文分享转发分时数据(getusersharehour)
|
||||||
|
* 详情请见文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141084&token=&lang=zh_CN">图文分析数据接口</a>
|
||||||
|
* 接口url格式:https://api.weixin.qq.com/datacube/getusersharehour?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param beginDate 开始时间
|
||||||
|
* @param endDate 最大时间跨度1天,endDate不能早于begingDate
|
||||||
|
*/
|
||||||
|
List<WxDataCubeArticleResult> getUserShareHour(Date beginDate, Date endDate) throws WxErrorException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
package me.chanjar.weixin.mp.api.impl;
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
|
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Binary Wang on 2016/8/23.
|
* Created by Binary Wang on 2016/8/23.
|
||||||
* @author binarywang (https://github.com/binarywang)
|
* @author binarywang (https://github.com/binarywang)
|
||||||
*/
|
*/
|
||||||
public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(WxMpServiceImpl.class);
|
||||||
|
|
||||||
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/datacube";
|
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/datacube";
|
||||||
private WxMpService wxMpService;
|
private WxMpService wxMpService;
|
||||||
|
|
||||||
@ -27,26 +32,106 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WxMpUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException {
|
public List<WxDataCubeUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
String url = API_URL_PREFIX + "/getusersummary";
|
String url = API_URL_PREFIX + "/getusersummary";
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
String responseContent = this.wxMpService.post(url, param.toString());
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
new TypeToken<List<WxMpUserSummary>>() {
|
new TypeToken<List<WxDataCubeUserSummary>>() {
|
||||||
}.getType());
|
}.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WxMpUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException {
|
public List<WxDataCubeUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
String url = API_URL_PREFIX + "/getusercumulate";
|
String url = API_URL_PREFIX + "/getusercumulate";
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
String responseContent = this.wxMpService.post(url, param.toString());
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
new TypeToken<List<WxMpUserCumulate>>() {
|
new TypeToken<List<WxDataCubeUserCumulate>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleResult> getArticleSummary(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getarticlesummary";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleTotal> getArticleTotal(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getarticletotal";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleTotal>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleResult> getUserRead(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getuserread";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleResult> getUserReadHour(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getuserreadhour";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleResult> getUserShare(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getusershare";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxDataCubeArticleResult> getUserShareHour(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
String url = API_URL_PREFIX + "/getusersharehour";
|
||||||
|
JsonObject param = new JsonObject();
|
||||||
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
||||||
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
||||||
|
String responseContent = this.wxMpService.post(url, param.toString());
|
||||||
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent);
|
||||||
|
return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"),
|
||||||
|
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||||
}.getType());
|
}.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,102 @@
|
|||||||
package me.chanjar.weixin.mp.bean.datacube;
|
package me.chanjar.weixin.mp.bean.datacube;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 图文分析数据接口返回结果对象
|
||||||
* @author binarywang(https://github.com/binarywang)
|
* @author binarywang(https://github.com/binarywang)
|
||||||
* Created by Binary Wang on 2016/8/24.
|
* Created by Binary Wang on 2016/8/24.
|
||||||
*/
|
*/
|
||||||
public class WxDataCubeArticleResult {
|
public class WxDataCubeArticleResult extends WxDataCubeBaseResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ref_hour
|
||||||
|
* 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时
|
||||||
|
*/
|
||||||
|
@SerializedName("ref_hour")
|
||||||
|
private Integer refHour;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* msgid
|
||||||
|
* 请注意:这里的msgid实际上是由msgid(图文消息id,这也就是群发接口调用后返回的msg_data_id)和index(消息次序索引)组成, 例如12003_3, 其中12003是msgid,即一次群发的消息的id; 3为index,假设该次群发的图文消息共5个文章(因为可能为多图文),3表示5个中的第3个
|
||||||
|
*/
|
||||||
|
@SerializedName("msgid")
|
||||||
|
private String msgId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* title
|
||||||
|
* 图文消息的标题
|
||||||
|
*/
|
||||||
|
@SerializedName("title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_read_user
|
||||||
|
* 图文页(点击群发图文卡片进入的页面)的阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_read_user")
|
||||||
|
private Integer intPageReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_read_count
|
||||||
|
* 图文页的阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_read_count")
|
||||||
|
private Integer intPageReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ori_page_read_user
|
||||||
|
* 原文页(点击图文页“阅读原文”进入的页面)的阅读人数,无原文页时此处数据为0
|
||||||
|
*/
|
||||||
|
@SerializedName("ori_page_read_user")
|
||||||
|
private Integer oriPageReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ori_page_read_count
|
||||||
|
* 原文页的阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("ori_page_read_count")
|
||||||
|
private Integer oriPageReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share_scene
|
||||||
|
* 分享的场景 1代表好友转发 2代表朋友圈 3代表腾讯微博 255代表其他
|
||||||
|
*/
|
||||||
|
@SerializedName("share_scene")
|
||||||
|
private Integer shareScene;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share_user
|
||||||
|
* 分享的人数
|
||||||
|
*/
|
||||||
|
@SerializedName("share_user")
|
||||||
|
private Integer shareUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share_count
|
||||||
|
* 分享的次数
|
||||||
|
*/
|
||||||
|
@SerializedName("share_count")
|
||||||
|
private Integer shareCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add_to_fav_user
|
||||||
|
* 收藏的人数
|
||||||
|
*/
|
||||||
|
@SerializedName("add_to_fav_user")
|
||||||
|
private Integer addToFavUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add_to_fav_count
|
||||||
|
* 收藏的次数
|
||||||
|
*/
|
||||||
|
@SerializedName("add_to_fav_count")
|
||||||
|
private Integer addToFavCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user_source
|
||||||
|
* 在获取图文阅读分时数据时才有该字段,代表用户从哪里进入来阅读该图文。0:会话;1.好友;2.朋友圈;3.腾讯微博;4.历史消息页;5.其他
|
||||||
|
*/
|
||||||
|
@SerializedName("user_source")
|
||||||
|
private Integer userSource;
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,14 @@ package me.chanjar.weixin.mp.bean.datacube;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图文分析数据接口返回结果对象
|
* 图文分析数据接口返回结果对象
|
||||||
* @author binarywang(https://github.com/binarywang)
|
* @author binarywang(https://github.com/binarywang)
|
||||||
* Created by Binary Wang on 2016/8/24.
|
* Created by Binary Wang on 2016/8/24.
|
||||||
*/
|
*/
|
||||||
public class WxDataCubeArticleTotal extends WxDataCubeResultBase {
|
public class WxDataCubeArticleTotal extends WxDataCubeBaseResult {
|
||||||
|
|
||||||
/**
|
|
||||||
* ref_hour
|
|
||||||
* 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msgid
|
* msgid
|
||||||
@ -29,72 +26,9 @@ public class WxDataCubeArticleTotal extends WxDataCubeResultBase {
|
|||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* int_page_read_user
|
* details
|
||||||
* 图文页(点击群发图文卡片进入的页面)的阅读人数
|
* 详细信息
|
||||||
*/
|
*/
|
||||||
@SerializedName("int_page_read_user")
|
@SerializedName("details")
|
||||||
private Integer intPageReadUser;
|
private List<WxDataCubeArticleTotalDetail> details;
|
||||||
|
|
||||||
/**
|
|
||||||
* int_page_read_count
|
|
||||||
* 图文页的阅读次数
|
|
||||||
*/
|
|
||||||
@SerializedName("int_page_read_count")
|
|
||||||
private Integer intPageReadCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ori_page_read_user
|
|
||||||
* 原文页(点击图文页“阅读原文”进入的页面)的阅读人数,无原文页时此处数据为0
|
|
||||||
*/
|
|
||||||
@SerializedName("ori_page_read_user")
|
|
||||||
private Integer oriPageReadUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ori_page_read_count
|
|
||||||
* 原文页的阅读次数
|
|
||||||
*/
|
|
||||||
@SerializedName("ori_page_read_count")
|
|
||||||
private Integer oriPageReadCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* share_scene
|
|
||||||
* 分享的场景 1代表好友转发 2代表朋友圈 3代表腾讯微博 255代表其他
|
|
||||||
*/
|
|
||||||
@SerializedName("share_scene")
|
|
||||||
private Integer shareScene;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* share_user
|
|
||||||
* 分享的人数
|
|
||||||
*/
|
|
||||||
@SerializedName("share_user")
|
|
||||||
private Integer shareUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* share_count
|
|
||||||
* 分享的次数
|
|
||||||
*/
|
|
||||||
@SerializedName("share_count")
|
|
||||||
private Integer shareCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add_to_fav_user
|
|
||||||
* 收藏的人数
|
|
||||||
*/
|
|
||||||
@SerializedName("add_to_fav_user")
|
|
||||||
private Integer addToFavUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add_to_fav_count
|
|
||||||
* 收藏的次数
|
|
||||||
*/
|
|
||||||
@SerializedName("add_to_fav_count")
|
|
||||||
private Integer addToFavCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* user_source
|
|
||||||
* 在获取图文阅读分时数据时才有该字段,代表用户从哪里进入来阅读该图文。0:会话;1.好友;2.朋友圈;3.腾讯微博;4.历史消息页;5.其他
|
|
||||||
*/
|
|
||||||
@SerializedName("user_source")
|
|
||||||
private Integer userSource;
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,194 @@
|
|||||||
package me.chanjar.weixin.mp.bean.datacube;
|
package me.chanjar.weixin.mp.bean.datacube;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 获取图文群发总数据接口(getarticletotal)中的详细字段
|
||||||
* @author binarywang(https://github.com/binarywang)
|
* @author binarywang(https://github.com/binarywang)
|
||||||
* Created by Binary Wang on 2016/8/24.
|
* Created by Binary Wang on 2016/8/24.
|
||||||
*/
|
*/
|
||||||
public class WxDataCubeArticleTotalDetail {
|
public class WxDataCubeArticleTotalDetail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stat_date
|
||||||
|
* 统计的日期,在getarticletotal接口中,ref_date指的是文章群发出日期, 而stat_date是数据统计日期
|
||||||
|
*/
|
||||||
|
@SerializedName("stat_date")
|
||||||
|
private Integer statDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* target_user
|
||||||
|
* 送达人数,一般约等于总粉丝数(需排除黑名单或其他异常情况下无法收到消息的粉丝)
|
||||||
|
*/
|
||||||
|
@SerializedName("target_user")
|
||||||
|
private Integer targetUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_read_user
|
||||||
|
* 图文页(点击群发图文卡片进入的页面)的阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_read_user")
|
||||||
|
private Integer intPageReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_read_count
|
||||||
|
* 图文页的阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_read_count")
|
||||||
|
private Integer intPageReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ori_page_read_user
|
||||||
|
* 原文页(点击图文页“阅读原文”进入的页面)的阅读人数,无原文页时此处数据为0
|
||||||
|
*/
|
||||||
|
@SerializedName("ori_page_read_user")
|
||||||
|
private Integer oriPageReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ori_page_read_count
|
||||||
|
* 原文页的阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("ori_page_read_count")
|
||||||
|
private Integer oriPageReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share_user
|
||||||
|
* 分享的人数
|
||||||
|
*/
|
||||||
|
@SerializedName("share_user")
|
||||||
|
private Integer shareUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share_count
|
||||||
|
* 分享的次数
|
||||||
|
*/
|
||||||
|
@SerializedName("share_count")
|
||||||
|
private Integer shareCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add_to_fav_user
|
||||||
|
* 收藏的人数
|
||||||
|
*/
|
||||||
|
@SerializedName("add_to_fav_user")
|
||||||
|
private Integer addToFavUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add_to_fav_count
|
||||||
|
* 收藏的次数
|
||||||
|
*/
|
||||||
|
@SerializedName("add_to_fav_count")
|
||||||
|
private Integer addToFavCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_session_read_user
|
||||||
|
* 公众号会话阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_session_read_user")
|
||||||
|
private Integer intPageFromSessionReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_session_read_count
|
||||||
|
* 公众号会话阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_session_read_count")
|
||||||
|
private Integer intPageFromSessionReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_hist_msg_read_user
|
||||||
|
* 历史消息页阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_hist_msg_read_user")
|
||||||
|
private Integer intPageFromHistMsgReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_hist_msg_read_count
|
||||||
|
* 历史消息页阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_hist_msg_read_count")
|
||||||
|
private Integer intPageFromHistMsgReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_feed_read_user
|
||||||
|
* 朋友圈阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_feed_read_user")
|
||||||
|
private Integer intPageFromFeedReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_feed_read_count
|
||||||
|
* 朋友圈阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_feed_read_count")
|
||||||
|
private Integer intPageFromFeedReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_friends_read_user
|
||||||
|
* 好友转发阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_friends_read_user")
|
||||||
|
private Integer intPageFromFriendsReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_friends_read_count
|
||||||
|
* 好友转发阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_friends_read_count")
|
||||||
|
private Integer intPageFromFriendsReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_other_read_user
|
||||||
|
* 其他场景阅读人数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_other_read_user")
|
||||||
|
private Integer intPageFromOtherReadUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* int_page_from_other_read_count
|
||||||
|
* 其他场景阅读次数
|
||||||
|
*/
|
||||||
|
@SerializedName("int_page_from_other_read_count")
|
||||||
|
private Integer intPageFromOtherReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_session_user
|
||||||
|
* 公众号会话转发朋友圈人数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_session_user")
|
||||||
|
private Integer feedShareFromSessionUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_session_cnt
|
||||||
|
* 公众号会话转发朋友圈次数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_session_cnt")
|
||||||
|
private Integer feedShareFromSessionCnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_feed_user
|
||||||
|
* 朋友圈转发朋友圈人数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_feed_user")
|
||||||
|
private Integer feedShareFromFeedUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_feed_cnt
|
||||||
|
* 朋友圈转发朋友圈次数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_feed_cnt")
|
||||||
|
private Integer feedShareFromFeedCnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_other_user
|
||||||
|
* 其他场景转发朋友圈人数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_other_user")
|
||||||
|
private Integer feedShareFromOtherUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feed_share_from_other_cnt
|
||||||
|
* 其他场景转发朋友圈次数
|
||||||
|
*/
|
||||||
|
@SerializedName("feed_share_from_other_cnt")
|
||||||
|
private Integer feedShareFromOtherCnt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
* @author binarywang(https://github.com/binarywang)
|
* @author binarywang(https://github.com/binarywang)
|
||||||
* Created by Binary Wang on 2016/8/25.
|
* Created by Binary Wang on 2016/8/25.
|
||||||
*/
|
*/
|
||||||
public class WxDataCubeResultBase {
|
public class WxDataCubeBaseResult {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
|
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
|
||||||
|
@ -3,6 +3,8 @@ package me.chanjar.weixin.mp.util.json;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import me.chanjar.weixin.mp.bean.*;
|
import me.chanjar.weixin.mp.bean.*;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
import me.chanjar.weixin.mp.bean.result.*;
|
import me.chanjar.weixin.mp.bean.result.*;
|
||||||
|
|
||||||
public class WxMpGsonBuilder {
|
public class WxMpGsonBuilder {
|
||||||
@ -25,8 +27,8 @@ public class WxMpGsonBuilder {
|
|||||||
INSTANCE.registerTypeAdapter(WxMpTemplateMessage.class, new WxMpTemplateMessageGsonAdapter());
|
INSTANCE.registerTypeAdapter(WxMpTemplateMessage.class, new WxMpTemplateMessageGsonAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpSemanticQueryResult.class, new WxMpSemanticQueryResultAdapter());
|
INSTANCE.registerTypeAdapter(WxMpSemanticQueryResult.class, new WxMpSemanticQueryResultAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpOAuth2AccessToken.class, new WxMpOAuth2AccessTokenAdapter());
|
INSTANCE.registerTypeAdapter(WxMpOAuth2AccessToken.class, new WxMpOAuth2AccessTokenAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpUserSummary.class, new WxMpUserSummaryGsonAdapter());
|
INSTANCE.registerTypeAdapter(WxDataCubeUserSummary.class, new WxMpUserSummaryGsonAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpUserCumulate.class, new WxMpUserCumulateGsonAdapter());
|
INSTANCE.registerTypeAdapter(WxDataCubeUserCumulate.class, new WxMpUserCumulateGsonAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpMaterialUploadResult.class, new WxMpMaterialUploadResultAdapter());
|
INSTANCE.registerTypeAdapter(WxMpMaterialUploadResult.class, new WxMpMaterialUploadResultAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpMaterialVideoInfoResult.class, new WxMpMaterialVideoInfoResultAdapter());
|
INSTANCE.registerTypeAdapter(WxMpMaterialVideoInfoResult.class, new WxMpMaterialVideoInfoResultAdapter());
|
||||||
INSTANCE.registerTypeAdapter(WxMpMassNews.WxMpMassNewsArticle.class, new WxMpMassNewsArticleGsonAdapter());
|
INSTANCE.registerTypeAdapter(WxMpMassNews.WxMpMassNewsArticle.class, new WxMpMassNewsArticleGsonAdapter());
|
||||||
|
@ -10,9 +10,7 @@ package me.chanjar.weixin.mp.util.json;
|
|||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
|
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@ -23,12 +21,12 @@ import java.text.SimpleDateFormat;
|
|||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WxMpUserCumulateGsonAdapter implements JsonDeserializer<WxMpUserCumulate> {
|
public class WxMpUserCumulateGsonAdapter implements JsonDeserializer<WxDataCubeUserCumulate> {
|
||||||
|
|
||||||
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
public WxMpUserCumulate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public WxDataCubeUserCumulate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
WxMpUserCumulate cumulate = new WxMpUserCumulate();
|
WxDataCubeUserCumulate cumulate = new WxDataCubeUserCumulate();
|
||||||
JsonObject summaryJsonObject = json.getAsJsonObject();
|
JsonObject summaryJsonObject = json.getAsJsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -10,8 +10,7 @@ package me.chanjar.weixin.mp.util.json;
|
|||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@ -20,13 +19,13 @@ import java.text.SimpleDateFormat;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public class WxMpUserSummaryGsonAdapter implements JsonDeserializer<WxMpUserSummary> {
|
public class WxMpUserSummaryGsonAdapter implements JsonDeserializer<WxDataCubeUserSummary> {
|
||||||
|
|
||||||
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
public WxMpUserSummary deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
public WxDataCubeUserSummary deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||||
throws JsonParseException {
|
throws JsonParseException {
|
||||||
WxMpUserSummary summary = new WxMpUserSummary();
|
WxDataCubeUserSummary summary = new WxDataCubeUserSummary();
|
||||||
JsonObject summaryJsonObject = json.getAsJsonObject();
|
JsonObject summaryJsonObject = json.getAsJsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package me.chanjar.weixin.mp.api.impl;
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
|
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Guice;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Guice;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
|
||||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
|
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试统计分析相关的接口
|
* 测试统计分析相关的接口
|
||||||
* Created by Binary Wang on 2016/8/23.
|
* Created by Binary Wang on 2016/8/23.
|
||||||
@ -28,24 +29,91 @@ public class WxMpDataCubeServiceImplTest {
|
|||||||
@Inject
|
@Inject
|
||||||
protected WxMpServiceImpl wxService;
|
protected WxMpServiceImpl wxService;
|
||||||
|
|
||||||
@Test
|
@DataProvider
|
||||||
public void testGetUserSummary() throws WxErrorException, ParseException {
|
public Object[][] oneDay() throws ParseException {
|
||||||
Date beginDate = simpleDateFormat.parse("2016-08-20");
|
return new Object[][]{{simpleDateFormat.parse("2016-08-22")}};
|
||||||
Date endDate = simpleDateFormat.parse("2016-08-22");
|
}
|
||||||
List<WxMpUserSummary> summaries = this.wxService.getDataCubeService()
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] threeDays() throws ParseException {
|
||||||
|
return new Object[][]{{simpleDateFormat.parse("2016-08-20"),
|
||||||
|
simpleDateFormat.parse("2016-08-22")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] sevenDays() throws ParseException {
|
||||||
|
return new Object[][]{{simpleDateFormat.parse("2016-08-16"),
|
||||||
|
simpleDateFormat.parse("2016-08-22")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUserSummary(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeUserSummary> summaries = this.wxService.getDataCubeService()
|
||||||
.getUserSummary(beginDate, endDate);
|
.getUserSummary(beginDate, endDate);
|
||||||
Assert.assertNotNull(summaries);
|
Assert.assertNotNull(summaries);
|
||||||
System.out.println(summaries);
|
System.out.println(summaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(dataProvider = "sevenDays")
|
||||||
public void testGetUserCumulate() throws WxErrorException, ParseException {
|
public void testGetUserCumulate(Date beginDate, Date endDate)
|
||||||
Date beginDate = simpleDateFormat.parse("2016-08-21");
|
throws WxErrorException {
|
||||||
Date endDate = simpleDateFormat.parse("2016-08-22");
|
List<WxDataCubeUserCumulate> result = this.wxService.getDataCubeService()
|
||||||
List<WxMpUserCumulate> cumulates = this.wxService.getDataCubeService()
|
|
||||||
.getUserCumulate(beginDate, endDate);
|
.getUserCumulate(beginDate, endDate);
|
||||||
Assert.assertNotNull(cumulates);
|
Assert.assertNotNull(result);
|
||||||
System.out.println(cumulates);
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetArticleSummary(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getArticleSummary(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
||||||
|
*/
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetArticleTotal(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleTotal> results = this.wxService.getDataCubeService()
|
||||||
|
.getArticleTotal(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "threeDays")
|
||||||
|
public void testGetUserRead(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserRead(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetUserReadHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserReadHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUserShare(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserShare(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetUserShareHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserShareHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public class WxMpKfListTest {
|
public class WxMpKfListTest {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user