Skip to content

Commit 01cee5a

Browse files
committed
refactor: modify method
1 parent b613cf5 commit 01cee5a

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public interface WxCpService {
4343
*/
4444
public void userAuthenticated(String userId) throws WxErrorException;
4545

46+
/**
47+
* 获取access_token, 不强制刷新access_token
48+
* @see #getAccessToken(boolean)
49+
* @return
50+
* @throws WxErrorException
51+
*/
52+
public String getAccessToken() throws WxErrorException;
53+
4654
/**
4755
* <pre>
4856
* 获取access_token,本方法线程安全

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public void userAuthenticated(String userId) throws WxErrorException {
7171
execute(new SimpleGetRequestExecutor(), url, null);
7272
}
7373

74+
public String getAccessToken() throws WxErrorException {
75+
return getAccessToken(false);
76+
}
77+
7478
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
7579
if (forceRefresh) {
7680
wxCpConfigStorage.expireAccessToken();

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ public interface WxMpService {
2828
* @return
2929
*/
3030
public boolean checkSignature(String timestamp, String nonce, String signature);
31-
31+
32+
/**
33+
* 获取access_token, 不强制刷新access_token
34+
* @see #getAccessToken(boolean)
35+
* @return
36+
* @throws WxErrorException
37+
*/
38+
public String getAccessToken() throws WxErrorException;
39+
3240
/**
3341
* <pre>
3442
* 获取access_token,本方法线程安全
@@ -46,6 +54,14 @@ public interface WxMpService {
4654
*/
4755
public String getAccessToken(boolean forceRefresh) throws WxErrorException;
4856

57+
/**
58+
* 获得jsapi_ticket,不强制刷新jsapi_ticket
59+
* @see #getJsapiTicket(boolean)
60+
* @return
61+
* @throws WxErrorException
62+
*/
63+
public String getJsapiTicket() throws WxErrorException;
64+
4965
/**
5066
* <pre>
5167
* 获得jsapi_ticket

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ public boolean checkSignature(String timestamp, String nonce, String signature)
6868
return false;
6969
}
7070
}
71-
71+
72+
public String getAccessToken() throws WxErrorException {
73+
return getAccessToken(false);
74+
}
75+
7276
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
7377
if (forceRefresh) {
7478
wxMpConfigStorage.expireAccessToken();
@@ -106,6 +110,9 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
106110
return wxMpConfigStorage.getAccessToken();
107111
}
108112

113+
public String getJsapiTicket() throws WxErrorException {
114+
return getJsapiTicket(false);
115+
}
109116

110117
public String getJsapiTicket(boolean forceRefresh) throws WxErrorException {
111118
if (forceRefresh) {

0 commit comments

Comments
 (0)