Skip to content

Commit 6e1d7fc

Browse files
committed
🎨 规范化部分代码格式
1 parent c6a4f45 commit 6e1d7fc

8 files changed

Lines changed: 64 additions & 51 deletions

File tree

quality-checks/google_checks.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<property name="max" value="120"/>
2828
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
2929
</module>
30-
<module name="AvoidStarImport"/>
3130
<module name="OneTopLevelClass"/>
3231
<module name="NoLineWrap"/>
3332
<module name="EmptyBlock">

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,36 @@
3636
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.*;
3737

3838
/**
39+
* .
40+
*
3941
* @author chanjarster
4042
*/
4143
@Slf4j
4244
public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestHttp<H, P> {
43-
private WxCpUserService userService = new WxCpUserServiceImpl(this);
44-
private WxCpChatService chatService = new WxCpChatServiceImpl(this);
45+
private WxCpUserService userService = new WxCpUserServiceImpl(this);
46+
private WxCpChatService chatService = new WxCpChatServiceImpl(this);
4547
private WxCpDepartmentService departmentService = new WxCpDepartmentServiceImpl(this);
46-
private WxCpMediaService mediaService = new WxCpMediaServiceImpl(this);
47-
private WxCpMenuService menuService = new WxCpMenuServiceImpl(this);
48-
private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this);
49-
private WxCpTagService tagService = new WxCpTagServiceImpl(this);
50-
private WxCpAgentService agentService = new WxCpAgentServiceImpl(this);
51-
private WxCpOaService oaService = new WxCpOaServiceImpl(this);
52-
private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
48+
private WxCpMediaService mediaService = new WxCpMediaServiceImpl(this);
49+
private WxCpMenuService menuService = new WxCpMenuServiceImpl(this);
50+
private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this);
51+
private WxCpTagService tagService = new WxCpTagServiceImpl(this);
52+
private WxCpAgentService agentService = new WxCpAgentServiceImpl(this);
53+
private WxCpOaService oaService = new WxCpOaServiceImpl(this);
54+
private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
5355
private WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this);
5456

5557
/**
56-
* 全局的是否正在刷新access token的锁
58+
* 全局的是否正在刷新access token的锁.
5759
*/
5860
protected final Object globalAccessTokenRefreshLock = new Object();
5961

6062
/**
61-
* 全局的是否正在刷新jsapi_ticket的锁
63+
* 全局的是否正在刷新jsapi_ticket的锁.
6264
*/
6365
protected final Object globalJsapiTicketRefreshLock = new Object();
6466

6567
/**
66-
* 全局的是否正在刷新agent的jsapi_ticket的锁
68+
* 全局的是否正在刷新agent的jsapi_ticket的锁.
6769
*/
6870
protected final Object globalAgentJsapiTicketRefreshLock = new Object();
6971

@@ -72,7 +74,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
7274
private WxSessionManager sessionManager = new StandardSessionManager();
7375

7476
/**
75-
* 临时文件目录
77+
* 临时文件目录.
7678
*/
7779
private File tmpDirFile;
7880
private int retrySleepMillis = 1000;
@@ -183,8 +185,8 @@ public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorEx
183185
params.put("js_code", jsCode);
184186
params.put("grant_type", "authorization_code");
185187

186-
String result = this.get(this.configStorage.getApiUrl(JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params));
187-
return WxCpMaJsCode2SessionResult.fromJson(result);
188+
final String url = this.configStorage.getApiUrl(JSCODE_TO_SESSION);
189+
return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params)));
188190
}
189191

190192
@Override

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpTpServiceImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.util.Map;
2727

2828
/**
29+
* .
30+
*
2931
* @author zhenjun cai
3032
*/
3133
@Slf4j
@@ -73,7 +75,7 @@ public String getSuiteTicket() throws WxErrorException {
7375

7476
@Override
7577
public String getSuiteTicket(boolean forceRefresh) throws WxErrorException {
76-
// suite ticket由微信服务器推送,不能强制刷新
78+
// suite ticket由微信服务器推送,不能强制刷新
7779
// if (forceRefresh) {
7880
// this.configStorage.expireSuiteTicket();
7981
// }
@@ -93,8 +95,8 @@ public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorEx
9395
params.put("js_code", jsCode);
9496
params.put("grant_type", "authorization_code");
9597

96-
String result = this.get(configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params));
97-
return WxCpMaJsCode2SessionResult.fromJson(result);
98+
final String url = configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION);
99+
return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params)));
98100
}
99101

100102

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public WxCpAgent get(Integer agentId) throws WxErrorException {
3636
throw new IllegalArgumentException("缺少agentid参数");
3737
}
3838

39-
String responseContent = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId), null);
40-
return WxCpAgent.fromJson(responseContent);
39+
final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId);
40+
return WxCpAgent.fromJson(this.mainService.get(url, null));
4141
}
4242

4343
@Override

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpChatServiceImpl.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ public String chatCreate(String name, String owner, List<String> users, String c
4343
if (StringUtils.isNotBlank(chatId)) {
4444
data.put("chatid", chatId);
4545
}
46-
String result = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_CREATE), WxGsonBuilder.create().toJson(data));
46+
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_CREATE);
47+
String result = this.cpService.post(url, WxGsonBuilder.create().toJson(data));
4748
return new JsonParser().parse(result).getAsJsonObject().get("chatid").getAsString();
4849
}
4950

5051
@Override
5152
public String create(String name, String owner, List<String> users, String chatId) throws WxErrorException {
52-
return chatCreate(name, owner, users, chatId);
53+
return this.chatCreate(name, owner, users, chatId);
5354
}
5455

