Skip to content

Commit 4505110

Browse files
committed
🎨 规范化代码
1 parent a5a375e commit 4505110

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import me.chanjar.weixin.common.error.WxErrorException;
44
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
55
import me.chanjar.weixin.cp.bean.WxCpUserDetail;
6-
import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificatioInformation;
6+
import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo;
77

88
/**
99
* <pre>
@@ -138,17 +138,13 @@ public interface WxCpOAuth2Service {
138138

139139
/**
140140
* 获取用户二次验证信息
141-
*
142-
* https://qyapi.weixin.qq.com/cgi-bin/auth/get_tfa_info?access_token=ACCESS_TOKEN
143-
*
144-
* @author Hugo
145-
* @date 2023/12/14 10:29
146-
* @param code 用户进入二次验证页面时,企业微信颁发的code,每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
147-
* @return me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificatioInformation 二次验证授权码,开发者可以调用通过二次验证接口,解锁企业微信终端.tfa_code有效期五分钟,且只能使用一次。
148-
*
141+
* <p>
142+
* api: https://qyapi.weixin.qq.com/cgi-bin/auth/get_tfa_info?access_token=ACCESS_TOKEN
149143
* 权限说明:仅『通讯录同步』或者自建应用可调用,如用自建应用调用,用户需要在二次验证范围和应用可见范围内。
150-
*
151144
* 并发限制:20
145+
*
146+
* @param code 用户进入二次验证页面时,企业微信颁发的code,每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
147+
* @return me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo 二次验证授权码,开发者可以调用通过二次验证接口,解锁企业微信终端.tfa_code有效期五分钟,且只能使用一次。
152148
*/
153-
WxCpSecondVerificatioInformation get_tfa_info(String code) throws WxErrorException;
149+
WxCpSecondVerificationInfo getTfaInfo(String code) throws WxErrorException;
154150
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import me.chanjar.weixin.cp.api.WxCpService;
1111
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
1212
import me.chanjar.weixin.cp.bean.WxCpUserDetail;
13-
import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificatioInformation;
13+
import me.chanjar.weixin.cp.bean.workbench.WxCpSecondVerificationInfo;
1414
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1515

1616
import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.*;
@@ -123,11 +123,9 @@ public WxCpOauth2UserInfo getAuthUserInfo(String code) throws WxErrorException {
123123
}
124124

125125
@Override
126-
public WxCpSecondVerificatioInformation get_tfa_info(String code) throws WxErrorException {
127-
JsonObject param = new JsonObject();
128-
param.addProperty("code", code);
126+
public WxCpSecondVerificationInfo getTfaInfo(String code) throws WxErrorException {
129127
String responseText = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_TFA_INFO),
130-
param.toString());
131-
return WxCpGsonBuilder.create().fromJson(responseText, WxCpSecondVerificatioInformation.class);
128+
GsonHelper.buildJsonObject("code", code));
129+
return WxCpGsonBuilder.create().fromJson(responseText, WxCpSecondVerificationInfo.class);
132130
}
133131
}
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
package me.chanjar.weixin.cp.bean.workbench;
22

3+
import com.google.gson.annotations.SerializedName;
34
import lombok.AllArgsConstructor;
45
import lombok.Builder;
56
import lombok.Data;
67
import lombok.NoArgsConstructor;
78
import lombok.experimental.Accessors;
89

10+
import java.io.Serializable;
11+
912
/**
1013
* @author Hugo
1114
* <pre>
1215
* 获取用户二次验证信息的结果类
1316
* </pre>
1417
* <p>
15-
* 文档1:https://developer.work.weixin.qq.com/document/path/99499
18+
* <a href="https://developer.work.weixin.qq.com/document/path/99499">文档</a>
1619
*/
1720
@Data
1821
@Accessors(chain = true)
1922
@NoArgsConstructor
2023
@AllArgsConstructor
2124
@Builder
22-
public class WxCpSecondVerificatioInformation {
25+
public class WxCpSecondVerificationInfo implements Serializable {
2326
private static final long serialVersionUID = -4301564507150486556L;
2427

2528
private String userId;
26-
private String tfa_code;
29+
30+
@SerializedName("tfa_code")
31+
private String tfaCode;
2732
}

0 commit comments

Comments
 (0)