done all the implementations of each parts yet
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// com.pmumali.plr.controllers.WinnerController.java
|
||||
package com.pmumali.plr.controllers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.pmumali.plr.dtos.GainViewDto;
|
||||
import com.pmumali.plr.enums.PariType;
|
||||
import com.pmumali.plr.services.GainService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/gains")
|
||||
@RequiredArgsConstructor
|
||||
public class GainController {
|
||||
|
||||
private final GainService winnerService;
|
||||
|
||||
@Operation(summary = "Lister tous les gagnants d'une course (officiels si disponibles, sinon provisoires)")
|
||||
@GetMapping("/course/{courseId}")
|
||||
public ResponseEntity<?> listWinners(@PathVariable Long courseId) {
|
||||
try {
|
||||
List<GainViewDto> winners = winnerService.listWinners(courseId);
|
||||
return ResponseEntity.ok(winners);
|
||||
} catch (EntityNotFoundException e) {
|
||||
return ResponseEntity.status(404).body(java.util.Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "Lister les gagnants d'une course pour un type de pari")
|
||||
@GetMapping("/course/{courseId}/type/{pariType}")
|
||||
public ResponseEntity<?> listWinnersByType(@PathVariable Long courseId, @PathVariable PariType pariType) {
|
||||
try {
|
||||
List<GainViewDto> winners = winnerService.listWinnersByType(courseId, pariType);
|
||||
return ResponseEntity.ok(winners);
|
||||
} catch (EntityNotFoundException e) {
|
||||
return ResponseEntity.status(404).body(java.util.Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "Savoir si un pari est gagnant (officiel si disponible, sinon provisoire)")
|
||||
@GetMapping("/pari/{pariId}")
|
||||
public ResponseEntity<?> isWinner(@PathVariable Long pariId) {
|
||||
try {
|
||||
GainViewDto view = winnerService.isWinner(pariId);
|
||||
return ResponseEntity.ok(view);
|
||||
} catch (EntityNotFoundException e) {
|
||||
return ResponseEntity.status(404).body(java.util.Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user