Przeglądaj źródła

添加泰康 调整 identityToken 接口

wlq 1 rok temu
rodzic
commit
7ef684e626

+ 21 - 0
tenant/insurance/quotation-taikang/README.md

@@ -0,0 +1,21 @@
+泰康保险接口抓包说明
+==================================================
+
+## 1、登录及获取token
+
+步骤:
+1. 先通过 `/rest/controller/identity` 接口获取一个 `初始token`,参数如下固定值即可:
+    ```json
+    { "channelCode":"OffWeb" }
+    ```
+2. 调登录接口 `/rest/tplatform/login`:参数格式如下:
+    ```json
+    { "userName":"Tgengchenjie", "channelCode":"OffWeb", "password":"CI3NVut7IQUhVnsef1Cp8w==" }
+    ```
+    并携带上 `初始token` 的请求头:`tkcarrequesttoken: 初始token值`。
+3. 和第一步一样,调 `/rest/controller/identity` 接口申请 `正式token`,参数格式如下:
+    ```json
+    { "channelCode":"OffWeb" }
+    ```
+   还是需要携带上 `初始token` 的请求头:`tkcarrequesttoken: 初始token值`。
+4. 之后的所有请求不再使用 `初始token`,而是一直使用 `正式token`,所有的请求都要携带上 `正式token` 的请求头:`tkcarrequesttoken: 正式token`。

+ 2 - 1
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/client/HttpURL.java

@@ -2,7 +2,8 @@ package com.jzg.quotation.taikang.client;
 
 public interface HttpURL {
     String host = "http://car.tk.cn";
-    String identityLogin = host + "/carSelfService/rest/controller/identity";
+    String login = host + "/carSelfService/rest/tplatform/login";
+    String identityToken = host + "/carSelfService/rest/controller/identity";
     String identityInit = host + "/carSelfService/rest/init/identify";
     String basicInfo = host + "/carSelfService/rest/init/basicInfo";
     /**

+ 1 - 1
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/entity/IdentityLoginParam.java → tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/entity/IdentityTokenParam.java

@@ -9,7 +9,7 @@ import lombok.Setter;
  */
 @Setter
 @Getter
-public class IdentityLoginParam {
+public class IdentityTokenParam {
     private String channelCode;
 
     private String tplatformId;

+ 2 - 2
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/entity/IdentityLoginResult.java → tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/entity/IdentityTokenResult.java

@@ -6,8 +6,8 @@ import lombok.Setter;
 
 @Setter
 @Getter
-public class IdentityLoginResult {
-    public static final class Response extends BaseResponse<IdentityLoginResult> {};
+public class IdentityTokenResult {
+    public static final class Response extends BaseResponse<IdentityTokenResult> {};
 
     /***
      * token

+ 6 - 6
tenant/insurance/quotation-taikang/src/main/java/com/jzg/quotation/taikang/service/TaiKangHttpService.java

@@ -37,16 +37,16 @@ public class TaiKangHttpService {
      * @param tplatformId
      * @return
      */
-    public String identityLogin(String tplatformId) {
-        IdentityLoginParam identityLoginParam = new IdentityLoginParam();
-        identityLoginParam.setTplatformId(tplatformId);
-        identityLoginParam.setChannelCode("OffWeb");
+    public String identityToken(String tplatformId) {
+        IdentityTokenParam identityTokenParam = new IdentityTokenParam();
+        identityTokenParam.setTplatformId(tplatformId);
+        identityTokenParam.setChannelCode("OffWeb");
 
         HttpHeaders httpHeaders = new HttpHeaders();
 
-        IdentityLoginResult.Response response = client.requestUrl(HttpURL.identityLogin, identityLoginParam, IdentityLoginResult.Response.class, httpHeaders);
+        IdentityTokenResult.Response response = client.requestUrl(HttpURL.identityToken, identityTokenParam, IdentityTokenResult.Response.class, httpHeaders);
 
-        IdentityLoginResult data = response.getData();
+        IdentityTokenResult data = response.getData();
 
         if (data != null) {
             token = data.getTkCarRequestToken();

+ 2 - 2
tenant/insurance/quotation-taikang/src/test/java/com/jzg/quotation/taikang/TaiKangHttpClientTest.java

@@ -3,7 +3,7 @@ package com.jzg.quotation.taikang;
 import com.jzg.quotation.commons.component.RequestComponent;
 import com.jzg.quotation.commons.config.WebClientConfig;
 import com.jzg.quotation.taikang.client.TaiKangHttpClient;
-import com.jzg.quotation.taikang.entity.IdentityLoginResult;
+import com.jzg.quotation.taikang.entity.IdentityTokenResult;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.reactive.function.client.WebClient;
 
@@ -23,7 +23,7 @@ public class TaiKangHttpClientTest {
 
         HttpHeaders httpHeaders = new HttpHeaders();
 
-        IdentityLoginResult.Response aa = client.requestUrl("http://car.tk.cn/carSelfService/rest/controller/identity", body, IdentityLoginResult.Response.class, httpHeaders);
+        IdentityTokenResult.Response aa = client.requestUrl("http://car.tk.cn/carSelfService/rest/controller/identity", body, IdentityTokenResult.Response.class, httpHeaders);
 
         System.out.println("结果:");
         System.out.println("结果 token:" + aa.getData().getTkCarRequestToken());

+ 2 - 3
tenant/insurance/quotation-taikang/src/test/java/com/jzg/quotation/taikang/service/TaiKangHttpServiceTest.java

@@ -4,7 +4,6 @@ package com.jzg.quotation.taikang.service;
 import com.alibaba.fastjson2.JSON;
 import com.jzg.quotation.commons.component.RequestComponent;
 import com.jzg.quotation.commons.config.WebClientConfig;
-import com.jzg.quotation.taikang.JsonUtil;
 import com.jzg.quotation.taikang.client.TaiKangHttpClient;
 import com.jzg.quotation.taikang.entity.*;
 import net.sf.cglib.beans.BeanCopier;
@@ -46,8 +45,8 @@ public class TaiKangHttpServiceTest {
 
     @Test
     @Order(1)
-    public void identityLogin() {
-        String token = taiKangHttpService.identityLogin("feda77e829d4dedbbd8b4e236bacfac5");
+    public void identityToken() {
+        String token = taiKangHttpService.identityToken("feda77e829d4dedbbd8b4e236bacfac5");
 
         System.out.println("token: " + token);
     }