Skip to content

Commit 142c3c8

Browse files
committed
🎨 日志代码统一使用@slf4j
1 parent 0640c10 commit 142c3c8

File tree

5 files changed

+54
-48
lines changed

5 files changed

+54
-48
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoApacheHttpRequestExecutor.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.chanjar.weixin.mp.util.requestexecuter.material;
22

33
import com.google.common.collect.ImmutableMap;
4+
import lombok.extern.slf4j.Slf4j;
45
import me.chanjar.weixin.common.enums.WxType;
56
import me.chanjar.weixin.common.error.WxError;
67
import me.chanjar.weixin.common.error.WxErrorException;
@@ -15,8 +16,6 @@
1516
import org.apache.http.client.methods.HttpPost;
1617
import org.apache.http.entity.StringEntity;
1718
import org.apache.http.impl.client.CloseableHttpClient;
18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
2019

2120
import java.io.IOException;
2221

@@ -26,9 +25,9 @@
2625
* @author ecoolper
2726
* created on 2017/5/5
2827
*/
28+
@Slf4j
2929
public class MaterialNewsInfoApacheHttpRequestExecutor
30-
extends MaterialNewsInfoRequestExecutor<CloseableHttpClient, HttpHost> {
31-
private final Logger logger = LoggerFactory.getLogger(this.getClass());
30+
extends MaterialNewsInfoRequestExecutor<CloseableHttpClient, HttpHost> {
3231

3332
public MaterialNewsInfoApacheHttpRequestExecutor(RequestHttp requestHttp) {
3433
super(requestHttp);
@@ -45,7 +44,7 @@ public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) th
4544
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))));
4645
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
4746
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
48-
this.logger.debug("响应原始数据:{}", responseContent);
47+
log.debug("响应原始数据:{}", responseContent);
4948
WxError error = WxError.fromJson(responseContent, WxType.MP);
5049
if (error.getErrorCode() != 0) {
5150
throw new WxErrorException(error);

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import com.github.binarywang.wxpay.service.WxPayService;
77
import com.github.binarywang.wxpay.testbase.ApiTestModule;
88
import com.google.inject.Inject;
9-
import org.slf4j.Logger;
10-
import org.slf4j.LoggerFactory;
9+
import lombok.extern.slf4j.Slf4j;
1110
import org.testng.annotations.Guice;
1211
import org.testng.annotations.Test;
1312

@@ -23,18 +22,17 @@
2322
* @author <a href="https://gitee.com/jeequan/jeepay">jmdhappy</a>
2423
*/
2524
@Test
25+
@Slf4j
2626
@Guice(modules = ApiTestModule.class)
2727
public class ComplaintServiceImplTest {
28-
29-
private final Logger logger = LoggerFactory.getLogger(this.getClass());
30-
3128
@Inject
3229
private WxPayService payService;
3330

3431
private static final String complaintId = "200231020220320120496109901";
3532

3633
/**
3734
* 查询投诉单列表API
35+
*
3836
* @throws WxPayException
3937
*/
4038
@Test
@@ -47,11 +45,12 @@ public void testQueryComplaints() throws WxPayException, BadPaddingException {
4745
.endDate("2022-03-20")
4846
.complaintedMchid(this.payService.getConfig().getMchId())
4947
.build();
50-
this.logger.info(this.payService.getComplaintsService().queryComplaints(request).toString());
48+
log.info(this.payService.getComplaintsService().queryComplaints(request).toString());
5149
}
5250

5351
/**
5452
* 查询投诉单详情API
53+
*
5554
* @throws WxPayException
5655
*/
5756
@Test
@@ -60,11 +59,12 @@ public void testGetComplaint() throws WxPayException, BadPaddingException {
6059
.newBuilder()
6160
.complaintId(complaintId)
6261
.build();
63-
this.logger.info(this.payService.getComplaintsService().getComplaint(request).toString());
62+
log.info(this.payService.getComplaintsService().getComplaint(request).toString());
6463
}
6564

6665
/**
6766
* 查询投诉协商历史API
67+
*
6868
* @throws WxPayException
6969
*/
7070
@Test
@@ -75,11 +75,12 @@ public void testQueryNegotiationHistorys() throws WxPayException {
7575
.offset(0)
7676
.limit(20)
7777
.build();
78-
this.logger.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString());
78+
log.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString());
7979
}
8080

8181
/**
8282
* 创建投诉通知回调地址API
83+
*
8384
* @throws WxPayException
8485
*/
8586
@Test
@@ -88,20 +89,22 @@ public void testAddComplaintNotifyUrl() throws WxPayException {
8889
.newBuilder()
8990
.url("https://jeepay.natapp4.cc")
9091
.build();
91-
this.logger.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString());
92+
log.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString());
9293
}
9394

9495
/**
9596
* 查询投诉通知回调地址API
97+
*
9698
* @throws WxPayException
9799
*/
98100
@Test
99101
public void testGetComplaintNotifyUrl() throws WxPayException {
100-
this.logger.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString());
102+
log.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString());
101103
}
102104

