ajout cors aux restcontrollers
This commit is contained in:
parent
81893b0dfe
commit
6c1e7491d6
3 changed files with 25 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package fr.teamflash.fencerjudgeback.restControllers
|
||||
|
||||
import fr.teamflash.fencerjudgeback.entities.MatchBean
|
||||
import fr.teamflash.fencerjudgeback.restControllers.RefereeRestController.Companion.URL_ORIGIN
|
||||
import fr.teamflash.fencerjudgeback.services.MatchService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
|
|
@ -9,6 +10,10 @@ import org.springframework.web.bind.annotation.*
|
|||
@RequestMapping("/matches")
|
||||
class MatchRestController(private val matchService: MatchService) {
|
||||
|
||||
companion object {
|
||||
const val URL_ORIGIN: String = "http://localhost:8080"
|
||||
}
|
||||
|
||||
// Lister tous les matchs
|
||||
@GetMapping("/")
|
||||
fun getAll(): ResponseEntity<List<MatchBean>?> {
|
||||
|
|
@ -64,6 +69,7 @@ class MatchRestController(private val matchService: MatchService) {
|
|||
}
|
||||
|
||||
// Ajouter un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-match")
|
||||
fun createMatch(@RequestBody match: MatchBean): ResponseEntity<MatchBean> {
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(matchService.createMatch(match))
|
||||
|
|
@ -71,12 +77,14 @@ class MatchRestController(private val matchService: MatchService) {
|
|||
}
|
||||
|
||||
// Mettre à jour un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PutMapping("/update-match/{id}")
|
||||
fun updateMatch(@PathVariable id: Long, @RequestBody match: MatchBean): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(matchService.updateMatch(id, match))
|
||||
}
|
||||
|
||||
// Supprimer un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-match/{id}")
|
||||
fun deleteMatch(@PathVariable id: Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(matchService.deleteMatchById(id))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package fr.teamflash.fencerjudgeback.restControllers
|
||||
|
||||
import fr.teamflash.fencerjudgeback.entities.PlayerBean
|
||||
import fr.teamflash.fencerjudgeback.restControllers.RefereeRestController.Companion.URL_ORIGIN
|
||||
import fr.teamflash.fencerjudgeback.services.PlayerService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.CrossOrigin
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
|
|
@ -16,6 +18,10 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/players")
|
||||
class PlayerRestController(private val playerService: PlayerService) {
|
||||
|
||||
companion object {
|
||||
const val URL_ORIGIN: String = "http://localhost:8080"
|
||||
}
|
||||
|
||||
// Lister tous les joueurs
|
||||
@GetMapping("/")
|
||||
fun getAll(): ResponseEntity<List<PlayerBean>> {
|
||||
|
|
@ -47,18 +53,21 @@ class PlayerRestController(private val playerService: PlayerService) {
|
|||
}
|
||||
|
||||
// Ajouter un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-player")
|
||||
fun createPlayer(@RequestBody player: PlayerBean): ResponseEntity<PlayerBean> {
|
||||
return ResponseEntity.ok(playerService.createPlayer(player))
|
||||
}
|
||||
|
||||
// Modifier un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PutMapping("/update-player/{id}")
|
||||
fun updatePlayer(@PathVariable id: Long, @RequestBody player: PlayerBean): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(playerService.updatePlayer(id, player))
|
||||
}
|
||||
|
||||
// Supprimer un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-player/{id}")
|
||||
fun deletePlayer(@PathVariable id: Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(playerService.deletePlayerById(id))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.teamflash.fencerjudgeback.restControllers
|
|||
import fr.teamflash.fencerjudgeback.entities.RefereeBean
|
||||
import fr.teamflash.fencerjudgeback.services.RefereeService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.CrossOrigin
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
|
|
@ -16,6 +17,10 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/referees")
|
||||
class RefereeRestController(private val refereeService: RefereeService) {
|
||||
|
||||
companion object {
|
||||
const val URL_ORIGIN: String = "http://localhost:8080"
|
||||
}
|
||||
|
||||
// Lister tous les arbitres
|
||||
@GetMapping("/")
|
||||
fun getAll() : ResponseEntity<List<RefereeBean>> {
|
||||
|
|
@ -47,18 +52,21 @@ class RefereeRestController(private val refereeService: RefereeService) {
|
|||
}
|
||||
|
||||
// Ajouter un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-referee")
|
||||
fun createReferee(@RequestBody referee: RefereeBean): ResponseEntity<RefereeBean> {
|
||||
return ResponseEntity.ok(refereeService.createReferee(referee))
|
||||
}
|
||||
|
||||
// Modifier un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PutMapping("/update-referee/{id}")
|
||||
fun updateReferee(@PathVariable id: Long, @RequestBody referee: RefereeBean) : ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(refereeService.updateReferee(id, referee))
|
||||
}
|
||||
|
||||
// Supprimer un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-referee/{id}")
|
||||
fun deleteReferee(@PathVariable id:Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(refereeService.deleteRefereeById(id))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue