mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
重构统计接口代码
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 图文分析数据接口返回结果对象
|
||||
@@ -9,6 +15,8 @@ import com.google.gson.annotations.SerializedName;
|
||||
*/
|
||||
public class WxDataCubeArticleResult extends WxDataCubeBaseResult {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
/**
|
||||
* ref_hour
|
||||
* 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时
|
||||
@@ -203,5 +211,11 @@ public class WxDataCubeArticleResult extends WxDataCubeBaseResult {
|
||||
public void setUserSource(Integer userSource) {
|
||||
this.userSource = userSource;
|
||||
}
|
||||
|
||||
|
||||
public static List<WxDataCubeArticleResult> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeArticleResult>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 图文分析数据接口返回结果对象
|
||||
* @author binarywang(https://github.com/binarywang)
|
||||
@@ -11,6 +15,8 @@ import java.util.List;
|
||||
*/
|
||||
public class WxDataCubeArticleTotal extends WxDataCubeBaseResult {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
/**
|
||||
* msgid
|
||||
* 请注意:这里的msgid实际上是由msgid(图文消息id,这也就是群发接口调用后返回的msg_data_id)和index(消息次序索引)组成, 例如12003_3, 其中12003是msgid,即一次群发的消息的id; 3为index,假设该次群发的图文消息共5个文章(因为可能为多图文),3表示5个中的第3个
|
||||
@@ -55,5 +61,11 @@ public class WxDataCubeArticleTotal extends WxDataCubeBaseResult {
|
||||
public void setDetails(List<WxDataCubeArticleTotalDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
|
||||
public static List<WxDataCubeArticleTotal> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeArticleTotal>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 接口分析数据接口返回结果对象
|
||||
@@ -9,6 +15,8 @@ import com.google.gson.annotations.SerializedName;
|
||||
*/
|
||||
public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
/**
|
||||
* ref_hour
|
||||
* 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时
|
||||
@@ -83,5 +91,12 @@ public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult {
|
||||
public void setMaxTimeCost(Integer maxTimeCost) {
|
||||
this.maxTimeCost = maxTimeCost;
|
||||
}
|
||||
|
||||
public static List<WxDataCubeInterfaceResult> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeInterfaceResult>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 消息分析数据接口返回结果对象
|
||||
@@ -9,6 +15,8 @@ import com.google.gson.annotations.SerializedName;
|
||||
*/
|
||||
public class WxDataCubeMsgResult extends WxDataCubeBaseResult {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
/**
|
||||
* ref_hour
|
||||
* 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时
|
||||
@@ -114,4 +122,11 @@ public class WxDataCubeMsgResult extends WxDataCubeBaseResult {
|
||||
this.oriPageReadUser = oriPageReadUser;
|
||||
}
|
||||
|
||||
public static List<WxDataCubeMsgResult> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeMsgResult>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 累计用户数据接口的返回JSON数据包
|
||||
* http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html
|
||||
* 详情查看文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141082&token=&lang=zh_CN">用户分析数据接口</a>
|
||||
* </pre>
|
||||
*/
|
||||
public class WxDataCubeUserCumulate implements Serializable {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
private static final long serialVersionUID = -3570981300225093657L;
|
||||
|
||||
private Date refDate;
|
||||
@@ -40,4 +48,11 @@ public class WxDataCubeUserCumulate implements Serializable {
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
|
||||
}
|
||||
|
||||
public static List<WxDataCubeUserCumulate> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeUserCumulate>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package me.chanjar.weixin.mp.bean.datacube;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 用户增减数据接口的返回JSON数据包
|
||||
* http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html
|
||||
* 详情查看文档:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141082&token=&lang=zh_CN">用户分析数据接口</a>
|
||||
* </pre>
|
||||
*/
|
||||
public class WxDataCubeUserSummary implements Serializable {
|
||||
private static final long serialVersionUID = -2336654489906694173L;
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
private Date refDate;
|
||||
|
||||
private Integer userSource;
|
||||
@@ -59,4 +67,11 @@ public class WxDataCubeUserSummary implements Serializable {
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
|
||||
}
|
||||
|
||||
public static List<WxDataCubeUserSummary> fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(
|
||||
JSON_PARSER.parse(json).getAsJsonObject().get("list"),
|
||||
new TypeToken<List<WxDataCubeUserSummary>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user