5556
@Override
@@ -72,24 +73,27 @@ public void chatUpdate(String chatId, String name, String owner, List<String> us
7273
data.put("del_user_list", usersToDelete);
7374
}
7475

75-
this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_UPDATE), WxGsonBuilder.create().toJson(data));
76+
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_UPDATE);
77+
this.cpService.post(url, WxGsonBuilder.create().toJson(data));
7678
}
7779

7880
@Override
79-
public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException {
81+
public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete)
82+
throws WxErrorException {
8083
chatUpdate(chatId, name, owner, usersToAdd, usersToDelete);
8184
}
8285

8386
@Override
8487
public WxCpChat chatGet(String chatId) throws WxErrorException {
85-
String result = this.cpService.get(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_GET_CHATID + chatId), null);
86-
return WxCpGsonBuilder.create()
87-
.fromJson(JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString(), WxCpChat.class);
88+
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_GET_CHATID + chatId);
89+
String result = this.cpService.get(url, null);
90+
final String chatInfo = JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString();
91+
return WxCpGsonBuilder.create().fromJson(chatInfo, WxCpChat.class);
8892
}
8993

9094
@Override
9195
public WxCpChat get(String chatId) throws WxErrorException {
92-
return chatGet(chatId);
96+
return this.chatGet(chatId);
9397
}
9498

9599
@Override

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ public WxCpExternalContactServiceImpl(WxCpService mainService) {
2020

2121
@Override
2222
public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException {
23-
String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId), null);
24-
23+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId);
24+
String responseContent = this.mainService.get(url, null);
2525
return WxCpUserExternalContactInfo.fromJson(responseContent);
2626
}
2727

2828
@Override
2929
public List<String> listExternalContacts(String userId) throws WxErrorException {
30-
String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId), null);
31-
WxCpUserExternalContactList list = WxCpUserExternalContactList.fromJson(responseContent);
32-
return list.getExternalUserId();
30+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId);
31+
String responseContent = this.mainService.get(url, null);
32+
return WxCpUserExternalContactList.fromJson(responseContent).getExternalUserId();
3333
}
3434

3535
@Override
3636
public List<String> listFollowUser() throws WxErrorException {
37-
String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(GET_FOLLOW_USER_LIST), null);
38-
WxCpUserWithExternalPermission list = WxCpUserWithExternalPermission.fromJson(responseContent);
39-
return list.getFollowUser();
37+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_FOLLOW_USER_LIST);
38+
String responseContent = this.mainService.get(url, null);
39+
return WxCpUserWithExternalPermission.fromJson(responseContent).getFollowUser();
4040
}
4141
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import me.chanjar.weixin.common.util.fs.FileUtils;
77
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor;
88
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
9+
import me.chanjar.weixin.common.util.http.RequestExecutor;
910
import me.chanjar.weixin.cp.api.WxCpMediaService;
1011
import me.chanjar.weixin.cp.api.WxCpService;
1112
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
@@ -59,8 +60,8 @@ public File getJssdkFile(String mediaId) throws WxErrorException {
5960

6061
@Override
6162
public String uploadImg(File file) throws WxErrorException {
62-
final WxMediaUploadResult result = this.mainService
63-
.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD), file);
64-
return result.getUrl();
63+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD);
64+
return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file)
65+
.getUrl();
6566
}
6667
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
2323

2424
/**
25+
* .
26+
*
2527
* @author Element
2628
* @date 2019-04-06 11:20
2729
*/
@@ -60,7 +62,8 @@ public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date st
6062

6163
jsonObject.add("useridlist", jsonArray);
6264

63-
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA), jsonObject.toString());
65+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA);
66+
String responseContent = this.mainService.post(url, jsonObject.toString());
6467
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
6568
return WxCpGsonBuilder.create()
6669
.fromJson(
@@ -89,7 +92,8 @@ public List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> user
8992
jsonObject.addProperty("datetime", datetime.getTime() / 1000L);
9093
jsonObject.add("useridlist", jsonArray);
9194

92-
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION), jsonObject.toString());
95+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION);
96+
String responseContent = this.mainService.post(url, jsonObject.toString());
9397
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
9498

9599
return WxCpGsonBuilder.create()
@@ -109,12 +113,14 @@ public WxCpApprovalDataResult getApprovalData(Date startTime, Date endTime, Long
109113
jsonObject.addProperty("next_spnum", nextSpnum);
110114
}
111115

112-
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA), jsonObject.toString());
116+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA);
117+
String responseContent = this.mainService.post(url, jsonObject.toString());
113118
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class);
114119
}
115120

116121
@Override
117-
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException {
122+
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
123+
throws WxErrorException {
118124
JsonObject jsonObject = new JsonObject();
119125

120126
if (offset == null) {
@@ -141,14 +147,13 @@ public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer
141147
jsonObject.addProperty("end_time", endtimestamp);
142148
}
143149

144-
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD), jsonObject.toString());
150+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD);
151+
String responseContent = this.mainService.post(url, jsonObject.toString());
145152
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
146153

147-
return WxCpGsonBuilder.create()
148-
.fromJson(
149-
tmpJsonElement.getAsJsonObject().get("record"),
150-
new TypeToken<List<WxCpDialRecord>>() {
151-
}.getType()
152-
);
154+
return WxCpGsonBuilder.create().fromJson(tmpJsonElement.getAsJsonObject().get("record"),
155+
new TypeToken<List<WxCpDialRecord>>() {
156+
}.getType()
157+
);
153158
}
154159
}

0 commit comments

Comments
 (0)