Skip to content

Commit 730ac24

Browse files
committed
🎨 优化小程序配置类的javadoc
1 parent ebb9ccd commit 730ac24

File tree

1 file changed

+87
-77
lines changed
  • weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config

1 file changed

+87
-77
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public interface WxMaConfig {
1616
default void setUpdateAccessTokenBefore(Consumer<WxAccessTokenEntity> updateAccessTokenBefore) {}
1717

1818
/**
19-
* Gets access token.
19+
* 获取当前的 access_token
2020
*
21-
* @return the access token
21+
* @return 当前的 access_token 字符串
2222
*/
2323
String getAccessToken();
2424

@@ -30,26 +30,28 @@ default void setUpdateAccessTokenBefore(Consumer<WxAccessTokenEntity> updateAcce
3030
// endregion
3131

3232
/**
33-
* Gets access token lock.
33+
* 获取用于保护 access_token 更新的锁(线程安全用)
3434
*
35-
* @return the access token lock
35+
* @return access_token 的锁对象
3636
*/
3737
Lock getAccessTokenLock();
3838

3939
/**
40-
* Is access token expired boolean.
40+
* 判断 access_token 是否已过期
4141
*
42-
* @return the boolean
42+
* @return 如果已过期则返回 true,否则返回 false
4343
*/
4444
boolean isAccessTokenExpired();
4545

46-
/** 强制将access token过期掉 */
46+
/**
47+
* 强制将 access_token 标记为已过期
48+
*/
4749
void expireAccessToken();
4850

4951
/**
5052
* 应该是线程安全的
5153
*
52-
* @param accessToken 要更新的WxAccessToken对象
54+
* @param accessToken 要更新的 WxAccessToken 对象
5355
*/
5456
default void updateAccessToken(WxAccessToken accessToken) {
5557
updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
@@ -58,8 +60,8 @@ default void updateAccessToken(WxAccessToken accessToken) {
5860
/**
5961
* 应该是线程安全的
6062
*
61-
* @param accessToken 新的accessToken值
62-
* @param expiresInSeconds 过期时间,以秒为单位
63+
* @param accessToken 新的 access_token 值
64+
* @param expiresInSeconds 过期时间,单位:秒
6365
*/
6466
void updateAccessToken(String accessToken, int expiresInSeconds);
6567

@@ -75,229 +77,237 @@ default void updateAccessTokenProcessor(String accessToken, int expiresInSeconds
7577
default void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) {}
7678

7779
/**
78-
* Gets jsapi ticket.
80+
* 获取当前的 JSAPI ticket
7981
*
80-
* @return the jsapi ticket
82+
* @return 当前的 jsapi_ticket 字符串
8183
*/
8284
String getJsapiTicket();
8385

8486
/**
85-
* Gets jsapi ticket lock.
87+
* 获取用于保护 jsapi_ticket 更新的锁(线程安全用)
8688
*
87-
* @return the jsapi ticket lock
89+
* @return jsapi_ticket 的锁对象
8890
*/
8991
Lock getJsapiTicketLock();
9092

9193
/**
92-
* Is jsapi ticket expired boolean.
94+
* 判断 jsapi_ticket 是否已过期
9395
*
94-
* @return the boolean
96+
* @return 如果已过期则返回 true,否则返回 false
9597
*/
9698
boolean isJsapiTicketExpired();
9799

98-
/** 强制将jsapi ticket过期掉 */
100+
/**
101+
* 强制将 jsapi_ticket 标记为已过期
102+
*/
99103
void expireJsapiTicket();
100104

101105
/**
102106
* 应该是线程安全的
103107
*
104-
* @param jsapiTicket 新的jsapi ticket值
105-
* @param expiresInSeconds 过期时间,以秒为单位
108+
* @param jsapiTicket 新的 jsapi_ticket 值
109+
* @param expiresInSeconds 过期时间,单位:秒
106110
*/
107111
void updateJsapiTicket(String jsapiTicket, int expiresInSeconds);
108112

109113
/**
110-
* 卡券api_ticket.
114+
* 获取卡券相关的 api_ticket
111115
*
112-
* @return the card api ticket
116+
* @return 卡券 api_ticket 字符串
113117
*/
114118
String getCardApiTicket();
115119

116120
/**
117-
* Gets card api ticket lock.
121+
* 获取用于保护卡券 api_ticket 更新的锁(线程安全用)
118122
*
119-
* @return the card api ticket lock
123+
* @return 卡券 api_ticket 的锁对象
120124
*/
121125
Lock getCardApiTicketLock();
122126

123127
/**
124-
* Is card api ticket expired boolean.
128+
* 判断卡券 api_ticket 是否已过期
125129
*
126-
* @return the boolean
130+
* @return 如果已过期则返回 true,否则返回 false
127131
*/
128132
boolean isCardApiTicketExpired();
129133

130-
/** 强制将卡券api ticket过期掉. */
134+
/**
135+
* 强制将卡券 api_ticket 标记为已过期
136+
*/
131137
void expireCardApiTicket();
132138

133139
/**
134-
* 应该是线程安全的.
140+
* 应该是线程安全的
135141
*
136-
* @param apiTicket 新的卡券api ticket值
137-
* @param expiresInSeconds 过期时间,以秒为单位
142+
* @param apiTicket 新的卡券 api_ticket 值
143+
* @param expiresInSeconds 过期时间,单位:秒
138144
*/
139145
void updateCardApiTicket(String apiTicket, int expiresInSeconds);
140146

141147
/**
142-
* Gets appid.
148+
* 获取小程序的 appId
143149
*
144-
* @return the appid
150+
* @return 小程序的 appId
145151
*/
146152
String getAppid();
147153

148154
/**
149-
* Gets secret.
155+
* 获取小程序的 secret
150156
*
151-
* @return the secret
157+
* @return 小程序的 secret
152158
*/
153159
String getSecret();
154160

155161
/**
156-
* Gets token.
162+
* 获取消息校验用的 token
157163
*
158-
* @return the token
164+
* @return token 字符串
159165
*/
160166
String getToken();
161167

162168
/**
163-
* Gets aes key.
169+
* 获取消息加解密使用的 AES 密钥(用于消息加密/解密)
164170
*
165-
* @return the aes key
171+
* @return AES 密钥字符串
166172
*/
167173
String getAesKey();
168174

169175
/**
170-
* Gets original id.
176+
* 获取原始 ID(原始公众号/小程序 ID)
171177
*
172-
* @return the original id
178+
* @return 原始 ID 字符串
173179
*/
174180
String getOriginalId();
175181

176182
/**
177-
* Gets cloud env.
183+
* 获取云开发(Cloud)环境标识
178184
*
179-
* @return the cloud env
185+
* @return 云环境 ID
180186
*/
181187
String getCloudEnv();
182188

183189
/**
184-
* Gets msg data format.
190+
* 获取消息数据的格式(例如 json)
185191
*
186-
* @return the msg data format
192+
* @return 消息数据格式字符串
187193
*/
188194
String getMsgDataFormat();
189195

190196
/**
191-
* Gets expires time.
197+
* 获取 access_token 或 ticket 的过期时间(时间戳)
192198
*
193-
* @return the expires time
199+
* @return 过期时间的毫秒时间戳
194200
*/
195201
long getExpiresTime();
196202

197203
/**
198-
* Gets http proxy host.
204+
* 获取 HTTP 代理主机
199205
*
200-
* @return the http proxy host
206+
* @return 代理主机名或 IP
201207
*/
202208
String getHttpProxyHost();
203209

204210
/**
205-
* Gets http proxy port.
211+
* 获取 HTTP 代理端口
206212
*
207-
* @return the http proxy port
213+
* @return 代理端口号
208214
*/
209215
int getHttpProxyPort();
210216

211217
/**
212-
* Gets http proxy username.
218+
* 获取 HTTP 代理用户名
213219
*
214-
* @return the http proxy username
220+
* @return 代理用户名
215221
*/
216222
String getHttpProxyUsername();
217223

218224
/**
219-
* Gets http proxy password.
225+
* 获取 HTTP 代理密码
220226
*
221-
* @return the http proxy password
227+
* @return 代理密码
222228
*/
223229
String getHttpProxyPassword();
224230

225231
/**
226-
* http 请求重试间隔
232+
* HTTP 请求重试间隔(毫秒)
227233
*
228234
* <pre>
229235
* {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setRetrySleepMillis(int)}
230236
* </pre>
237+
*
238+
* @return 重试间隔,单位:毫秒
231239
*/
232240
int getRetrySleepMillis();
233241

234242
/**
235-
* http 请求最大重试次数
243+
* HTTP 请求最大重试次数
236244
*
237245
* <pre>
238246
* {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setMaxRetryTimes(int)}
239247
* </pre>
248+
*
249+
* @return 最大重试次数
240250
*/
241251
int getMaxRetryTimes();
242252

243253
/**
244-
* http client builder
254+
* 获取用于创建 HTTP 客户端的 ApacheHttpClientBuilder
245255
*
246-
* @return ApacheHttpClientBuilder apache http client builder
256+
* @return ApacheHttpClientBuilder 实例
247257
*/
248258
ApacheHttpClientBuilder getApacheHttpClientBuilder();
249259

250260
/**
251-
* 是否自动刷新token
261+
* 是否在 token 失效时自动刷新
252262
*
253-
* @return the boolean
263+
* @return 如果自动刷新则返回 true,否则返回 false
254264
*/
255265
boolean autoRefreshToken();
256266

257267
/**
258-
* 设置自定义的apiHost地址
259-
* 具体取值,可以参考https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html
268+
* 设置自定义的 apiHost 地址
269+
* 具体取值,可以参考 <a href="https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html">API 域名文档</a>
260270
*
261-
* @param apiHostUrl api域名地址
271+
* @param apiHostUrl api 域名地址
262272
*/
263273
void setApiHostUrl(String apiHostUrl);
264274

265275
/**
266-
* 获取自定义的apiHost地址,用于替换原请求中的https://api.weixin.qq.com
267-
* 具体取值,可以参考https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html
276+
* 获取自定义的 apiHost 地址,用于替换原请求中的 <a href="https://api.weixin.qq.com">https://api.weixin.qq.com</a>
277+
* 具体取值,可以参考 <a href="https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html">API 域名文档</a>
268278
*
269-
* @return 自定义的api域名地址
279+
* @return 自定义的 api 域名地址
270280
*/
271281
String getApiHostUrl();
272282

273283
/**
274-
* 获取自定义的获取accessToken地址,用于向自定义统一服务获取accessToken
284+
* 获取自定义的获取 accessToken 地址,用于向自定义统一服务获取 accessToken
275285
*
276-
* @return 自定义的获取accessToken地址
286+
* @return 自定义的获取 accessToken 地址
277287
*/
278288
String getAccessTokenUrl();
279289

280290
/**
281-
* 设置自定义的获取accessToken地址 可用于设置获取accessToken的自定义服务
291+
* 设置自定义的获取 accessToken 地址,可用于设置获取 accessToken 的自定义服务
282292
*
283-
* @param accessTokenUrl 自定义的获取accessToken地址
293+
* @param accessTokenUrl 自定义的获取 accessToken 地址
284294
*/
285295
void setAccessTokenUrl(String accessTokenUrl);
286296

287297
/**
288-
* 服务端API签名用到的RSA私钥【pkcs8格式,会以 -----BEGIN PRIVATE KEY-----开头, 'BEGIN RSA PRIVATE
289-
* KEY'的是pkcs1格式,需要转换(可用openssl转换)。 设置参考:
290-
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html
298+
* 服务端 API 签名用到的 RSA 私钥(pkcs8 格式,会以 -----BEGIN PRIVATE KEY----- 开头,
299+
* 'BEGIN RSA PRIVATE KEY' 的是 pkcs1 格式,需要转换(可用 openssl 转换)。设置参考:
300+
* <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html">API 签名文档</a>
291301
*
292-
* @return rsa private key string
302+
* @return RSA 私钥字符串(pkcs8 格式)
293303
*/
294304
String getApiSignatureRsaPrivateKey();
295305

296306
/**
297-
* 服务端API签名用到的AES密钥
298-
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html
307+
* 服务端 API 签名用到的 AES 密钥
308+
* <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html">API 签名文档</a>
299309
*
300-
* @return aes key string
310+
* @return AES 密钥字符串
301311
*/
302312
String getApiSignatureAesKey();
303313

@@ -307,6 +317,6 @@ default void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) {}
307317
/** 密钥对应的序号 */
308318
String getApiSignatureRsaPrivateKeySn();
309319

310-
/** 密钥对应的小程序ID (普通小程序同 appId, 托管第三方平台的是 componentAppId) */
320+
/** 密钥对应的小程序 ID(普通小程序为 appId,托管第三方平台为 componentAppId) */
311321
String getWechatMpAppid();
312322
}

0 commit comments

Comments
 (0)