40 lines
1.4 KiB
Java
40 lines
1.4 KiB
Java
package com.pmumali.ch1_simple.controller;
|
|
|
|
import com.pmumali.ch1_simple.model.PariSimple;
|
|
import com.pmumali.ch1_simple.service.PariSimpleService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/paris")
|
|
public class PariController {
|
|
|
|
@Autowired
|
|
private PariSimpleService pariService;
|
|
|
|
@PostMapping
|
|
public ResponseEntity<PariSimple> placerPari(@RequestBody PariSimple pari) {
|
|
return ResponseEntity.ok(pariService.placerPari(pari));
|
|
}
|
|
|
|
@GetMapping("/course/{courseId}")
|
|
public ResponseEntity<List<PariSimple>> obtenirParisParCourse(@PathVariable Long courseId) {
|
|
return ResponseEntity.ok(pariService.obtenirParisParCourse(courseId));
|
|
}
|
|
|
|
@GetMapping("/course/{courseId}/type/{typePari}")
|
|
public ResponseEntity<List<PariSimple>> obtenirParisParCourseEtType(
|
|
@PathVariable Long courseId, @PathVariable String typePari) {
|
|
return ResponseEntity.ok(pariService.obtenirParisParCourseEtType(courseId, typePari));
|
|
}
|
|
|
|
@GetMapping("/cheval/{chevalId}")
|
|
public ResponseEntity<List<PariSimple>> obtenirParisParCheval(@PathVariable Long chevalId) {
|
|
return ResponseEntity.ok(pariService.obtenirParisParCheval(chevalId));
|
|
}
|
|
}
|
|
|