初始化同程接口
This commit is contained in:
parent
9f4f77fcc7
commit
510ea39b50
|
@ -22,15 +22,16 @@ public class LYPostRequest {
|
||||||
|
|
||||||
private String mySecret = L_Y_SECRET;
|
private String mySecret = L_Y_SECRET;
|
||||||
|
|
||||||
public <T> T post(String url, LYBaseRequest jsonRequest, Class<T> responseType) {
|
public <T> T post(String url, LYBaseRequest jsonRequest, Class<T> responseType) {
|
||||||
String token = lyTokenRequest.loadToken();
|
String token = lyTokenRequest.loadToken();
|
||||||
jsonRequest.setRandom(UUID.randomUUID().toString());
|
jsonRequest.setRandom(UUID.randomUUID().toString());
|
||||||
jsonRequest.setTimestamp(String.valueOf(System.currentTimeMillis()));
|
jsonRequest.setTimestamp(String.valueOf(System.currentTimeMillis()));
|
||||||
jsonRequest.setAccessToken(token);
|
jsonRequest.setAccessToken(token);
|
||||||
String postDataMd5 = md5(postRequest.gson().toJson(jsonRequest));
|
jsonRequest.setEncrypt(false);
|
||||||
|
String json = postRequest.gson().toJson(jsonRequest);
|
||||||
|
String postDataMd5 = md5(json);
|
||||||
String finallySign = md5(postDataMd5 + mySecret);
|
String finallySign = md5(postDataMd5 + mySecret);
|
||||||
jsonRequest.setSign(finallySign);
|
return postRequest.post(url + "?sign=" + finallySign, jsonRequest, responseType);
|
||||||
return postRequest.post(url, jsonRequest, responseType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String md5(String input) {
|
public static String md5(String input) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class LYUserRequest {
|
||||||
EmployeeEntity employeeEntity = user2LYEmployee(currentUser);
|
EmployeeEntity employeeEntity = user2LYEmployee(currentUser);
|
||||||
EmployeeRequest employeeData = new EmployeeRequest();
|
EmployeeRequest employeeData = new EmployeeRequest();
|
||||||
employeeData.setParam(employeeEntity);
|
employeeData.setParam(employeeEntity);
|
||||||
UserResponse post = postRequest.post(userUrl, employeeData, UserResponse.class);
|
UserResponse post = postRequest.post(userUrl , employeeData, UserResponse.class);
|
||||||
return post.isSuccess();
|
return post.isSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,5 @@ public class LYBaseRequest {
|
||||||
private String random;
|
private String random;
|
||||||
private String timestamp;
|
private String timestamp;
|
||||||
private String sign;
|
private String sign;
|
||||||
|
private boolean isEncrypt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class EmployeeEntity {
|
||||||
private int workingState;
|
private int workingState;
|
||||||
private String birthday;
|
private String birthday;
|
||||||
private String credentialExpireDate;
|
private String credentialExpireDate;
|
||||||
private int credentialType;
|
// private int credentialType;
|
||||||
private int addTravellerAllowed;
|
private int addTravellerAllowed;
|
||||||
private String employeeCode;
|
private String employeeCode;
|
||||||
private String costCenter;
|
private String costCenter;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EmployeeRequest extends LYBaseRequest {
|
public class EmployeeRequest extends LYBaseRequest {
|
||||||
private boolean isEncrypt;
|
|
||||||
private EmployeeEntity param;
|
private EmployeeEntity param;
|
||||||
private List<CostCenter> costCenterList;
|
private List<CostCenter> costCenterList;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue