|
|
|
|
@ -1,8 +1,17 @@
|
|
|
|
|
package me.chanjar.weixin.mp.api.impl;
|
|
|
|
|
|
|
|
|
|
import java.text.Format;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.FastDateFormat;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
import com.google.gson.JsonParser;
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
|
|
|
|
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
|
|
|
|
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
|
|
|
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
|
|
@ -13,11 +22,6 @@ import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
|
|
|
|
|
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 org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by Binary Wang on 2016/8/23.
|
|
|
|
|
@ -27,6 +31,9 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
protected final Logger log = LoggerFactory.getLogger(WxMpDataCubeServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/datacube";
|
|
|
|
|
|
|
|
|
|
private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
private WxMpService wxMpService;
|
|
|
|
|
|
|
|
|
|
public WxMpDataCubeServiceImpl(WxMpService wxMpService) {
|
|
|
|
|
@ -37,8 +44,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
public List<WxDataCubeUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getusersummary";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -50,8 +57,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
public List<WxDataCubeUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getusercumulate";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -63,8 +70,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -76,8 +83,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -89,8 +96,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -102,8 +109,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -115,8 +122,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -128,8 +135,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
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));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -142,8 +149,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsg";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -156,8 +163,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsghour";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -170,8 +177,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsgweek";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -184,8 +191,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsgmonth";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -198,8 +205,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsgdist";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -212,8 +219,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsgdistweek";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -226,8 +233,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getupstreammsgdistmonth";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -240,8 +247,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getinterfacesummary";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
@ -254,8 +261,8 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
|
|
|
|
Date endDate) throws WxErrorException {
|
|
|
|
|
String url = API_URL_PREFIX + "/getinterfacesummaryhour";
|
|
|
|
|
JsonObject param = new JsonObject();
|
|
|
|
|
param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate));
|
|
|
|
|
param.addProperty("begin_date", this.dateFormat.format(beginDate));
|
|
|
|
|
param.addProperty("end_date", this.dateFormat.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"),
|
|
|
|
|
|