初始化同程接口

This commit is contained in:
lulz1 2024-02-01 14:46:23 +08:00
parent 9f4f77fcc7
commit 510ea39b50
5 changed files with 9 additions and 7 deletions

View File

@ -22,15 +22,16 @@ public class LYPostRequest {
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();
jsonRequest.setRandom(UUID.randomUUID().toString());
jsonRequest.setTimestamp(String.valueOf(System.currentTimeMillis()));
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);
jsonRequest.setSign(finallySign);
return postRequest.post(url, jsonRequest, responseType);
return postRequest.post(url + "?sign=" + finallySign, jsonRequest, responseType);
}
public static String md5(String input) {

View File

@ -34,7 +34,7 @@ public class LYUserRequest {
EmployeeEntity employeeEntity = user2LYEmployee(currentUser);
EmployeeRequest employeeData = new EmployeeRequest();
employeeData.setParam(employeeEntity);
UserResponse post = postRequest.post(userUrl, employeeData, UserResponse.class);
UserResponse post = postRequest.post(userUrl , employeeData, UserResponse.class);
return post.isSuccess();
}

View File

@ -8,4 +8,5 @@ public class LYBaseRequest {
private String random;
private String timestamp;
private String sign;
private boolean isEncrypt;
}

View File

@ -24,7 +24,7 @@ public class EmployeeEntity {
private int workingState;
private String birthday;
private String credentialExpireDate;
private int credentialType;
// private int credentialType;
private int addTravellerAllowed;
private String employeeCode;
private String costCenter;

View File

@ -7,7 +7,7 @@ import java.util.List;
@Data
public class EmployeeRequest extends LYBaseRequest {
private boolean isEncrypt;
private EmployeeEntity param;
private List<CostCenter> costCenterList;