Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
文鑫
/
docking-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
5c304c23
...
5c304c23845b49361d7359890b5798b33ab88958
authored
2024-05-10 15:16:42 +0800
by
文鑫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加跨域支持
1 parent
83a04ac2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
View file @
5c304c2
...
...
@@ -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
);
}
...
...
Please
register
or
sign in
to post a comment