同步代码
This commit is contained in:
parent
d1acab14e5
commit
92fe207374
|
@ -5,14 +5,21 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class UserDTO {
|
||||
private String accountId;
|
||||
private String mobile;
|
||||
private String userName;
|
||||
private String uid;
|
||||
private String email;
|
||||
|
||||
private UserData attributes;
|
||||
private String id;
|
||||
// 构造函数和其他方法(getter 和 setter)可以根据需要添加
|
||||
|
||||
// Getter 和 Setter 方法
|
||||
|
||||
@Data
|
||||
public static class UserData{
|
||||
private String user_name;
|
||||
private String mobile;
|
||||
private String account_no;
|
||||
private long token_gtime;
|
||||
private String token_expired;
|
||||
private String email;
|
||||
private String user_uid;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
@ -59,13 +60,15 @@ public class PailaLoginStrategy implements LoginStrategy {
|
|||
|
||||
log.info("开始执行登录");
|
||||
List<NameValuePair> parameters = Arrays.asList(
|
||||
new BasicNameValuePair("grant_type", "authorization_code"),
|
||||
new BasicNameValuePair("client_id", clientId),
|
||||
new BasicNameValuePair("client_secret", clientSecret),
|
||||
new BasicNameValuePair("redirect_uri", redirectUri),
|
||||
new BasicNameValuePair("code", code)
|
||||
new BasicNameValuePair("code", code),
|
||||
new BasicNameValuePair("redirect_uri", redirectUri)
|
||||
|
||||
);
|
||||
|
||||
HttpGet getMethod = getRequest("/profile/oauth2/accessToken", parameters);
|
||||
HttpPost getMethod = postRequest("/esc-sso/oauth2.0/accessToken", parameters);
|
||||
return LoginStrategy.getAccessTokenMethod(getMethod, "access_token");
|
||||
}
|
||||
|
||||
|
@ -77,7 +80,7 @@ public class PailaLoginStrategy implements LoginStrategy {
|
|||
new BasicNameValuePair("access_token", accessToken)
|
||||
);
|
||||
|
||||
HttpGet getMethodUserInfo = getRequest("/profile/oauth2/profile", userInfoParams);
|
||||
HttpGet getMethodUserInfo = getRequest("/esc-sso/oauth2.0/profile", userInfoParams);
|
||||
|
||||
String userInfoResBody = null;
|
||||
HttpClient client = HttpClients.createDefault();
|
||||
|
@ -91,7 +94,7 @@ public class PailaLoginStrategy implements LoginStrategy {
|
|||
if (userDTO == null) {
|
||||
throw new NotFoundException(NOT_FOUND);
|
||||
}
|
||||
return userDTO.getUid();
|
||||
return userDTO.getAttributes().getAccount_no();
|
||||
}
|
||||
|
||||
private HttpGet getRequest(String path, List<NameValuePair> parameters) {
|
||||
|
@ -106,4 +109,17 @@ public class PailaLoginStrategy implements LoginStrategy {
|
|||
request.setHeader("Content-Type", "application/json");
|
||||
return request;
|
||||
}
|
||||
|
||||
private HttpPost postRequest(String path, List<NameValuePair> parameters) {
|
||||
String userInfoUrl = null;
|
||||
try {
|
||||
userInfoUrl = new URIBuilder(baseUrl).setPath(path)
|
||||
.setParameters(parameters).build().toString();
|
||||
} catch (URISyntaxException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
HttpPost request = new HttpPost(userInfoUrl);
|
||||
request.setHeader("Content-Type", "application/json");
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ chint:
|
|||
database: itinerary_booking
|
||||
username: tripbook
|
||||
password: W@Xgf25d&lRk*L0X#
|
||||
url: https://gxdev03.chint.com/businesstravel/
|
||||
url: https://gxdev03.chint.com/businesstravelhome/
|
||||
logging:
|
||||
level:
|
||||
org.springframework.jdbc.core.JdbcTemplate: DEBUG
|
||||
|
@ -56,8 +56,8 @@ FSSC:
|
|||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
client-secret: 7368bcec4c0f004c40585f6ed1087d887897
|
||||
redirect-url: https://gxdev03.chint.com/businesstravel/
|
||||
base-url: http://signin-test.chint.com
|
||||
redirect-url: https://gxdev03.chint.com/businesstravelhome/*.*
|
||||
base-url: https://signin-test.chint.com
|
||||
token-name: token
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ chint:
|
|||
database: itinerary_booking
|
||||
username: root
|
||||
password: 123456
|
||||
url: https://gxdev03.chint.com/businesstravel/
|
||||
url: https://gxdev03.chint.com/businesstravelhome/
|
||||
|
||||
cTrip:
|
||||
baseUrl: https://ct.ctrip.com
|
||||
|
@ -26,6 +26,6 @@ FSSC:
|
|||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
client-secret: 7368bcec4c0f004c40585f6ed1087d887897
|
||||
redirect-url: https://gxdev03.chint.com/businesstravel/
|
||||
base-url: http://signin-test.chint.com
|
||||
redirect-url: https://gxdev03.chint.com/businesstravelhome/*.*
|
||||
base-url: https://signin-test.chint.com
|
||||
token-name: token
|
||||
|
|
|
@ -21,7 +21,7 @@ chint:
|
|||
database: itinerary_booking
|
||||
username: tripbook
|
||||
password: W@Xgf25d&lRk*L0X#
|
||||
url: https://gxdev03.chint.com/businesstravel/
|
||||
url: https://gxdev03.chint.com/businesstravelhome/
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
@ -45,8 +45,8 @@ FSSC:
|
|||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
client-secret: 7368bcec4c0f004c40585f6ed1087d887897
|
||||
redirect-url: https://gxdev03.chint.com/businesstravel/
|
||||
base-url: http://signin-test.chint.com
|
||||
redirect-url: https://gxdev03.chint.com/businesstravelhome/*.*
|
||||
base-url: https://signin-test.chint.com
|
||||
token-name: token
|
||||
|
||||
bpm:
|
||||
|
|
Loading…
Reference in New Issue