提交 334574df 编写于 作者: 不合群的混子's avatar 不合群的混子

添加用户在第三方系统中的唯一主键

上级 d978ca9b
...@@ -24,4 +24,8 @@ public class AuthUser { ...@@ -24,4 +24,8 @@ public class AuthUser {
private AuthUserGender gender; private AuthUserGender gender;
private AuthSource source; private AuthSource source;
private AuthToken token; private AuthToken token;
/**
* 用户第三方系统的唯一id
*/
private String uuid;
} }
...@@ -64,6 +64,7 @@ public class AuthQqRequest extends BaseAuthRequest { ...@@ -64,6 +64,7 @@ public class AuthQqRequest extends BaseAuthRequest {
.nickname(object.getString("nickname")) .nickname(object.getString("nickname"))
.avatar(avatar) .avatar(avatar)
.location(object.getString("province") + "-" + object.getString("city")) .location(object.getString("province") + "-" + object.getString("city"))
.uuid(openId)
.gender(AuthUserGender.getRealGender(object.getString("gender"))) .gender(AuthUserGender.getRealGender(object.getString("gender")))
.token(authToken) .token(authToken)
.source(AuthSource.QQ) .source(AuthSource.QQ)
......
...@@ -31,8 +31,7 @@ public class AuthWeChatRequest extends BaseAuthRequest { ...@@ -31,8 +31,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
String accessTokenUrl = UrlBuilder.getWeChatAccessTokenUrl(config.getClientId(), config.getClientSecret(), code); String accessTokenUrl = UrlBuilder.getWeChatAccessTokenUrl(config.getClientId(), config.getClientSecret(), code);
HttpResponse response = HttpRequest.get(accessTokenUrl).execute(); HttpResponse response = HttpRequest.get(accessTokenUrl).execute();
JSONObject object = JSONObject.parseObject(response.body()); JSONObject object = JSONObject.parseObject(response.body());
if (!object.containsKey("access_token") || !object.containsKey("openid") || !object if (!object.containsKey("access_token") || !object.containsKey("openid") || !object.containsKey("refresh_token")) {
.containsKey("refresh_token")) {
throw new AuthException("Unable to get access_token or openid or refresh_token from wechat using code [" + code + "]"); throw new AuthException("Unable to get access_token or openid or refresh_token from wechat using code [" + code + "]");
} }
return AuthToken.builder() return AuthToken.builder()
...@@ -58,6 +57,7 @@ public class AuthWeChatRequest extends BaseAuthRequest { ...@@ -58,6 +57,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
.nickname(object.getString("nickname")) .nickname(object.getString("nickname"))
.avatar(object.getString("headimgurl")) .avatar(object.getString("headimgurl"))
.location(object.getString("country") + "-" + object.getString("province") + "-" + object.getString("city")) .location(object.getString("country") + "-" + object.getString("province") + "-" + object.getString("city"))
.uuid(openId)
.gender(AuthUserGender.getRealGender(object.getString("sex"))) .gender(AuthUserGender.getRealGender(object.getString("sex")))
.token(authToken) .token(authToken)
.source(AuthSource.WECHAT) .source(AuthSource.WECHAT)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册