Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wxh
spring-boot-material
Commits
acdde426
Commit
acdde426
authored
Nov 06, 2019
by
mergen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix problems
parent
60b04139
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
src/main/java/com/orhon/smartcampus/material/cloud/Api.java
+43
-0
No files found.
src/main/java/com/orhon/smartcampus/material/cloud/Api.java
0 → 100644
View file @
acdde426
package
com
.
orhon
.
smartcampus
.
material
.
cloud
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.Map
;
@Component
public
class
Api
{
@Autowired
private
RestTemplate
restTemplate
;
public
ResponseEntity
<
Map
>
buildGqlQuery
(
String
query
){
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"query"
,
query
);
data
.
put
(
"operationName"
,
null
);
data
.
put
(
"variables"
,
null
);
String
payload
=
JSON
.
toJSONString
(
data
,
SerializerFeature
.
WriteMapNullValue
);
HttpHeaders
headers
=
new
HttpHeaders
();
String
graphqlMapping
=
"http://smartcampus-base/graphql"
;
HttpEntity
<
Object
>
request
=
this
.
forJson
(
payload
,
headers
);
return
restTemplate
.
exchange
(
graphqlMapping
,
HttpMethod
.
POST
,
request
,
Map
.
class
);
}
private
HttpEntity
<
Object
>
forJson
(
String
json
,
HttpHeaders
headers
)
{
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
return
new
HttpEntity
<>(
json
,
headers
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment