update match scores function
This commit is contained in:
parent
e061b9d1c0
commit
0f90a233a6
2 changed files with 22 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import fr.teamflash.fencerjudgeback.services.MatchService
|
|||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import java.util.Date
|
||||
import java.util.Dictionary
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = ["*"])
|
||||
|
|
@ -82,6 +83,12 @@ class MatchRestController(private val matchService: MatchService) {
|
|||
return ResponseEntity.ok(matchService.updateMatch(id, match))
|
||||
}
|
||||
|
||||
// Mettre à jour les scores d'un match
|
||||
@PutMapping("/update-match-scores/{id}")
|
||||
fun updateMatchScores(@PathVariable id: Long, @RequestBody score1:Int, @RequestBody score2:Int): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(matchService.updateScores(id, score1, score2))
|
||||
}
|
||||
|
||||
// Supprimer un match
|
||||
@DeleteMapping("/delete-match/{id}")
|
||||
fun deleteMatch(@PathVariable id: Long): ResponseEntity<Int> {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,21 @@ class MatchService(
|
|||
return 1
|
||||
}
|
||||
|
||||
// Modifier le score d'un match (admin)
|
||||
fun updateScores(id:Long?, score1:Int, score2:Int): Int {
|
||||
println("MatchService.updateScores : $id - $score1 - $score2")
|
||||
if (getById(id) == null) {
|
||||
return -1
|
||||
}
|
||||
|
||||
val match = getById(id)
|
||||
match?.score1 = score1
|
||||
match?.score2 = score2
|
||||
match?.let { matchRepository.save(it) }
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
// Supprimer un match (admin)
|
||||
fun deleteMatchById(id: Long?) : Int? {
|
||||
println("MatchService.deleteMatchById : $id")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue