|
8 | 8 | import me.chanjar.weixin.mp.api.WxMpService;
|
9 | 9 | import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
|
10 | 10 | import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
|
| 11 | +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; |
11 | 12 | import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
12 | 13 | import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
13 | 14 | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
|
22 | 23 | * @author binarywang (https://github.com/binarywang)
|
23 | 24 | */
|
24 | 25 | public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
|
25 |
| - protected final Logger log = LoggerFactory.getLogger(WxMpServiceImpl.class); |
| 26 | + protected final Logger log = LoggerFactory.getLogger(WxMpDataCubeServiceImpl.class); |
26 | 27 |
|
27 | 28 | private static final String API_URL_PREFIX = "https://api.weixin.qq.com/datacube";
|
28 | 29 | private WxMpService wxMpService;
|
@@ -134,4 +135,102 @@ public List<WxDataCubeArticleResult> getUserShareHour(Date beginDate, Date endDa
|
134 | 135 | new TypeToken<List<WxDataCubeArticleResult>>() {
|
135 | 136 | }.getType());
|
136 | 137 | }
|
| 138 | + |
| 139 | + @Override |
| 140 | + public List<WxDataCubeMsgResult> getUpstreamMsg(Date beginDate, Date endDate) |
| 141 | + throws WxErrorException { |
| 142 | + String url = API_URL_PREFIX + "/getupstreammsg"; |
| 143 | + JsonObject param = new JsonObject(); |
| 144 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 145 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 146 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 147 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 148 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 149 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 150 | + }.getType()); |
| 151 | + } |
| 152 | + |
| 153 | + @Override |
| 154 | + public List<WxDataCubeMsgResult> getUpstreamMsgHour(Date beginDate, |
| 155 | + Date endDate) throws WxErrorException { |
| 156 | + String url = API_URL_PREFIX + "/getupstreammsghour"; |
| 157 | + JsonObject param = new JsonObject(); |
| 158 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 159 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 160 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 161 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 162 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 163 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 164 | + }.getType()); |
| 165 | + } |
| 166 | + |
| 167 | + @Override |
| 168 | + public List<WxDataCubeMsgResult> getUpstreamMsgWeek(Date beginDate, |
| 169 | + Date endDate) throws WxErrorException { |
| 170 | + String url = API_URL_PREFIX + "/getupstreammsgweek"; |
| 171 | + JsonObject param = new JsonObject(); |
| 172 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 173 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 174 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 175 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 176 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 177 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 178 | + }.getType()); |
| 179 | + } |
| 180 | + |
| 181 | + @Override |
| 182 | + public List<WxDataCubeMsgResult> getUpstreamMsgMonth(Date beginDate, |
| 183 | + Date endDate) throws WxErrorException { |
| 184 | + String url = API_URL_PREFIX + "/getupstreammsgmonth"; |
| 185 | + JsonObject param = new JsonObject(); |
| 186 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 187 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 188 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 189 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 190 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 191 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 192 | + }.getType()); |
| 193 | + } |
| 194 | + |
| 195 | + @Override |
| 196 | + public List<WxDataCubeMsgResult> getUpstreamMsgDist(Date beginDate, |
| 197 | + Date endDate) throws WxErrorException { |
| 198 | + String url = API_URL_PREFIX + "/getupstreammsgdist"; |
| 199 | + JsonObject param = new JsonObject(); |
| 200 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 201 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 202 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 203 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 204 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 205 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 206 | + }.getType()); |
| 207 | + } |
| 208 | + |
| 209 | + @Override |
| 210 | + public List<WxDataCubeMsgResult> getUpstreamMsgDistWeek(Date beginDate, |
| 211 | + Date endDate) throws WxErrorException { |
| 212 | + String url = API_URL_PREFIX + "/getupstreammsgdistweek"; |
| 213 | + JsonObject param = new JsonObject(); |
| 214 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 215 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 216 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 217 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 218 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 219 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 220 | + }.getType()); |
| 221 | + } |
| 222 | + |
| 223 | + @Override |
| 224 | + public List<WxDataCubeMsgResult> getUpstreamMsgDistMonth(Date beginDate, |
| 225 | + Date endDate) throws WxErrorException { |
| 226 | + String url = API_URL_PREFIX + "/getupstreammsgdistmonth"; |
| 227 | + JsonObject param = new JsonObject(); |
| 228 | + param.addProperty("begin_date", WxMpService.SIMPLE_DATE_FORMAT.format(beginDate)); |
| 229 | + param.addProperty("end_date", WxMpService.SIMPLE_DATE_FORMAT.format(endDate)); |
| 230 | + String responseContent = this.wxMpService.post(url, param.toString()); |
| 231 | + this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); |
| 232 | + return WxMpGsonBuilder.INSTANCE.create().fromJson(new JsonParser().parse(responseContent).getAsJsonObject().get("list"), |
| 233 | + new TypeToken<List<WxDataCubeMsgResult>>() { |
| 234 | + }.getType()); |
| 235 | + } |
137 | 236 | }
|
0 commit comments