Skip to content

Commit

Permalink
1. 增加接口分析数据接口;2. 增加消息分析数据接口和接口分析数据接口的单元测试模块。
Browse files Browse the repository at this point in the history
  • Loading branch information
junior9919 committed Jan 5, 2016
1 parent 2be629c commit 49c51fb
Show file tree
Hide file tree
Showing 16 changed files with 780 additions and 7 deletions.
86 changes: 86 additions & 0 deletions src/com/halo/wechat/capabilities/InterfaceAnalysisCapability.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.halo.wechat.capabilities;

import java.util.HashMap;
import java.util.Map;

import com.halo.http.utils.HttpUtilsException;
import com.halo.json.utils.JSONUtils;
import com.halo.wechat.capabilities.abilities.InterfaceAnalysisAbility;
import com.halo.wechat.capabilities.beans.AnalysisBean;
import com.halo.wechat.capabilities.beans.InterfaceSummaryBean;
import com.halo.wechat.capabilities.beans.InterfaceSummaryHourBean;

/**
* 用于获得公众平台官网数据统计模块中接口分析数据的接口
*
* @author zyl
* @date 2016年1月5日 下午9:11:30
* @version
* @since
*/
public class InterfaceAnalysisCapability extends AccessSupportCapability implements InterfaceAnalysisAbility {

private final String GET_INTERFACE_SUMMARY_URL = "https://api.weixin.qq.com/datacube/getinterfacesummary";

private final String GET_INTERFACE_SUMMARY_HOUR_URL = "https://api.weixin.qq.com/datacube/getinterfacesummaryhour";

/**
* 无参构造方法,会自动调用AbstractCapability的无参构造方法,初始化"wechat.properties"配置文件。<br>
* 如果配置文件不存在或非法格式, 构造方法抛出CapabilityException异常
*
* @throws CapabilityException
* 加载"wechat.properties"配置文件失败抛出的异常
*/
public InterfaceAnalysisCapability() throws PropertiesException {

}

/**
* 获取接口分析数据
*
* @param analysisBean
* 用户分析数据接口需要向相应接口调用地址POST的数据包
* @return 接口分析数据接口的返回数据
* @throws CapabilityException
*/
@Override
public InterfaceSummaryBean getInterfaceSummary(AnalysisBean analysisBean) throws CapabilityException {
Map<String, String> args = new HashMap<String, String>();
putAccessTokenIntoArgs(args);

InterfaceSummaryBean resultBean = null;
try {
resultBean = this.getHttpTemplate().jsonPost(GET_INTERFACE_SUMMARY_URL, args,
new JSONUtils<AnalysisBean>(AnalysisBean.class), analysisBean,
new JSONUtils<InterfaceSummaryBean>(InterfaceSummaryBean.class));
} catch (HttpUtilsException e) {
throw new CapabilityException("Get interface summary failed.", e);
}
return resultBean;
}

/**
* 获取接口分析分时数据
*
* @param analysisBean
* 用户分析数据接口需要向相应接口调用地址POST的数据包
* @return 接口分析分时数据
* @throws CapabilityException
*/
@Override
public InterfaceSummaryHourBean getInterfaceSummaryHour(AnalysisBean analysisBean) throws CapabilityException {
Map<String, String> args = new HashMap<String, String>();
putAccessTokenIntoArgs(args);

InterfaceSummaryHourBean resultBean = null;
try {
resultBean = this.getHttpTemplate().jsonPost(GET_INTERFACE_SUMMARY_HOUR_URL, args,
new JSONUtils<AnalysisBean>(AnalysisBean.class), analysisBean,
new JSONUtils<InterfaceSummaryHourBean>(InterfaceSummaryHourBean.class));
} catch (HttpUtilsException e) {
throw new CapabilityException("Get interface summary hour failed.", e);
}
return resultBean;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.halo.wechat.capabilities.abilities;

import com.halo.wechat.capabilities.CapabilityException;
import com.halo.wechat.capabilities.beans.AnalysisBean;
import com.halo.wechat.capabilities.beans.InterfaceSummaryBean;
import com.halo.wechat.capabilities.beans.InterfaceSummaryHourBean;

/**
* 用于获得公众平台官网数据统计模块中接口分析数据的接口
*
* @author zyl
* @date 2016年1月5日 下午9:06:23
* @version
* @since
*/
public interface InterfaceAnalysisAbility {

/**
* 获取接口分析数据
*
* @param analysisBean
* 用户分析数据接口需要向相应接口调用地址POST的数据包
* @return 接口分析数据接口的返回数据
* @throws CapabilityException
*/
public InterfaceSummaryBean getInterfaceSummary(AnalysisBean analysisBean) throws CapabilityException;

/**
* 获取接口分析分时数据
*
* @param analysisBean
* 用户分析数据接口需要向相应接口调用地址POST的数据包
* @return 接口分析分时数据
* @throws CapabilityException
*/
public InterfaceSummaryHourBean getInterfaceSummaryHour(AnalysisBean analysisBean) throws CapabilityException;

}
30 changes: 30 additions & 0 deletions src/com/halo/wechat/capabilities/beans/InterfaceSummaryBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.halo.wechat.capabilities.beans;

/**
* 接口分析数据接口的返回数据
*
* @author zyl
* @date 2016年1月5日 下午8:56:23
* @version
* @since
*/
public class InterfaceSummaryBean extends ResultBean {

private InterfaceSummaryData[] list;

/**
* @return InterfaceSummaryData[] 不同ref_date(在begin_date和end_date之间)的数据
*/
public InterfaceSummaryData[] getList() {
return list;
}

/**
* @param InterfaceSummaryData[]
* list 不同ref_date(在begin_date和end_date之间)的数据
*/
public void setList(InterfaceSummaryData[] list) {
this.list = list;
}

}
98 changes: 98 additions & 0 deletions src/com/halo/wechat/capabilities/beans/InterfaceSummaryData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.halo.wechat.capabilities.beans;

/**
* 接口分析数据接口的返回数据
*
* @author zyl
* @date 2016年1月5日 下午8:36:37
* @version
* @since
*/
public class InterfaceSummaryData {

private String ref_date;

private int callback_count;

private int fail_count;

private int total_time_cost;

private int max_time_cost;

/**
* @return String 数据的日期
*/
public String getRef_date() {
return ref_date;
}

/**
* @param String
* ref_date 数据的日期
*/
public void setRef_date(String ref_date) {
this.ref_date = ref_date;
}

/**
* @return int 通过服务器配置地址获得消息后,被动回复用户消息的次数
*/
public int getCallback_count() {
return callback_count;
}

/**
* @param int
* callback_count 通过服务器配置地址获得消息后,被动回复用户消息的次数
*/
public void setCallback_count(int callback_count) {
this.callback_count = callback_count;
}

/**
* @return int 上述动作的失败次数
*/
public int getFail_count() {
return fail_count;
}

/**
* @param int
* fail_count 上述动作的失败次数
*/
public void setFail_count(int fail_count) {
this.fail_count = fail_count;
}

/**
* @return int 总耗时,除以callback_count即为平均耗时
*/
public int getTotal_time_cost() {
return total_time_cost;
}

/**
* @param int
* total_time_cost 总耗时,除以callback_count即为平均耗时
*/
public void setTotal_time_cost(int total_time_cost) {
this.total_time_cost = total_time_cost;
}

/**
* @return int 最大耗时
*/
public int getMax_time_cost() {
return max_time_cost;
}

/**
* @param int
* max_time_cost 最大耗时
*/
public void setMax_time_cost(int max_time_cost) {
this.max_time_cost = max_time_cost;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
*
*/
package com.halo.wechat.capabilities.beans;

/**
* 接口分析分时数据
* @author zyl
* @date 2016年1月5日 下午9:04:10
* @version
* @since
*/
public class InterfaceSummaryHourBean extends ResultBean {

private InterfaceSummaryHourData[] list;

/**
* @return InterfaceSummaryHourData[] 不同ref_hour的数据
*/
public InterfaceSummaryHourData[] getList() {
return list;
}

/**
* @param InterfaceSummaryHourData[]
* list 不同ref_hour的数据
*/
public void setList(InterfaceSummaryHourData[] list) {
this.list = list;
}

}
Loading

0 comments on commit 49c51fb

Please sign in to comment.