Merge branch 'FDP' of ssh://git.lehub.tf:2222/SchoolTask/jpe-controle into FDP

This commit is contained in:
ExostFlash 2025-06-03 14:23:28 +02:00
commit ab0d97cff6
2 changed files with 22 additions and 0 deletions

View file

@ -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> {

View file

@ -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")