diff --git a/README.md b/README.md
index 5e20f533675f31897c934c539948d0e71fbbab22..88abf71e8d5d4b3a2839805155aa144e5fb1d80c 100644
--- a/README.md
+++ b/README.md
@@ -103,7 +103,7 @@ authRequest.login("code");
|
| [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | 参考文档 |
|
| [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | 参考文档 |
|
| [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 待续 |
-|
| [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 待续 |
+|
| [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 参考文档 |
## 后续开发计划
diff --git a/src/main/java/me/zhyd/oauth/config/AuthConfig.java b/src/main/java/me/zhyd/oauth/config/AuthConfig.java
index 6b0cb4d778c93091244cdb37c266e10971a9ef16..df47d049e7504e6dbaf5840a991f9c7c8dad510f 100644
--- a/src/main/java/me/zhyd/oauth/config/AuthConfig.java
+++ b/src/main/java/me/zhyd/oauth/config/AuthConfig.java
@@ -6,6 +6,8 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
/**
+ * JustAuth配置类
+ *
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
@@ -15,8 +17,17 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class AuthConfig {
+
+ /**
+ * 客户端id:对应个平台的appKey
+ */
private String clientId;
+
+ /**
+ * 客户端Secret:对应个平台的appSecret
+ */
private String clientSecret;
+
/**
* 登录成功后的回调地址
*/
diff --git a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java b/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
index 7cff8e2240f5e4902a1bf5ad54b5a85eac258fbd..993dadf8b790a845bc5f911317ac695c43d29ee7 100644
--- a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
+++ b/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
@@ -356,18 +356,33 @@ public enum ApiUrl {
@Override
public String refresh() {
- return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
+ return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
}
};
+ /**
+ * 授权的api
+ */
public abstract String authorize();
+ /**
+ * 获取accessToken的api
+ */
public abstract String accessToken();
+ /**
+ * 获取用户信息的api
+ */
public abstract String userInfo();
+ /**
+ * 取消授权的api
+ */
public abstract String revoke();
+ /**
+ * 刷新授权的api
+ */
public abstract String refresh();
}
diff --git a/src/main/java/me/zhyd/oauth/model/AuthUserGender.java b/src/main/java/me/zhyd/oauth/model/AuthUserGender.java
index f708a6d6df1eb7c07eb48055e57792a222981277..be3a98898589a42a860c3c8f9f32416780168025 100644
--- a/src/main/java/me/zhyd/oauth/model/AuthUserGender.java
+++ b/src/main/java/me/zhyd/oauth/model/AuthUserGender.java
@@ -1,5 +1,7 @@
package me.zhyd.oauth.model;
+import java.util.Arrays;
+
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
@@ -19,10 +21,12 @@ public enum AuthUserGender {
if (code == null) {
return UNKNOW;
}
- if ("m".equals(code) || "男".equals(code) || "1".equals(code) || "male".equalsIgnoreCase(code) || "F".equalsIgnoreCase(code)) {
+ String[] males = {"m", "男", "1", "male", "F"};
+ if (Arrays.asList(males).contains(code)) {
return MALE;
}
- if ("f".equals(code) || "女".equals(code) || "0".equals(code) || "female".equalsIgnoreCase(code)) {
+ String[] females = {"f", "女", "0", "female"};
+ if (Arrays.asList(females).contains(code)) {
return FEMALE;
}
return UNKNOW;
diff --git a/src/test/java/me/zhyd/oauth/AuthRequestTest.java b/src/test/java/me/zhyd/oauth/AuthRequestTest.java
index 8b67f23d424f74cf3ff6dce3b6721527f1c8c868..8e32bf70418bd96f4cff3ff6730e261a161a9c0a 100644
--- a/src/test/java/me/zhyd/oauth/AuthRequestTest.java
+++ b/src/test/java/me/zhyd/oauth/AuthRequestTest.java
@@ -116,6 +116,19 @@ public class AuthRequestTest {
authRequest.login("code");
}
+ @Test
+ public void qqTest() {
+ AuthRequest authRequest = new AuthQqRequest(AuthConfig.builder()
+ .clientId("clientId")
+ .clientSecret("clientSecret")
+ .redirectUri("redirectUri")
+ .build());
+ // 返回授权页面,可自行调整
+ String url = authRequest.authorize();
+ // 授权登录后会返回一个code,用这个code进行登录
+ AuthResponse login = authRequest.login("code");
+ }
+
@Test
public void wechatTest() {
AuthRequest authRequest = new AuthWeChatRequest(AuthConfig.builder()