Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78731573
ThirdApiController.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 22, 16:23
Size
1 KB
Mime Type
text/x-java
Expires
Sat, Aug 24, 16:23 (2 d)
Engine
blob
Format
Raw Data
Handle
20089980
Attached To
rDDJUDGEBACK JudgeMyRace Back
ThirdApiController.java
View Options
package
net.javaguides.springboot.websocket.controller
;
import
net.javaguides.springboot.websocket.model.ThirdApi
;
import
net.javaguides.springboot.websocket.repository.ThirdApiRepository
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Collection
;
/**
* Manage the API in bdd
*/
@RestController
public
class
ThirdApiController
{
private
ThirdApiRepository
repository
;
public
ThirdApiController
(
ThirdApiRepository
repository
)
{
this
.
repository
=
repository
;
}
/**
* GetThirdApi
* @return the Api from bdd
*/
@GetMapping
(
"/getThirdApi"
)
@CrossOrigin
public
Collection
<
ThirdApi
>
getThirdApi
()
{
return
repository
.
findAll
();
}
/**
* Delete the api in bdd and save new api
* @param api
*/
@PostMapping
(
path
=
"/saveThirdApi"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
"application/json"
)
@CrossOrigin
public
void
saveThirdApi
(
@RequestBody
ThirdApi
api
)
{
repository
.
deleteAll
();
repository
.
save
(
api
);
System
.
out
.
println
(
api
);
}
/**
* Delete api in bdd
* @return true
*/
@GetMapping
(
"/deleteThirdApi"
)
@CrossOrigin
public
boolean
deleteThirdApi
()
{
repository
.
deleteAll
();
return
true
;
}
}
Event Timeline
Log In to Comment