🎨 日志代码统一使用@Slf4j

This commit is contained in:
Binary Wang 2023-05-31 16:51:52 +08:00
parent 0640c10671
commit 142c3c857e
5 changed files with 54 additions and 48 deletions

View File

@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.util.requestexecuter.material;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
@ -15,8 +16,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@ -26,9 +25,9 @@ import java.io.IOException;
* @author ecoolper
* created on 2017/5/5
*/
@Slf4j
public class MaterialNewsInfoApacheHttpRequestExecutor
extends MaterialNewsInfoRequestExecutor<CloseableHttpClient, HttpHost> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
extends MaterialNewsInfoRequestExecutor<CloseableHttpClient, HttpHost> {
public MaterialNewsInfoApacheHttpRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
@ -45,7 +44,7 @@ public class MaterialNewsInfoApacheHttpRequestExecutor
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))));
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
this.logger.debug("响应原始数据:{}", responseContent);
log.debug("响应原始数据:{}", responseContent);
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);

View File

@ -6,8 +6,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.testbase.ApiTestModule;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@ -23,11 +22,9 @@ import java.io.IOException;
* @author <a href="https://gitee.com/jeequan/jeepay">jmdhappy</a>
*/
@Test
@Slf4j
@Guice(modules = ApiTestModule.class)
public class ComplaintServiceImplTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Inject
private WxPayService payService;
@ -35,6 +32,7 @@ public class ComplaintServiceImplTest {
/**
* 查询投诉单列表API
*
* @throws WxPayException
*/
@Test
@ -47,11 +45,12 @@ public class ComplaintServiceImplTest {
.endDate("2022-03-20")
.complaintedMchid(this.payService.getConfig().getMchId())
.build();
this.logger.info(this.payService.getComplaintsService().queryComplaints(request).toString());
log.info(this.payService.getComplaintsService().queryComplaints(request).toString());
}
/**
* 查询投诉单详情API
*
* @throws WxPayException
*/
@Test
@ -60,11 +59,12 @@ public class ComplaintServiceImplTest {
.newBuilder()
.complaintId(complaintId)
.build();
this.logger.info(this.payService.getComplaintsService().getComplaint(request).toString());
log.info(this.payService.getComplaintsService().getComplaint(request).toString());
}
/**
* 查询投诉协商历史API
*
* @throws WxPayException
*/
@Test
@ -75,11 +75,12 @@ public class ComplaintServiceImplTest {
.offset(0)
.limit(20)
.build();
this.logger.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString());
log.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString());
}
/**
* 创建投诉通知回调地址API
*
* @throws WxPayException
*/
@Test
@ -88,20 +89,22 @@ public class ComplaintServiceImplTest {
.newBuilder()
.url("https://jeepay.natapp4.cc")
.build();
this.logger.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString());
log.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString());
}
/**
* 查询投诉通知回调地址API
*
* @throws WxPayException
*/
@Test
public void testGetComplaintNotifyUrl() throws WxPayException {
this.logger.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString());
log.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString());
}
/**
* 更新投诉通知回调地址API
*
* @throws WxPayException
*/
@Test
@ -110,11 +113,12 @@ public class ComplaintServiceImplTest {
.newBuilder()
.url("https://jeepay1.natapp4.cc")
.build();
this.logger.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString());
log.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString());
}
/**
* 删除投诉通知回调地址API
*
* @throws WxPayException
*/
@Test
@ -124,6 +128,7 @@ public class ComplaintServiceImplTest {
/**
* 提交回复API
*
* @throws WxPayException
*/
@Test
@ -141,6 +146,7 @@ public class ComplaintServiceImplTest {
/**
* 反馈处理完成API
*
* @throws WxPayException
*/
@Test
@ -154,13 +160,14 @@ public class ComplaintServiceImplTest {
}
/**
* 商户上传反馈图片API
* 商户上传反馈图片API
*
* @throws WxPayException
* @throws IOException
*/
@Test
public void testUploadResponseImage() throws WxPayException, IOException {
String filePath="你的图片文件的路径地址";
public void testUploadResponseImage() throws WxPayException, IOException {
String filePath = "你的图片文件的路径地址";
// String filePath="WxJava/images/banners/wiki.jpg";
File file = new File(filePath);

View File

@ -6,6 +6,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.testbase.ApiTestModule;
import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Guice;
@ -23,6 +24,7 @@ import java.util.concurrent.TimeUnit;
*/
@Test
@Guice(modules = ApiTestModule.class)
@Slf4j
public class EntPayServiceImplTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -45,7 +47,7 @@ public class EntPayServiceImplTest {
.description("描述信息")
.build();
this.logger.info(this.payService.getEntPayService().entPay(request).toString());
log.info(this.payService.getEntPayService().entPay(request).toString());
}
/**
@ -55,7 +57,7 @@ public class EntPayServiceImplTest {
*/
@Test
public void testQueryEntPay() throws WxPayException {
this.logger.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
log.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
}
/**
@ -65,7 +67,7 @@ public class EntPayServiceImplTest {
*/
@Test
public void testGetPublicKey() throws Exception {
this.logger.info(this.payService.getEntPayService().getPublicKey());
log.info(this.payService.getEntPayService().getPublicKey());
}
/**
@ -83,7 +85,7 @@ public class EntPayServiceImplTest {
.partnerTradeNo("3")
.description("11")
.build());
this.logger.info(result.toString());
log.info(result.toString());
}
/**
@ -93,13 +95,13 @@ public class EntPayServiceImplTest {
*/
@Test
public void testQueryPayBank() throws Exception {
this.logger.info(this.payService.getEntPayService().queryPayBank("123").toString());
log.info(this.payService.getEntPayService().queryPayBank("123").toString());
}
/**
* 发送企业红包
*
* @throws Exception the exception
*/
@Test
@ -107,7 +109,7 @@ public class EntPayServiceImplTest {
EntPayRedpackRequest request = new EntPayRedpackRequest();
request.setMchId("1");
//商户单号
request.setMchBillNo(request.getMchId()+"20191202"+"1");
request.setMchBillNo(request.getMchId() + "20191202" + "1");
//企业微信corpid即为此appId
request.setWxAppId("1");
// request.setSenderName("1");
@ -125,11 +127,12 @@ public class EntPayServiceImplTest {
redpackResult = this.payService.getEntPayService().sendEnterpriseRedpack(request);
} catch (WxPayException e) {
}
this.logger.info(redpackResult.toString());
log.info(redpackResult.toString());
}
/**
* 查询企业红包
*
* @throws Exception
*/
@Test
@ -142,7 +145,7 @@ public class EntPayServiceImplTest {
try {
EntPayRedpackQueryResult result = this.payService.getEntPayService().queryEnterpriseRedpack(request);
this.logger.info(result.toString());
log.info(result.toString());
} catch (Exception e) {
}
TimeUnit.SECONDS.sleep(3);

View File

@ -6,16 +6,14 @@ import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.testbase.ApiTestModule;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@Test
@Slf4j
@Guice(modules = ApiTestModule.class)
public class ProfitSharingServiceImplTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Inject
private WxPayService payService;
@ -33,7 +31,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000431201910234736634272")
.receivers(instance.toJSONString())
.build();
this.logger.info(this.payService.getProfitSharingService().profitSharing(request).toString());
log.info(this.payService.getProfitSharingService().profitSharing(request).toString());
}
@Test
@ -49,7 +47,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010
.receivers(instance.toJSONString())
.build();
this.logger.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString());
log.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString());
}
@Test
@ -60,7 +58,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000441201910238267278073")
.description("分账完成")
.build();
this.logger.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString());
log.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString());
}
@Test
@ -74,7 +72,7 @@ public class ProfitSharingServiceImplTest {
.newBuilder()
.receiver(receiver.toJSONString())
.build();
this.logger.info(this.payService.getProfitSharingService().addReceiver(request).toString());
log.info(this.payService.getProfitSharingService().addReceiver(request).toString());
}
@Test
@ -85,7 +83,7 @@ public class ProfitSharingServiceImplTest {
.newBuilder()
.receiver(receiver.toJSONString())
.build();
this.logger.info(this.payService.getProfitSharingService().removeReceiver(request).toString());
log.info(this.payService.getProfitSharingService().removeReceiver(request).toString());
}
@Test
@ -96,8 +94,8 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000431201910234736634272")
.build();
ProfitSharingQueryResult result = this.payService.getProfitSharingService().profitSharingQuery(request);
this.logger.info(result.formatReceivers().toString());
this.logger.info(result.toString());
log.info(result.formatReceivers().toString());
log.info(result.toString());
}
@Test
@ -105,17 +103,17 @@ public class ProfitSharingServiceImplTest {
final String subMchId = "subMchid";
final ProfitSharingMerchantRatioQueryRequest request = new ProfitSharingMerchantRatioQueryRequest(subMchId);
final ProfitSharingMerchantRatioQueryResult result = payService.getProfitSharingService().profitSharingMerchantRatioQuery(request);
logger.info(result.toString());
log.info(result.toString());
}
@Test
public void testProfitSharingOrderAmountQuery() throws WxPayException {
public void testProfitSharingOrderAmountQuery() throws WxPayException {
final String transactionId = "4200000916202012281633853127";
final ProfitSharingOrderAmountQueryRequest request = ProfitSharingOrderAmountQueryRequest.newBuilder()
.transactionId(transactionId)
.build();
final ProfitSharingOrderAmountQueryResult result = payService.getProfitSharingService().profitSharingOrderAmountQuery(request);
logger.info(result.toString());
log.info(result.toString());
}
@Test
@ -129,7 +127,7 @@ public class ProfitSharingServiceImplTest {
.returnAmount(2)
.description("用户退款")
.build();
this.logger.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString());
log.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString());
}
@Test
@ -139,7 +137,7 @@ public class ProfitSharingServiceImplTest {
.outOrderNo("20191023154723316420060")
.outReturnNo("R2019102315")
.build();
this.logger.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString());
log.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString());
}
}

View File

@ -5,6 +5,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.testbase.ApiTestModule;
import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Guice;
@ -17,11 +18,9 @@ import org.testng.annotations.Test;
* @create 2022-04-26-22:33 PM
*/
@Test
@Slf4j
@Guice(modules = ApiTestModule.class)
public class ProfitSharingV3ServiceImplTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Inject
private WxPayService payService;
@ -33,6 +32,6 @@ public class ProfitSharingV3ServiceImplTest {
header.setNonce("Wechatpay-Nonce");
header.setSigned("Wechatpay-Signature");
String data = "body";
this.logger.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyData(data,header).toString());
log.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyData(data,header).toString());
}
}