@Test public void testGetUserSummary(){ Calendar calendar = Calendar.getInstance(); calendar.roll(Calendar.DAY_OF_YEAR, -6); List<UserSummary> userSummaries = Stats.defaultStats().getUserSummary(calendar.getTime()); assertNotNull(userSummaries); }
public List<UserSummary> getUserSummary(Date start, Date end) { if(diffThan6Days(start, end)) { throw new IllegalArgumentException("start和end相差不能超过6天以上"); } String url = WxEndpoint.get("url.stats.user.summary"); String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String body = String.format(json, dateFormat.format(start), dateFormat.format(end)); logger.debug("stats: get user summary: {}", body); String response = wxClient.post(url, body); UserSummaryWrapper userSummaryWrapper = JsonMapper.defaultMapper().fromJson(response, UserSummaryWrapper.class); return userSummaryWrapper.getList(); }
Stats { public List<UserSummary> getUserSummary(Date start, Date end) { if(diffThan6Days(start, end)) { throw new IllegalArgumentException("start和end相差不能超过6天以上"); } String url = WxEndpoint.get("url.stats.user.summary"); String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String body = String.format(json, dateFormat.format(start), dateFormat.format(end)); logger.debug("stats: get user summary: {}", body); String response = wxClient.post(url, body); UserSummaryWrapper userSummaryWrapper = JsonMapper.defaultMapper().fromJson(response, UserSummaryWrapper.class); return userSummaryWrapper.getList(); } }
Stats { public List<UserSummary> getUserSummary(Date start, Date end) { if(diffThan6Days(start, end)) { throw new IllegalArgumentException("start和end相差不能超过6天以上"); } String url = WxEndpoint.get("url.stats.user.summary"); String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String body = String.format(json, dateFormat.format(start), dateFormat.format(end)); logger.debug("stats: get user summary: {}", body); String response = wxClient.post(url, body); UserSummaryWrapper userSummaryWrapper = JsonMapper.defaultMapper().fromJson(response, UserSummaryWrapper.class); return userSummaryWrapper.getList(); }  }
Stats { public List<UserSummary> getUserSummary(Date start, Date end) { if(diffThan6Days(start, end)) { throw new IllegalArgumentException("start和end相差不能超过6天以上"); } String url = WxEndpoint.get("url.stats.user.summary"); String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String body = String.format(json, dateFormat.format(start), dateFormat.format(end)); logger.debug("stats: get user summary: {}", body); String response = wxClient.post(url, body); UserSummaryWrapper userSummaryWrapper = JsonMapper.defaultMapper().fromJson(response, UserSummaryWrapper.class); return userSummaryWrapper.getList(); }  static Stats defaultStats(); static Stats with(AppSetting appSetting); void setWxClient(WxClient wxClient); List<UserSummary> getUserSummary(Date start, Date end); List<UserSummary> getUserSummary(Date start); List<UserCumulative> getUserCumulative(Date start, Date end); List<UserCumulative> getUserCumulative(Date start); }
Stats { public List<UserSummary> getUserSummary(Date start, Date end) { if(diffThan6Days(start, end)) { throw new IllegalArgumentException("start和end相差不能超过6天以上"); } String url = WxEndpoint.get("url.stats.user.summary"); String json = "{\"begin_date\":\"%s\",\"end_date\":\"%s\"}"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String body = String.format(json, dateFormat.format(start), dateFormat.format(end)); logger.debug("stats: get user summary: {}", body); String response = wxClient.post(url, body); UserSummaryWrapper userSummaryWrapper = JsonMapper.defaultMapper().fromJson(response, UserSummaryWrapper.class); return userSummaryWrapper.getList(); }  static Stats defaultStats(); static Stats with(AppSetting appSetting); void setWxClient(WxClient wxClient); List<UserSummary> getUserSummary(Date start, Date end); List<UserSummary> getUserSummary(Date start); List<UserCumulative> getUserCumulative(Date start, Date end); List<UserCumulative> getUserCumulative(Date start);  }