添加跨域支持
Showing
1 changed file
with
5 additions
and
8 deletions
... | @@ -7,10 +7,7 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse; | ... | @@ -7,10 +7,7 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse; |
7 | import com.topdraw.dockingapi.config.EnvConfiguration; | 7 | import com.topdraw.dockingapi.config.EnvConfiguration; |
8 | import lombok.RequiredArgsConstructor; | 8 | import lombok.RequiredArgsConstructor; |
9 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
10 | import org.springframework.web.bind.annotation.PostMapping; | 10 | import org.springframework.web.bind.annotation.*; |
11 | import org.springframework.web.bind.annotation.RequestBody; | ||
12 | import org.springframework.web.bind.annotation.RequestMapping; | ||
13 | import org.springframework.web.bind.annotation.RestController; | ||
14 | 11 | ||
15 | import javax.annotation.PostConstruct; | 12 | import javax.annotation.PostConstruct; |
16 | import java.util.HashMap; | 13 | import java.util.HashMap; |
... | @@ -26,6 +23,7 @@ import java.util.Map; | ... | @@ -26,6 +23,7 @@ import java.util.Map; |
26 | @Slf4j | 23 | @Slf4j |
27 | @RequestMapping("/api") | 24 | @RequestMapping("/api") |
28 | @RequiredArgsConstructor | 25 | @RequiredArgsConstructor |
26 | @CrossOrigin(origins = "*", allowCredentials = "true", maxAge = 3600) | ||
29 | public class ApiController { | 27 | public class ApiController { |
30 | private final EnvConfiguration configuration; | 28 | private final EnvConfiguration configuration; |
31 | 29 | ||
... | @@ -34,7 +32,6 @@ public class ApiController { | ... | @@ -34,7 +32,6 @@ public class ApiController { |
34 | String iv; | 32 | String iv; |
35 | String appKey; | 33 | String appKey; |
36 | String appSecretKey; | 34 | String appSecretKey; |
37 | String authCode; | ||
38 | int readTimeout = 1000; | 35 | int readTimeout = 1000; |
39 | int connTimeout = 1000; | 36 | int connTimeout = 1000; |
40 | 37 | ||
... | @@ -45,7 +42,6 @@ public class ApiController { | ... | @@ -45,7 +42,6 @@ public class ApiController { |
45 | iv = configuration.getAppIv(); | 42 | iv = configuration.getAppIv(); |
46 | appKey = configuration.getAppKey(); | 43 | appKey = configuration.getAppKey(); |
47 | appSecretKey = configuration.getAppSecret(); | 44 | appSecretKey = configuration.getAppSecret(); |
48 | authCode = ""; | ||
49 | } | 45 | } |
50 | 46 | ||
51 | /** | 47 | /** |
... | @@ -76,7 +72,7 @@ public class ApiController { | ... | @@ -76,7 +72,7 @@ public class ApiController { |
76 | param.put("userId", userId); | 72 | param.put("userId", userId); |
77 | param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); | 73 | param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); |
78 | Map<String, String> headerMap = new HashMap<>(); | 74 | Map<String, String> headerMap = new HashMap<>(); |
79 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout); | 75 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, "", headerMap, readTimeout, connTimeout); |
80 | } | 76 | } |
81 | 77 | ||
82 | /** | 78 | /** |
... | @@ -88,7 +84,8 @@ public class ApiController { | ... | @@ -88,7 +84,8 @@ public class ApiController { |
88 | public GatewayResponse getUserInfoByAuthCode(@RequestBody JSONObject data) { | 84 | public GatewayResponse getUserInfoByAuthCode(@RequestBody JSONObject data) { |
89 | String method = "app.ykb.uc.oauth.userInfo"; | 85 | String method = "app.ykb.uc.oauth.userInfo"; |
90 | JSONObject param = new JSONObject(); | 86 | JSONObject param = new JSONObject(); |
91 | param.put("authCode", data.getString("authCode")); | 87 | String authCode = data.getString("authCode"); |
88 | param.put("authCode", authCode); | ||
92 | Map<String, String> headerMap = new HashMap<>(); | 89 | Map<String, String> headerMap = new HashMap<>(); |
93 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout); | 90 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout); |
94 | } | 91 | } | ... | ... |
-
Please register or sign in to post a comment