|
|
@@ -49,10 +49,10 @@ public class HttpService {
|
|
|
*
|
|
|
* @param username 账号
|
|
|
* @param password 密码
|
|
|
- * @param token 临时 token。通过无参的 {@link #identityToken(String)} 接口获取临时 token。
|
|
|
+ * @param token 临时 token。通过无参的 {@link #identityToken(String, String)} 接口获取临时 token。
|
|
|
* @return
|
|
|
*/
|
|
|
- public LoginResult login(String username, String password, String token) {
|
|
|
+ public LoginResult login(String token, String username, String password) {
|
|
|
String key = "hh43jii5e954eD54";
|
|
|
String encrypted = AESEncryption.encryptPassing(password, key);
|
|
|
|
|
|
@@ -82,10 +82,11 @@ public class HttpService {
|
|
|
* 2.1 好像可以不用通过登录,写死此值,绕过登录接口。
|
|
|
* 2.2 没有登录,也没有临时 token 的情况下,仅使用此参数可以获取正式 token。
|
|
|
*
|
|
|
- * @param tplatformId
|
|
|
+ * @param token 初次时为 null
|
|
|
+ * @param tplatformId 初次时为 null
|
|
|
* @return
|
|
|
*/
|
|
|
- public IdentityTokenResult identityToken(String tplatformId) {
|
|
|
+ public IdentityTokenResult identityToken(String token, String tplatformId) {
|
|
|
IdentityTokenParam param = new IdentityTokenParam();
|
|
|
|
|
|
param.setChannelCode("OffWeb");
|
|
|
@@ -96,8 +97,8 @@ public class HttpService {
|
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
|
- if (this.token != null) {
|
|
|
- httpHeaders.add("tkCarRequestToken", this.token);
|
|
|
+ if (token != null) {
|
|
|
+ httpHeaders.add("tkCarRequestToken", token);
|
|
|
}
|
|
|
|
|
|
IdentityTokenResult.Response response = client.request(HttpURL.identityToken, param, httpHeaders, IdentityTokenResult.Response.class);
|
|
|
@@ -108,17 +109,11 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- IdentityTokenResult data = response.getData();
|
|
|
-
|
|
|
- if (data != null) {
|
|
|
- token = data.getTkCarRequesttoken;
|
|
|
-
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("保存新 token:{}", token);
|
|
|
- }
|
|
|
- }
|
|
|
+ return response.getData();
|
|
|
+ }
|
|
|
|
|
|
- return data;
|
|
|
+ public IdentityTokenResult identityToken() {
|
|
|
+ return identityToken(null, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -158,12 +153,10 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- InitIdentityResult data = response.getData();
|
|
|
-
|
|
|
- return data;
|
|
|
+ return response.getData();
|
|
|
}
|
|
|
|
|
|
- public InitBasicDataResult initBasicData() {
|
|
|
+ public InitBasicDataResult initBasicData(String token) {
|
|
|
InitBasicDataParam param = new InitBasicDataParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
|
|
|
|
@@ -179,9 +172,9 @@ public class HttpService {
|
|
|
|
|
|
/**
|
|
|
* 03 获取省区市区数据
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 包含投保地区、车牌号码前缀、证件类型
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 可以当前 token 校验的功能,当 token 过期时返回 status 为 0 message 为 您的登录状态已过期,请重新登录!
|
|
|
*
|
|
|
* @param tplatformId
|
|
|
@@ -208,24 +201,11 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- String data = response.getData();
|
|
|
-
|
|
|
- if (data == null || data.isBlank()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 解密
|
|
|
- String json = AESDecryptor.decrypt(data);
|
|
|
-
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("TaiKangHttpClient basicInfo body: {}", json);
|
|
|
- }
|
|
|
-
|
|
|
- BasicInfoResult.Response response1 = JsonUtil.readObjcet(json, BasicInfoResult.Response.class);
|
|
|
+ BasicInfoResult.Response decrypt = decrypt(response, BasicInfoResult.Response.class);
|
|
|
|
|
|
- checkResponseUnknownField(response1);
|
|
|
+ checkResponseUnknownField(decrypt);
|
|
|
|
|
|
- return response1.getData();
|
|
|
+ return decrypt.getData();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -249,9 +229,7 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- List<CarTypeResult> data = response.getData();
|
|
|
-
|
|
|
- return data;
|
|
|
+ return response.getData();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -400,24 +378,11 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- String data = response.getData();
|
|
|
-
|
|
|
- if (data == null || data.isBlank()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 解密
|
|
|
- String json = AESDecryptor.decrypt(data);
|
|
|
+ CarModelinfoQueryResult.Response decrypt = decrypt(response, CarModelinfoQueryResult.Response.class);
|
|
|
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("TaiKangHttpClient carModelinfoQuery decrypt body: {}", json);
|
|
|
- }
|
|
|
-
|
|
|
- CarModelinfoQueryResult.Response response1 = JsonUtil.readObjcet(json, CarModelinfoQueryResult.Response.class);
|
|
|
-
|
|
|
- checkResponseUnknownField(response1);
|
|
|
+ checkResponseUnknownField(decrypt);
|
|
|
|
|
|
- return response1.getData();
|
|
|
+ return decrypt.getData();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -615,7 +580,7 @@ public class HttpService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public InitQuotationResult initQuotationFlag2(String token, String tplatformId, String orderId) {
|
|
|
+ public InitQuotationResult initQuotationFlag2(String token, String orderId) {
|
|
|
InitQuotationParam param = new InitQuotationParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
|
param.setOrderID(orderId);
|
|
|
@@ -658,7 +623,7 @@ public class HttpService {
|
|
|
/**
|
|
|
* @return
|
|
|
*/
|
|
|
- public FloatNoticeGetResult floatNoticeGet(String token, String tplatformId, String orderId) {
|
|
|
+ public FloatNoticeGetResult floatNoticeGet(String token, String orderId) {
|
|
|
FloatNoticeGetParam param = new FloatNoticeGetParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
|
param.setOrderID(orderId);
|
|
|
@@ -684,7 +649,6 @@ public class HttpService {
|
|
|
param.setTplatformId(tplatformId);
|
|
|
param.setTplatLoginKey(tplatLoginKey);
|
|
|
|
|
|
-
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("tkCarRequestToken", token);
|
|
|
|
|
|
@@ -692,14 +656,7 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- // 解密
|
|
|
- String json = AESDecryptor.decrypt(response.getData());
|
|
|
-
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("TaiKangHttpClient initQuotation decrypt body: {}", json);
|
|
|
- }
|
|
|
-
|
|
|
- InitProposalResult.Response response1 = JsonUtil.readObjcet(json, InitProposalResult.Response.class);
|
|
|
+ InitProposalResult.Response response1 = decrypt(response, InitProposalResult.Response.class);
|
|
|
|
|
|
checkResponseUnknownField(response1);
|
|
|
|
|
|
@@ -713,7 +670,7 @@ public class HttpService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<EngageEngageQueryResult> engageEngageQuery(String token, String tplatformId, String fromId, String orderId, EngageEngageQueryParam.Privy privy) {
|
|
|
+ public List<EngageEngageQueryResult> engageEngageQuery(String token, String fromId, String orderId, EngageEngageQueryParam.Privy privy) {
|
|
|
EngageEngageQueryParam param = new EngageEngageQueryParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
|
param.setFromId(fromId);
|
|
|
@@ -723,7 +680,6 @@ public class HttpService {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("tkCarRequestToken", token);
|
|
|
|
|
|
-
|
|
|
EngageEngageQueryResult.Response response = client.request(HttpURL.engageEngageQuery, param, httpHeaders, EngageEngageQueryResult.Response.class);
|
|
|
|
|
|
return response.getData();
|
|
|
@@ -732,7 +688,7 @@ public class HttpService {
|
|
|
/**
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, String> initFindRiskConfig(String token, String tplatformId) {
|
|
|
+ public Map<String, String> initFindRiskConfig(String token) {
|
|
|
InitFindRiskConfigParam param = new InitFindRiskConfigParam();
|
|
|
param.setConfigcode("SDMessageControl");
|
|
|
param.setRiskcode("08");
|
|
|
@@ -741,7 +697,6 @@ public class HttpService {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("tkCarRequestToken", token);
|
|
|
|
|
|
-
|
|
|
InitFindRiskConfigResult.Response response = client.request(HttpURL.initFindRiskConfig, param, httpHeaders, InitFindRiskConfigResult.Response.class);
|
|
|
|
|
|
return response.getData();
|
|
|
@@ -758,7 +713,6 @@ public class HttpService {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("tkCarRequestToken", token);
|
|
|
|
|
|
-
|
|
|
GroupOrderGetNewNoticeStatusResult.Response response = client.request(HttpURL.groupOrderGetNewNoticeStatus, param, httpHeaders, GroupOrderGetNewNoticeStatusResult.Response.class);
|
|
|
|
|
|
return response.getData();
|
|
|
@@ -769,7 +723,7 @@ public class HttpService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private EntranceResult entranceForDecrypt(String token, String tplatformId, String fromId, String orderId) {
|
|
|
+ private EntranceResult entranceForDecrypt(String token, String fromId, String orderId) {
|
|
|
EntranceParam param = new EntranceParam();
|
|
|
param.setChannelCode("OffWeb");
|
|
|
param.setFromID(fromId);
|
|
|
@@ -786,14 +740,7 @@ public class HttpService {
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- // 解密
|
|
|
- String json = AESDecryptor.decrypt(response.getData());
|
|
|
-
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("TaiKangHttpClient entranceForDecrypt decrypt body: {}", json);
|
|
|
- }
|
|
|
-
|
|
|
- EntranceResult.Response response1 = JsonUtil.readObjcet(json, EntranceResult.Response.class);
|
|
|
+ EntranceResult.Response response1 = decrypt(response, EntranceResult.Response.class);
|
|
|
|
|
|
checkResponseUnknownField(response1);
|
|
|
|
|
|
@@ -820,7 +767,7 @@ public class HttpService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private <B> B entranceForJson(String token, Object param, String actionType, Class<B> responseType) {
|
|
|
+ private <B> B entranceForJson(String token, Object param, String actionType, Class<B> responseType) {
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.add("Actiontype", actionType);
|
|
|
httpHeaders.add("tkCarRequestToken", token);
|
|
|
@@ -843,11 +790,32 @@ public class HttpService {
|
|
|
param.setOrderID(orderId);
|
|
|
param.setInsureInfo(insureInfo);
|
|
|
|
|
|
- EntranceResult.Response response = entranceForJson(param, "000012", EntranceResult.Response.class);
|
|
|
+ EntranceResult.Response response = entranceForJson(token, param, "000012", EntranceResult.Response.class);
|
|
|
|
|
|
return response.getData();
|
|
|
}
|
|
|
|
|
|
+ private <T> T decrypt(StringResponse response, Class<T> clazz) {
|
|
|
+ if (response == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String data = response.getData();
|
|
|
+
|
|
|
+ if (data == null || data.isBlank()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解密
|
|
|
+ String json = AESDecryptor.decrypt(data);
|
|
|
+
|
|
|
+ if (logger.isInfoEnabled()) {
|
|
|
+ logger.info("decrypt body: {}", json);
|
|
|
+ }
|
|
|
+
|
|
|
+ return JsonUtil.readObjcet(json, clazz);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* entrance 返回的数据是 json 的情况
|
|
|
*
|
|
|
@@ -861,22 +829,15 @@ public class HttpService {
|
|
|
param.setOrderID(orderId);
|
|
|
param.setIdcardOcrFlag("0"); // todo
|
|
|
|
|
|
- StringResponse response = entranceForJson(param, "000038", StringResponse.class);
|
|
|
+ StringResponse response = entranceForJson(token, param, "000038", StringResponse.class);
|
|
|
|
|
|
checkResponseUnknownField(response);
|
|
|
|
|
|
- // 解密
|
|
|
- String json = AESDecryptor.decrypt(response.getData());
|
|
|
+ TKEntranceFor000038Result.Response decrypt = decrypt(response, TKEntranceFor000038Result.Response.class);
|
|
|
|
|
|
- if (logger.isInfoEnabled()) {
|
|
|
- logger.info("TaiKangHttpClient entranceFor000038 decrypt body: {}", json);
|
|
|
- }
|
|
|
-
|
|
|
- TKEntranceFor000038Result.Response response1 = JsonUtil.readObjcet(json, TKEntranceFor000038Result.Response.class);
|
|
|
+ checkResponseUnknownField(decrypt);
|
|
|
|
|
|
- checkResponseUnknownField(response1);
|
|
|
-
|
|
|
- return response1.getData();
|
|
|
+ return decrypt.getData();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -904,7 +865,7 @@ public class HttpService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String carCheckAttorneyList(String token, String tplatformId, String proposalNo) {
|
|
|
+ public String carCheckAttorneyList(String token, String proposalNo) {
|
|
|
CarCheckAttorneyListParam param = new CarCheckAttorneyListParam();
|
|
|
param.setProposalNo(proposalNo);
|
|
|
|