103105
/**
104106
* 更新投诉通知回调地址API
107+
*
105108
* @throws WxPayException
106109
*/
107110
@Test
@@ -110,11 +113,12 @@ public void testUpdateComplaintNotifyUrl() throws WxPayException {
110113
.newBuilder()
111114
.url("https://jeepay1.natapp4.cc")
112115
.build();
113-
this.logger.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString());
116+
log.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString());
114117
}
115118

116119
/**
117120
* 删除投诉通知回调地址API
121+
*
118122
* @throws WxPayException
119123
*/
120124
@Test
@@ -124,6 +128,7 @@ public void testDeleteComplaintNotifyUrl() throws WxPayException {
124128

125129
/**
126130
* 提交回复API
131+
*
127132
* @throws WxPayException
128133
*/
129134
@Test
@@ -141,6 +146,7 @@ public void testSubmitResponse() throws WxPayException {
141146

142147
/**
143148
* 反馈处理完成API
149+
*
144150
* @throws WxPayException
145151
*/
146152
@Test
@@ -154,13 +160,14 @@ public void testComplete() throws WxPayException {
154160
}
155161

156162
/**
157-
* 商户上传反馈图片API
163+
* 商户上传反馈图片API
164+
*
158165
* @throws WxPayException
159166
* @throws IOException
160167
*/
161168
@Test
162-
public void testUploadResponseImage() throws WxPayException, IOException {
163-
String filePath="你的图片文件的路径地址";
169+
public void testUploadResponseImage() throws WxPayException, IOException {
170+
String filePath = "你的图片文件的路径地址";
164171
// String filePath="WxJava/images/banners/wiki.jpg";
165172

166173
File file = new File(filePath);

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.github.binarywang.wxpay.service.WxPayService;
77
import com.github.binarywang.wxpay.testbase.ApiTestModule;
88
import com.google.inject.Inject;
9+
import lombok.extern.slf4j.Slf4j;
910
import org.slf4j.Logger;
1011
import org.slf4j.LoggerFactory;
1112
import org.testng.annotations.Guice;
@@ -23,6 +24,7 @@
2324
*/
2425
@Test
2526
@Guice(modules = ApiTestModule.class)
27+
@Slf4j
2628
public class EntPayServiceImplTest {
2729
private final Logger logger = LoggerFactory.getLogger(this.getClass());
2830

@@ -45,7 +47,7 @@ public void testEntPay() throws WxPayException {
4547
.description("描述信息")
4648
.build();
4749

48-
this.logger.info(this.payService.getEntPayService().entPay(request).toString());
50+
log.info(this.payService.getEntPayService().entPay(request).toString());
4951
}
5052

5153
/**
@@ -55,7 +57,7 @@ public void testEntPay() throws WxPayException {
5557
*/
5658
@Test
5759
public void testQueryEntPay() throws WxPayException {
58-
this.logger.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
60+
log.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
5961
}
6062

6163
/**
@@ -65,7 +67,7 @@ public void testQueryEntPay() throws WxPayException {
6567
*/
6668
@Test
6769
public void testGetPublicKey() throws Exception {
68-
this.logger.info(this.payService.getEntPayService().getPublicKey());
70+
log.info(this.payService.getEntPayService().getPublicKey());
6971
}
7072

7173
/**
@@ -83,7 +85,7 @@ public void testPayBank() throws Exception {
8385
.partnerTradeNo("3")
8486
.description("11")
8587
.build());
86-
this.logger.info(result.toString());
88+
log.info(result.toString());
8789
}
8890

8991
/**
@@ -93,21 +95,21 @@ public void testPayBank() throws Exception {
9395
*/
9496
@Test
9597
public void testQueryPayBank() throws Exception {
96-
this.logger.info(this.payService.getEntPayService().queryPayBank("123").toString());
98+
log.info(this.payService.getEntPayService().queryPayBank("123").toString());
9799
}
98100

99101

100-
101102
/**
102103
* 发送企业红包
104+
*
103105
* @throws Exception the exception
104106
*/
105107
@Test
106108
public void testSendEnterpriseRedpack() {
107109
EntPayRedpackRequest request = new EntPayRedpackRequest();
108110
request.setMchId("1");
109111
//商户单号
110-
request.setMchBillNo(request.getMchId()+"20191202"+"1");
112+
request.setMchBillNo(request.getMchId() + "20191202" + "1");
111113
//企业微信corpid即为此appId
112114
request.setWxAppId("1");
113115
// request.setSenderName("1");
@@ -125,11 +127,12 @@ public void testSendEnterpriseRedpack() {
125127
redpackResult = this.payService.getEntPayService().sendEnterpriseRedpack(request);
126128
} catch (WxPayException e) {
127129
}
128-
this.logger.info(redpackResult.toString());
130+
log.info(redpackResult.toString());
129131
}
130132

131133
/**
132134
* 查询企业红包
135+
*
133136
* @throws Exception
134137
*/
135138
@Test
@@ -142,7 +145,7 @@ public void testQueryEnterpriseRedpack() throws Exception {
142145

143146
try {
144147
EntPayRedpackQueryResult result = this.payService.getEntPayService().queryEnterpriseRedpack(request);
145-
this.logger.info(result.toString());
148+
log.info(result.toString());
146149
} catch (Exception e) {
147150
}
148151
TimeUnit.SECONDS.sleep(3);

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
import com.github.binarywang.wxpay.service.WxPayService;
77
import com.github.binarywang.wxpay.testbase.ApiTestModule;
88
import com.google.inject.Inject;
9-
import org.slf4j.Logger;
10-
import org.slf4j.LoggerFactory;
9+
import lombok.extern.slf4j.Slf4j;
1110
import org.testng.annotations.Guice;
1211
import org.testng.annotations.Test;
1312

1413
@Test
14+
@Slf4j
1515
@Guice(modules = ApiTestModule.class)
1616
public class ProfitSharingServiceImplTest {
17-
private final Logger logger = LoggerFactory.getLogger(this.getClass());
18-
1917
@Inject
2018
private WxPayService payService;
2119

@@ -33,7 +31,7 @@ public void testProfitSharing() throws WxPayException {
3331
.transactionId("4200000431201910234736634272")
3432
.receivers(instance.toJSONString())
3533
.build();
36-
this.logger.info(this.payService.getProfitSharingService().profitSharing(request).toString());
34+
log.info(this.payService.getProfitSharingService().profitSharing(request).toString());
3735
}
3836

3937
@Test
@@ -49,7 +47,7 @@ public void testMultiProfitSharing() throws WxPayException {
4947
.transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010
5048
.receivers(instance.toJSONString())
5149
.build();
52-
this.logger.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString());
50+
log.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString());
5351
}
5452

5553
@Test
@@ -60,7 +58,7 @@ public void testProfitSharingFinish() throws WxPayException {
6058
.transactionId("4200000441201910238267278073")
6159
.description("分账完成")
6260
.build();
63-
this.logger.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString());
61+
log.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString());
6462
}
6563

6664
@Test
@@ -74,7 +72,7 @@ public void testAddReceiver() throws WxPayException {
7472
.newBuilder()
7573
.receiver(receiver.toJSONString())
7674
.build();
77-
this.logger.info(this.payService.getProfitSharingService().addReceiver(request).toString());
75+
log.info(this.payService.getProfitSharingService().addReceiver(request).toString());
7876
}
7977

8078
@Test
@@ -85,7 +83,7 @@ public void testRemoveReceiver() throws WxPayException {
8583
.newBuilder()
8684
.receiver(receiver.toJSONString())
8785
.build();
88-
this.logger.info(this.payService.getProfitSharingService().removeReceiver(request).toString());
86+
log.info(this.payService.getProfitSharingService().removeReceiver(request).toString());
8987
}
9088

9189
@Test
@@ -96,26 +94,26 @@ public void testProfitSharingQuery() throws WxPayException {
9694
.transactionId("4200000431201910234736634272")
9795
.build();
9896
ProfitSharingQueryResult result = this.payService.getProfitSharingService().profitSharingQuery(request);
99-
this.logger.info(result.formatReceivers().toString());
100-
this.logger.info(result.toString());
97+
log.info(result.formatReceivers().toString());
98+
log.info(result.toString());
10199
}
102100

103101
@Test
104102
public void testProfitSharingMerchantRatioQuery() throws WxPayException {
105103
final String subMchId = "subMchid";
106104
final ProfitSharingMerchantRatioQueryRequest request = new ProfitSharingMerchantRatioQueryRequest(subMchId);
107105
final ProfitSharingMerchantRatioQueryResult result = payService.getProfitSharingService().profitSharingMerchantRatioQuery(request);
108-
logger.info(result.toString());
106+
log.info(result.toString());
109107
}
110108

111109
@Test
112-
public void testProfitSharingOrderAmountQuery() throws WxPayException {
110+
public void testProfitSharingOrderAmountQuery() throws WxPayException {
113111
final String transactionId = "4200000916202012281633853127";
114112
final ProfitSharingOrderAmountQueryRequest request = ProfitSharingOrderAmountQueryRequest.newBuilder()
115113
.transactionId(transactionId)
116114
.build();
117115
final ProfitSharingOrderAmountQueryResult result = payService.getProfitSharingService().profitSharingOrderAmountQuery(request);
118-
logger.info(result.toString());
116+
log.info(result.toString());
119117
}
120118

121119
@Test
@@ -129,7 +127,7 @@ public void testProfitSharingReturn() throws WxPayException {
129127
.returnAmount(2)
130128
.description("用户退款")
131129
.build();
132-
this.logger.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString());
130+
log.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString());
133131
}
134132

135133
@Test
@@ -139,7 +137,7 @@ public void testProfitSharingReturnQuery() throws WxPayException {
139137
.outOrderNo("20191023154723316420060")
140138
.outReturnNo("R2019102315")
141139
.build();
142-
this.logger.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString());
140+
log.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString());
143141
}
144142

145143
}

0 commit comments

Comments
 (0)