Commit 5c304c23 5c304c23845b49361d7359890b5798b33ab88958 by 文鑫

添加跨域支持

1 parent 83a04ac2
......@@ -7,10 +7,7 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse;
import com.topdraw.dockingapi.config.EnvConfiguration;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.PostConstruct;
import java.util.HashMap;
......@@ -26,6 +23,7 @@ import java.util.Map;
@Slf4j
@RequestMapping("/api")
@RequiredArgsConstructor
@CrossOrigin(origins = "*", allowCredentials = "true", maxAge = 3600)
public class ApiController {
private final EnvConfiguration configuration;
......@@ -34,7 +32,6 @@ public class ApiController {
String iv;
String appKey;
String appSecretKey;
String authCode;
int readTimeout = 1000;
int connTimeout = 1000;
......@@ -45,7 +42,6 @@ public class ApiController {
iv = configuration.getAppIv();
appKey = configuration.getAppKey();
appSecretKey = configuration.getAppSecret();
authCode = "";
}
/**
......@@ -76,7 +72,7 @@ public class ApiController {
param.put("userId", userId);
param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide"));
Map<String, String> headerMap = new HashMap<>();
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout);
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, "", headerMap, readTimeout, connTimeout);
}
/**
......@@ -88,7 +84,8 @@ public class ApiController {
public GatewayResponse getUserInfoByAuthCode(@RequestBody JSONObject data) {
String method = "app.ykb.uc.oauth.userInfo";
JSONObject param = new JSONObject();
param.put("authCode", data.getString("authCode"));
String authCode = data.getString("authCode");
param.put("authCode", authCode);
Map<String, String> headerMap = new HashMap<>();
return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout);
}
......