Browse Source

去掉多余重复的日志输出

master
BinaryWang 8 years ago
parent
commit
7478361824
2 changed files with 9 additions and 58 deletions
  1. +6
    -34
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java
  2. +3
    -24
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java

+ 6
- 34
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java View File

@@ -1,32 +1,21 @@
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 me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult;
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.bean.datacube.*;
import org.apache.commons.lang3.time.FastDateFormat;

import java.text.Format;
import java.util.Date;
import java.util.List;

/**
* Created by Binary Wang on 2016/8/23.
* @author binarywang (https://github.com/binarywang)
*/
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");
@@ -44,7 +33,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeUserSummary.fromJson(responseContent);
}

@@ -55,7 +43,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeUserCumulate.fromJson(responseContent);
}

@@ -66,7 +53,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleResult.fromJson(responseContent);
}

@@ -77,7 +63,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleTotal.fromJson(responseContent);
}

@@ -88,7 +73,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleResult.fromJson(responseContent);
}

@@ -99,7 +83,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleResult.fromJson(responseContent);
}

@@ -110,7 +93,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleResult.fromJson(responseContent);
}

@@ -121,7 +103,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeArticleResult.fromJson(responseContent);
}

@@ -133,7 +114,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -145,7 +125,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -157,7 +136,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -169,7 +147,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -181,7 +158,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -193,7 +169,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -205,7 +180,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeMsgResult.fromJson(responseContent);
}

@@ -217,7 +191,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeInterfaceResult.fromJson(responseContent);
}

@@ -229,7 +202,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService {
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 WxDataCubeInterfaceResult.fromJson(responseContent);
}
}

+ 3
- 24
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java View File

@@ -1,16 +1,9 @@
package me.chanjar.weixin.mp.api.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;

import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
@@ -18,6 +11,9 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
*
@@ -25,8 +21,6 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
* Created by Binary Wang on 2016/9/2.
*/
public class WxMpUserTagServiceImpl implements WxMpUserTagService {
protected final Logger log = LoggerFactory
.getLogger(WxMpDataCubeServiceImpl.class);
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags";

private WxMpService wxMpService;
@@ -44,8 +38,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.add("tag", tagJson);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
return WxUserTag.fromJson(responseContent);
}

@@ -54,8 +46,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
String url = API_URL_PREFIX + "/get";

String responseContent = this.wxMpService.get(url, null);
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, "[empty]",
responseContent);
return WxUserTag.listFromJson(responseContent);
}

@@ -70,7 +60,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.add("tag", tagJson);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), responseContent);
WxError wxError = WxError.fromJson(responseContent);
if (wxError.getErrorCode() == 0) {
return true;
@@ -89,8 +78,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.add("tag", tagJson);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
WxError wxError = WxError.fromJson(responseContent);
if (wxError.getErrorCode() == 0) {
return true;
@@ -109,8 +96,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.addProperty("next_openid", StringUtils.trimToEmpty(nextOpenid));

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
return WxTagListUser.fromJson(responseContent);
}

@@ -128,8 +113,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.add("openid_list", openidArrayJson);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
WxError wxError = WxError.fromJson(responseContent);
if (wxError.getErrorCode() == 0) {
return true;
@@ -152,8 +135,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.add("openid_list", openidArrayJson);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
WxError wxError = WxError.fromJson(responseContent);
if (wxError.getErrorCode() == 0) {
return true;
@@ -170,8 +151,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
json.addProperty("openid", openid);

String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);

return WxMpGsonBuilder.create().fromJson(
new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"),


Loading…
Cancel
Save