Compare commits
1 Commits
main
...
c13e5b1dfc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c13e5b1dfc |
@@ -13,7 +13,7 @@ services:
|
||||
networks:
|
||||
- api
|
||||
api_db:
|
||||
image: postgres
|
||||
image: postgres:15
|
||||
container_name: api_db
|
||||
ports:
|
||||
- 5555:5432
|
||||
@@ -22,7 +22,7 @@ services:
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DBNAME="plr"
|
||||
- POSTGRES_DB="plr"
|
||||
restart: always
|
||||
networks:
|
||||
- api
|
||||
|
||||
0
gradle.properties
Normal file
0
gradle.properties
Normal file
5
run.sh
Executable file
5
run.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
./gradlew clean build -x test
|
||||
docker-compose up --build -d
|
||||
docker logs -f api_app
|
||||
@@ -2,6 +2,8 @@ package com.pmu.betengine;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BetEngineApplication {
|
||||
@@ -10,4 +12,8 @@ public class BetEngineApplication {
|
||||
SpringApplication.run(BetEngineApplication.class, args);
|
||||
}
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void onApplicationReady() {
|
||||
System.out.println("******************* PMU Bet Engine is running and connected successfully! *******************");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.Agent;
|
||||
import com.pmu.betengine.service.AgentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/agents")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Agents", description = "Endpoints relatifs aux Agents")
|
||||
public class AgentController {
|
||||
|
||||
private final AgentService agentService;
|
||||
|
||||
public AgentController(AgentService agentService) {
|
||||
this.agentService = agentService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister tous les Agents")
|
||||
public ResponseEntity<List<Agent>> getAllAgents() {
|
||||
return ResponseEntity.ok(agentService.getAllAgents());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "Obtenir un Agent par ID")
|
||||
public ResponseEntity<Agent> getAgentById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(agentService.getAgentById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Créer un Agent")
|
||||
public ResponseEntity<Agent> createAgent(@RequestBody Agent agent) {
|
||||
return new ResponseEntity<>(agentService.createAgent(agent), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "Modifier un Agent")
|
||||
public ResponseEntity<Agent> updateAgent(@PathVariable Long id, @RequestBody Agent agent) {
|
||||
return ResponseEntity.ok(agentService.updateAgent(id, agent));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer un Agent")
|
||||
public ResponseEntity<String> deleteAgent(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(agentService.deleteAgent(id));
|
||||
}
|
||||
|
||||
@GetMapping("/code/{code}")
|
||||
@Operation(summary = "Obtenir un Agent par code")
|
||||
public ResponseEntity<Agent> getAgentByCode(@PathVariable String code) {
|
||||
return ResponseEntity.ok(agentService.getAgentByCode(code));
|
||||
}
|
||||
|
||||
@GetMapping("/statut/{statut}")
|
||||
@Operation(summary = "Lister les Agents par statut")
|
||||
public ResponseEntity<List<Agent>> getAgentsByStatut(@PathVariable String statut) {
|
||||
return ResponseEntity.ok(agentService.getAgentsByStatut(statut));
|
||||
}
|
||||
|
||||
@GetMapping("/ville/{ville}")
|
||||
@Operation(summary = "Lister les Agents par ville")
|
||||
public ResponseEntity<List<Agent>> getAgentsByVille(@PathVariable String ville) {
|
||||
return ResponseEntity.ok(agentService.getAgentsByVille(ville));
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
@Operation(summary = "Rechercher des Agents par nom ou prénom")
|
||||
public ResponseEntity<List<Agent>> searchAgents(@RequestParam String q) {
|
||||
return ResponseEntity.ok(agentService.searchAgentsByName(q));
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,79 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.dto.AgentFamilyMemberDTO;
|
||||
import com.pmu.betengine.model.dto.AgentFamilyMemberRequestDTO;
|
||||
import com.pmu.betengine.model.AgentFamilyMember;
|
||||
import com.pmu.betengine.service.AgentFamilyMemberService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/agent-family-members")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Membres de famille", description = "Endpoints relatifs à l'objet AgentFamilyMember")
|
||||
public class AgentFamilyMemberController {
|
||||
|
||||
private final AgentFamilyMemberService agentFamilyMemberService;
|
||||
private final AgentFamilyMemberService service;
|
||||
|
||||
/* public AgentFamilyMemberController(AgentFamilyMemberService agentFamilyMemberService) {
|
||||
this.agentFamilyMemberService = agentFamilyMemberService;
|
||||
}*/
|
||||
public AgentFamilyMemberController(AgentFamilyMemberService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getAllFamilyMembers() {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.getAllFamilyMembers());
|
||||
@Operation(summary = "Lister tous les membres de famille")
|
||||
public ResponseEntity<List<AgentFamilyMember>> getAllFamilyMembers() {
|
||||
return ResponseEntity.ok(service.getAllFamilyMembers());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<AgentFamilyMemberDTO> getFamilyMemberById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMemberById(id));
|
||||
@Operation(summary = "Obtenir un membre de famille par ID")
|
||||
public ResponseEntity<AgentFamilyMember> getFamilyMemberById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.getFamilyMemberById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Ajouter un AgentFamilyMember dans la base")
|
||||
public ResponseEntity<AgentFamilyMemberDTO> createFamilyMember(@Valid @RequestBody AgentFamilyMemberRequestDTO requestDTO) {
|
||||
return new ResponseEntity<>(agentFamilyMemberService.createFamilyMember(requestDTO), HttpStatus.CREATED);
|
||||
@Operation(summary = "Créer un membre de famille")
|
||||
public ResponseEntity<AgentFamilyMember> createFamilyMember(@RequestBody AgentFamilyMember member) {
|
||||
return new ResponseEntity<>(service.createFamilyMember(member), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<AgentFamilyMemberDTO> updateFamilyMember(@PathVariable Long id, @Valid @RequestBody AgentFamilyMemberRequestDTO requestDTO) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.updateFamilyMember(id, requestDTO));
|
||||
@Operation(summary = "Modifier un membre de famille")
|
||||
public ResponseEntity<AgentFamilyMember> updateFamilyMember(@PathVariable Long id,
|
||||
@RequestBody AgentFamilyMember member) {
|
||||
return ResponseEntity.ok(service.updateFamilyMember(id, member));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteFamilyMember(@PathVariable Long id) {
|
||||
agentFamilyMemberService.deleteFamilyMember(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
@Operation(summary = "Supprimer un membre de famille")
|
||||
public ResponseEntity<String> deleteFamilyMember(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.deleteFamilyMember(id));
|
||||
}
|
||||
|
||||
@GetMapping("/statut/{statut}")
|
||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersByStatut(@PathVariable String statut) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersByStatut(statut));
|
||||
@Operation(summary = "Lister les membres par statut")
|
||||
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersByStatut(@PathVariable String statut) {
|
||||
return ResponseEntity.ok(service.getFamilyMembersByStatut(statut));
|
||||
}
|
||||
|
||||
@GetMapping("/sexe/{sexe}")
|
||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersBySexe(@PathVariable String sexe) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersBySexe(sexe));
|
||||
@Operation(summary = "Lister les membres par sexe")
|
||||
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersBySexe(@PathVariable String sexe) {
|
||||
return ResponseEntity.ok(service.getFamilyMembersBySexe(sexe));
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
public ResponseEntity<List<AgentFamilyMemberDTO>> searchFamilyMembers(@RequestParam String keyword) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.searchFamilyMembers(keyword));
|
||||
@Operation(summary = "Rechercher des membres par mot-clé")
|
||||
public ResponseEntity<List<AgentFamilyMember>> searchFamilyMembers(@RequestParam String keyword) {
|
||||
return ResponseEntity.ok(service.searchFamilyMembers(keyword));
|
||||
}
|
||||
|
||||
@GetMapping("/nom/{nom}")
|
||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersByNom(@PathVariable String nom) {
|
||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersByNom(nom));
|
||||
@Operation(summary = "Lister les membres par nom")
|
||||
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersByNom(@PathVariable String nom) {
|
||||
return ResponseEntity.ok(service.getFamilyMembersByNom(nom));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.AgentLimit;
|
||||
import com.pmu.betengine.service.AgentLimitService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/agent-limits")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Limites Agents", description = "Endpoints relatifs à l'objet AgentLimit")
|
||||
public class AgentLimitController {
|
||||
|
||||
private final AgentLimitService service;
|
||||
|
||||
public AgentLimitController(AgentLimitService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister toutes les limites d'agents")
|
||||
public ResponseEntity<List<AgentLimit>> getAllAgentLimits() {
|
||||
return ResponseEntity.ok(service.getAllAgentLimits());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "Obtenir une limite par ID")
|
||||
public ResponseEntity<AgentLimit> getAgentLimitById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.getAgentLimitById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Créer une limite d'agent")
|
||||
public ResponseEntity<AgentLimit> createAgentLimit(@RequestBody AgentLimit agentLimit) {
|
||||
return new ResponseEntity<>(service.createAgentLimit(agentLimit), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "Modifier une limite d'agent")
|
||||
public ResponseEntity<AgentLimit> updateAgentLimit(@PathVariable Long id,
|
||||
@RequestBody AgentLimit agentLimit) {
|
||||
return ResponseEntity.ok(service.updateAgentLimit(id, agentLimit));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer une limite d'agent")
|
||||
public ResponseEntity<String> deleteAgentLimit(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.deleteAgentLimit(id));
|
||||
}
|
||||
|
||||
@GetMapping("/actif/{actif}")
|
||||
@Operation(summary = "Lister les limites actives ou inactives")
|
||||
public ResponseEntity<List<AgentLimit>> getAgentLimitsByActif(@PathVariable boolean actif) {
|
||||
return ResponseEntity.ok(service.getAgentLimitsByActif(actif));
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
@Operation(summary = "Rechercher les limites par nom")
|
||||
public ResponseEntity<List<AgentLimit>> searchAgentLimitsByNom(@RequestParam String nom) {
|
||||
return ResponseEntity.ok(service.searchAgentLimitsByNom(nom));
|
||||
}
|
||||
}
|
||||
@@ -4,26 +4,35 @@ import com.pmu.betengine.model.Cheval;
|
||||
import com.pmu.betengine.service.ChevalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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/v1/cheval")
|
||||
@Tag(name = "Gestion des Chevaux", description = "Endpoints relatifs à l'objet cheval")
|
||||
@RequestMapping("/api/v1/chevaux")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Chevaux", description = "Endpoints relatifs à l'objet Cheval")
|
||||
public class ChevalController {
|
||||
|
||||
@Autowired
|
||||
private ChevalService chevalService;
|
||||
private final ChevalService chevalService;
|
||||
|
||||
public ChevalController(ChevalService chevalService) {
|
||||
this.chevalService = chevalService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Ajouter un cheval dans la base")
|
||||
@Operation(summary = "Ajouter un cheval")
|
||||
public ResponseEntity<Cheval> ajouterCheval(@RequestBody Cheval cheval) {
|
||||
return ResponseEntity.ok(chevalService.ajouterCheval(cheval));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister tous les chevaux")
|
||||
public ResponseEntity<List<Cheval>> obtenirTousLesChevaux() {
|
||||
return ResponseEntity.ok(chevalService.obtenirTousLesChevaux());
|
||||
}
|
||||
|
||||
@GetMapping("/course/{courseId}")
|
||||
@Operation(summary = "Affiche les chevaux d'une Course donnée")
|
||||
public ResponseEntity<List<Cheval>> obtenirChevauxParCourse(@PathVariable Long courseId) {
|
||||
@@ -35,5 +44,17 @@ public class ChevalController {
|
||||
public ResponseEntity<List<Cheval>> obtenirChevauxParEcurie(@PathVariable String nomEcurie) {
|
||||
return ResponseEntity.ok(chevalService.obtenirChevauxParEcurie(nomEcurie));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/numero/{numero}")
|
||||
@Operation(summary = "Obtenir un cheval par numéro")
|
||||
public ResponseEntity<Cheval> obtenirChevalParNumero(@PathVariable int numero) {
|
||||
return ResponseEntity.ok(chevalService.obtenirChevalParNumero(numero));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer un cheval par ID")
|
||||
public ResponseEntity<String> supprimerCheval(@PathVariable Long id) {
|
||||
chevalService.supprimerCheval(id);
|
||||
return ResponseEntity.ok("Cheval supprimé avec succès.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +1,69 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.Cheval;
|
||||
import com.pmu.betengine.model.Course;
|
||||
import com.pmu.betengine.model.dto.NewCourse;
|
||||
import com.pmu.betengine.model.statut.StatutCourse;
|
||||
import com.pmu.betengine.service.CourseService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/course")
|
||||
@Tag(name = "Gestion des Courses", description = "Endpoints relatifs à l'objet course")
|
||||
@RequestMapping("/api/v1/courses")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Courses", description = "Endpoints relatifs aux Courses")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Création d'une Nouvelle Course")
|
||||
@ApiResponse(responseCode = "201", description = "Course Enregistrée")
|
||||
public ResponseEntity<String> creerCourse(@RequestBody NewCourse course) {
|
||||
Course courseNew =null;
|
||||
try {
|
||||
courseNew = courseService.creerCourse(fromDto(course));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(courseNew!=null && courseNew.getId()!=null)
|
||||
|
||||
return new ResponseEntity<>("Course ID = "+courseNew.getId(), HttpStatus.CREATED);
|
||||
|
||||
else {
|
||||
|
||||
return new ResponseEntity<>("Erreur de Création de la Course", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
private final CourseService courseService;
|
||||
|
||||
public CourseController(CourseService courseService) {
|
||||
this.courseService = courseService;
|
||||
}
|
||||
|
||||
// @GetMapping
|
||||
public ResponseEntity<List<Course>> obtenirToutesCourses() {
|
||||
return ResponseEntity.ok(courseService.obtenirToutesCourses());
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister toutes les Courses")
|
||||
public ResponseEntity<List<Course>> getAllCourses() {
|
||||
return ResponseEntity.ok(courseService.getAllCourses());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "Obtenir une Course à travers son ID")
|
||||
public ResponseEntity<Course> obtenirCourseParId(@PathVariable Long id) {
|
||||
Course course = courseService.obtenirCourseParId(id);
|
||||
return course != null ? ResponseEntity.ok(course) : ResponseEntity.notFound().build();
|
||||
@Operation(summary = "Obtenir une Course par ID")
|
||||
public ResponseEntity<Course> getCourseById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(courseService.getCourseById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/terminees")
|
||||
@Operation(summary = "Afficher toutes les courses terminées")
|
||||
public ResponseEntity<List<Course>> obtenirCoursesTerminees() {
|
||||
return ResponseEntity.ok(courseService.obtenirCoursesTerminees());
|
||||
@PostMapping
|
||||
@Operation(summary = "Créer une Course")
|
||||
public ResponseEntity<Course> createCourse(@RequestBody Course course) {
|
||||
return new ResponseEntity<>(courseService.createCourse(course), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/avenir")
|
||||
@Operation(summary = "Afficher les Courses à venir")
|
||||
public ResponseEntity<List<Course>> obtenirCoursesAVenir() {
|
||||
return ResponseEntity.ok(courseService.obtenirCoursesAVenir());
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "Modifier une Course")
|
||||
public ResponseEntity<Course> updateCourse(@PathVariable Long id, @RequestBody Course course) {
|
||||
return ResponseEntity.ok(courseService.updateCourse(id, course));
|
||||
}
|
||||
|
||||
private Course fromDto(NewCourse dto){
|
||||
return Course.builder()
|
||||
.heureCourse(dto.getHeureCourse())
|
||||
.numero(dto.getNumero())
|
||||
.aDeadHeat(false)
|
||||
.estAnnulee(false)
|
||||
.estTerminee(false)
|
||||
.lieu(dto.getLieu())
|
||||
.reunion(dto.getReunion())
|
||||
.statut(StatutCourse.CREATED)
|
||||
// .nombreChevauxInscrits(dto.getChevaux() != null ? dto.getChevaux().size() : 0)
|
||||
// .chevaux(fromIntegerList(dto.getChevaux()))
|
||||
.build();
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer une Course")
|
||||
public ResponseEntity<Void> deleteCourse(@PathVariable Long id) {
|
||||
courseService.deleteCourse(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
@Operation(summary = "Rechercher des Courses")
|
||||
public ResponseEntity<List<Course>> searchCourses(@RequestParam String q) {
|
||||
return ResponseEntity.ok(courseService.searchCourses(q));
|
||||
}
|
||||
|
||||
@PatchMapping("/{id}/statut")
|
||||
@Operation(summary = "Modifier le statut d'une Course")
|
||||
public ResponseEntity<Course> updateStatut(@PathVariable Long id, @RequestBody Map<String, String> request) {
|
||||
String statut = request.get("statut");
|
||||
return ResponseEntity.ok(courseService.updateStatut(id, statut));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.CourseReportDetailRow;
|
||||
import com.pmu.betengine.service.CourseReportDetailRowService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/course-report-detail-rows")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des détails de rapports de course", description = "Endpoints relatifs à l'objet CourseReportDetailRow")
|
||||
public class CourseReportDetailRowController {
|
||||
|
||||
private final CourseReportDetailRowService service;
|
||||
|
||||
public CourseReportDetailRowController(CourseReportDetailRowService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Créer un détail de rapport de course")
|
||||
public ResponseEntity<CourseReportDetailRow> create(@RequestBody CourseReportDetailRow row) {
|
||||
return ResponseEntity.ok(service.create(row));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "Obtenir un détail par ID")
|
||||
public ResponseEntity<CourseReportDetailRow> getById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.getById(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister tous les détails de rapport")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getAll() {
|
||||
return ResponseEntity.ok(service.getAll());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "Mettre à jour un détail de rapport")
|
||||
public ResponseEntity<CourseReportDetailRow> update(@PathVariable Long id,
|
||||
@RequestBody CourseReportDetailRow row) {
|
||||
return ResponseEntity.ok(service.update(id, row));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer un détail de rapport")
|
||||
public ResponseEntity<String> delete(@PathVariable Long id) {
|
||||
service.delete(id);
|
||||
return ResponseEntity.ok("CourseReportDetailRow supprimé avec succès.");
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{detailId}")
|
||||
@Operation(summary = "Obtenir les détails par detailId")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByDetailId(@PathVariable Long detailId) {
|
||||
return ResponseEntity.ok(service.getByDetailId(detailId));
|
||||
}
|
||||
|
||||
@GetMapping("/type-gain/{typeGain}")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByTypeGain(@PathVariable String typeGain) {
|
||||
return ResponseEntity.ok(service.getByTypeGain(typeGain));
|
||||
}
|
||||
|
||||
@GetMapping("/type-jeu/{typeJeu}")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByTypeJeu(@PathVariable String typeJeu) {
|
||||
return ResponseEntity.ok(service.getByTypeJeu(typeJeu));
|
||||
}
|
||||
|
||||
@GetMapping("/statut/{statut}")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByStatut(@PathVariable String statut) {
|
||||
return ResponseEntity.ok(service.getByStatut(statut));
|
||||
}
|
||||
|
||||
@GetMapping("/distributed/{distributed}")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByDistributed(@PathVariable Boolean distributed) {
|
||||
return ResponseEntity.ok(service.getByDistributed(distributed));
|
||||
}
|
||||
|
||||
@GetMapping("/externe/{externe}")
|
||||
public ResponseEntity<List<CourseReportDetailRow>> getByExterne(@PathVariable Boolean externe) {
|
||||
return ResponseEntity.ok(service.getByExterne(externe));
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.dto.HippodromeDTO;
|
||||
import com.pmu.betengine.model.dto.HippodromeRequestDTO;
|
||||
import com.pmu.betengine.model.Hippodrome;
|
||||
import com.pmu.betengine.service.HippodromeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/hippodromes")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Hippodromes ", description = "Endpoints relatifs à l'objet Hippodrome")
|
||||
@Tag(name = "Gestion des Hippodromes", description = "Endpoints relatifs aux Hippodromes")
|
||||
public class HippodromeController {
|
||||
|
||||
private final HippodromeService hippodromeService;
|
||||
@@ -26,45 +23,51 @@ public class HippodromeController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<HippodromeDTO>> getAllHippodromes() {
|
||||
@Operation(summary = "Lister tous les Hippodromes")
|
||||
public ResponseEntity<List<Hippodrome>> getAllHippodromes() {
|
||||
return ResponseEntity.ok(hippodromeService.getAllHippodromes());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<HippodromeDTO> getHippodromeById(@PathVariable Long id) {
|
||||
@Operation(summary = "Obtenir un Hippodrome par ID")
|
||||
public ResponseEntity<Hippodrome> getHippodromeById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(hippodromeService.getHippodromeById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Enregistrer Un Hippodrome",
|
||||
description = "Méthode permettant d'enregistrer l'Hippodrome")
|
||||
public ResponseEntity<HippodromeDTO> createHippodrome(@Valid @RequestBody HippodromeRequestDTO requestDTO) {
|
||||
return new ResponseEntity<>(hippodromeService.createHippodrome(requestDTO), HttpStatus.CREATED);
|
||||
@Operation(summary = "Créer un Hippodrome")
|
||||
public ResponseEntity<Hippodrome> createHippodrome(@RequestBody Hippodrome hippodrome) {
|
||||
return new ResponseEntity<>(hippodromeService.createHippodrome(hippodrome), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<HippodromeDTO> updateHippodrome(@PathVariable Long id, @Valid @RequestBody HippodromeRequestDTO requestDTO) {
|
||||
return ResponseEntity.ok(hippodromeService.updateHippodrome(id, requestDTO));
|
||||
@Operation(summary = "Modifier un Hippodrome")
|
||||
public ResponseEntity<Hippodrome> updateHippodrome(@PathVariable Long id, @RequestBody Hippodrome hippodrome) {
|
||||
return ResponseEntity.ok(hippodromeService.updateHippodrome(id, hippodrome));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer un Hippodrome")
|
||||
public ResponseEntity<Void> deleteHippodrome(@PathVariable Long id) {
|
||||
hippodromeService.deleteHippodrome(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping("/ville/{ville}")
|
||||
public ResponseEntity<List<HippodromeDTO>> getHippodromesByVille(@PathVariable String ville) {
|
||||
@Operation(summary = "Lister les Hippodromes par ville")
|
||||
public ResponseEntity<List<Hippodrome>> getHippodromesByVille(@PathVariable String ville) {
|
||||
return ResponseEntity.ok(hippodromeService.getHippodromesByVille(ville));
|
||||
}
|
||||
|
||||
@GetMapping("/actifs")
|
||||
public ResponseEntity<List<HippodromeDTO>> getHippodromesActifs() {
|
||||
@Operation(summary = "Lister les Hippodromes actifs")
|
||||
public ResponseEntity<List<Hippodrome>> getHippodromesActifs() {
|
||||
return ResponseEntity.ok(hippodromeService.getHippodromesActifs());
|
||||
}
|
||||
|
||||
@GetMapping("/reunion/{reunionId}")
|
||||
public ResponseEntity<HippodromeDTO> getHippodromeByReunion(@PathVariable Long reunionId) {
|
||||
return ResponseEntity.ok(hippodromeService.getHippodromeByReunion(reunionId));
|
||||
@GetMapping("/search")
|
||||
@Operation(summary = "Rechercher des Hippodromes par nom")
|
||||
public ResponseEntity<List<Hippodrome>> searchHippodromes(@RequestParam String nom) {
|
||||
return ResponseEntity.ok(hippodromeService.searchHippodromesByNom(nom));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.NonPartant;
|
||||
import com.pmu.betengine.service.NonPartantService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/non-partants")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Non Partants", description = "Endpoints relatifs aux chevaux non partants")
|
||||
public class NonPartantController {
|
||||
|
||||
private final NonPartantService service;
|
||||
|
||||
public NonPartantController(NonPartantService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Ajouter un NonPartant")
|
||||
public ResponseEntity<NonPartant> create(@RequestBody NonPartant np) {
|
||||
return new ResponseEntity<>(service.createNonPartant(np), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "Lister tous les NonPartants")
|
||||
public ResponseEntity<List<NonPartant>> getAll() {
|
||||
return ResponseEntity.ok(service.getAllNonPartants());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "Obtenir un NonPartant par ID")
|
||||
public ResponseEntity<NonPartant> getById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(service.getNonPartantById(id));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "Mettre à jour un NonPartant")
|
||||
public ResponseEntity<NonPartant> update(@PathVariable Long id, @RequestBody NonPartant np) {
|
||||
return ResponseEntity.ok(service.updateNonPartant(id, np));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "Supprimer un NonPartant")
|
||||
public ResponseEntity<String> delete(@PathVariable Long id) {
|
||||
service.deleteNonPartant(id);
|
||||
return ResponseEntity.ok("NonPartant supprimé avec succès.");
|
||||
}
|
||||
|
||||
@GetMapping("/course/{courseId}")
|
||||
@Operation(summary = "Lister les NonPartants d'une course")
|
||||
public ResponseEntity<List<NonPartant>> getByCourse(@PathVariable Long courseId) {
|
||||
return ResponseEntity.ok(service.getByCourseId(courseId));
|
||||
}
|
||||
|
||||
@GetMapping("/search/nom")
|
||||
@Operation(summary = "Rechercher des NonPartants par nom de cheval")
|
||||
public ResponseEntity<List<NonPartant>> searchByNom(@RequestParam String nom) {
|
||||
return ResponseEntity.ok(service.searchByNomCheval(nom));
|
||||
}
|
||||
|
||||
@GetMapping("/search/motif")
|
||||
@Operation(summary = "Rechercher des NonPartants par motif")
|
||||
public ResponseEntity<List<NonPartant>> searchByMotif(@RequestParam String motif) {
|
||||
return ResponseEntity.ok(service.searchByMotif(motif));
|
||||
}
|
||||
}
|
||||
@@ -1,113 +1,196 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.Pari;
|
||||
import com.pmu.betengine.model.dto.NewPari;
|
||||
import com.pmu.betengine.model.dto.updatePari;
|
||||
import com.pmu.betengine.model.statut.StatutParis;
|
||||
import com.pmu.betengine.model.type.TypeFormule;
|
||||
import com.pmu.betengine.service.CourseService;
|
||||
import com.pmu.betengine.service.PariService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
||||
import static com.pmu.betengine.util.ChevalUtil.numeroToCheval;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/pari")
|
||||
@Tag(name = "Gestion des Pari (Bet)", description = "Endpoints relatifs à l'objet pari")
|
||||
public class PariController {
|
||||
|
||||
@Autowired
|
||||
private PariService pariService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@PostMapping
|
||||
@Operation(summary = "Placer un Pari (Bet)",
|
||||
description = "Permet d'enregistrer tous les types de Pari (Bet) avec toutes les Formules possibles")
|
||||
@ApiResponse(responseCode = "201", description = "Nouveau Pari Enregistré")
|
||||
public ResponseEntity<Pari> placerPari(@RequestBody NewPari pari) {
|
||||
try {
|
||||
return new ResponseEntity<>(pariService.placerPari(fromNewPariDto(pari)), HttpStatus.CREATED);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
private final PariService pariService;
|
||||
private final CourseService courseService;
|
||||
|
||||
@GetMapping("/course/{courseId}")
|
||||
@Operation(summary = "Affiche tous les Pari (Bet) d'une Course")
|
||||
@ApiResponse(responseCode = "200", description = "Paris Trouvés")
|
||||
public ResponseEntity<List<Pari>> obtenirParisParCourse(@PathVariable Long courseId) {
|
||||
return ResponseEntity.ok(pariService.obtenirParisParCourse(courseId));
|
||||
public PariController(PariService pariService, CourseService courseService) {
|
||||
this.pariService = pariService;
|
||||
this.courseService = courseService;
|
||||
}
|
||||
|
||||
// CREATE
|
||||
@PostMapping
|
||||
public ResponseEntity<Pari> create(@RequestBody Pari pari) {
|
||||
|
||||
if (pari.getCourse() != null && pari.getCourse().getId() != null) {
|
||||
pari.setCourse(courseService.getCourseById(pari.getCourse().getId()));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(pariService.save(pari));
|
||||
}
|
||||
|
||||
// GET ALL
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Pari>> getAll() {
|
||||
return ResponseEntity.ok(pariService.getAll());
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Pari> getById(@PathVariable Long id) {
|
||||
Pari pari = pariService.getById(id);
|
||||
return pari != null ? ResponseEntity.ok(pari) : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
// GET BY COURSE
|
||||
@GetMapping("/course/{courseId}")
|
||||
public ResponseEntity<List<Pari>> getByCourse(@PathVariable Long courseId) {
|
||||
return ResponseEntity.ok(pariService.getByCourse(courseId));
|
||||
}
|
||||
|
||||
// UPDATE STATUS / PAY / REFUND
|
||||
@PutMapping("/{ticket}")
|
||||
@Operation(summary = "Mettre à jour un Pari Existant",description = "Cette opération concerne le status (), payé ou remboursé")
|
||||
@ApiResponse(responseCode = "200", description = "Pari Modifié avec succès")
|
||||
@ApiResponse(responseCode = "404", description = "Pari Non Trouvé")
|
||||
public ResponseEntity<String> updateProduct(@PathVariable String ticket, @RequestBody updatePari updatePari) {
|
||||
// Find the product by ID
|
||||
public ResponseEntity<Pari> update(
|
||||
@PathVariable String ticket,
|
||||
@RequestBody Pari update
|
||||
) {
|
||||
Pari pari = pariService.findByTicket(ticket);
|
||||
|
||||
if (pari != null) {
|
||||
|
||||
pari.setStatut(updatePari.getStatus());
|
||||
pari.setEstRembourse(updatePari.isEstRembourse());
|
||||
pari.setEstPaye(updatePari.isEstPaye());
|
||||
|
||||
Pari pariUpdate = pariService.update(pari);
|
||||
return ResponseEntity.ok(ticket); // Return the updated product
|
||||
} else {
|
||||
return ResponseEntity.status(404).body(ticket);
|
||||
if (pari == null) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
pari.setStatut(update.getStatut());
|
||||
pari.setEstRembourse(update.isEstRembourse());
|
||||
pari.setEstPaye(update.isEstPaye());
|
||||
|
||||
return ResponseEntity.ok(pariService.update(pari));
|
||||
}
|
||||
|
||||
// @GetMapping("/course/{courseId}/type/{typePari}")
|
||||
public ResponseEntity<List<Pari>> obtenirParisParCourseEtType(
|
||||
@PathVariable Long courseId, @PathVariable TypeFormule typeFormule) {
|
||||
return ResponseEntity.ok(pariService.obtenirParisParCourseEtType(courseId, typeFormule));
|
||||
}
|
||||
|
||||
// @GetMapping("/cheval/{chevalId}")
|
||||
public ResponseEntity<List<Pari>> obtenirParisParCheval(@PathVariable Long chevalId) {
|
||||
return ResponseEntity.ok(pariService.obtenirParisParCheval(chevalId));
|
||||
}
|
||||
|
||||
private Pari fromNewPariDto(NewPari newPari){
|
||||
return Pari.builder()
|
||||
.datePari(newPari.getDatePari())
|
||||
.course(courseService.obtenirCourseParId(newPari.getCourseId()))
|
||||
.cheval(numeroToCheval(newPari.getCheval()))
|
||||
.cheval1(numeroToCheval(newPari.getCheval1()))
|
||||
.cheval2(numeroToCheval(newPari.getCheval2()))
|
||||
.cheval3(numeroToCheval(newPari.getCheval3()))
|
||||
.chevauxOrdre(newPari.getChevauxOrdre())
|
||||
.chevauxSelectionnes(fromIntegerList(newPari.getChevauxSelectionnes()))
|
||||
.numeroTicket(newPari.getNumeroTicket())
|
||||
.nomParieur(newPari.getNomParieur())
|
||||
.idParieur(newPari.getIdParieur())
|
||||
.statut(StatutParis.EN_ATTENTE)
|
||||
.mise(newPari.getMise())
|
||||
.premier(numeroToCheval(newPari.getPremier()))
|
||||
.deuxieme(numeroToCheval(newPari.getDeuxieme()))
|
||||
.troisieme(numeroToCheval(newPari.getTroisieme()))
|
||||
.typeFormule(newPari.getTypeFormule())
|
||||
.typePari(newPari.getTypePari())
|
||||
.estRembourse(false)
|
||||
.estPaye(false)
|
||||
.typeMulti(newPari.getTypeMulti())
|
||||
.ordrePredit(newPari.getOrdrePredit())
|
||||
.validationOrdreExact(newPari.getValidationOrdreExact())
|
||||
.build();
|
||||
// DELETE
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
pariService.delete(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.controller;
|
||||
|
||||
// import com.pmu.betengine.model.Pari;
|
||||
// import com.pmu.betengine.model.dto.NewPari;
|
||||
// import com.pmu.betengine.model.dto.updatePari;
|
||||
// import com.pmu.betengine.model.statut.StatutParis;
|
||||
// import com.pmu.betengine.model.type.TypeFormule;
|
||||
// import com.pmu.betengine.service.CourseService;
|
||||
// import com.pmu.betengine.service.PariService;
|
||||
// import io.swagger.v3.oas.annotations.Operation;
|
||||
// import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
// import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.http.HttpStatus;
|
||||
// import org.springframework.http.ResponseEntity;
|
||||
// import org.springframework.web.bind.annotation.*;
|
||||
|
||||
// import java.util.List;
|
||||
|
||||
// import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
||||
// import static com.pmu.betengine.util.ChevalUtil.numeroToCheval;
|
||||
|
||||
// @RestController
|
||||
// @RequestMapping("/api/v1/pari")
|
||||
// @Tag(name = "Gestion des Pari (Bet)", description = "Endpoints relatifs à l'objet pari")
|
||||
// public class PariController {
|
||||
|
||||
// @Autowired
|
||||
// private PariService pariService;
|
||||
// @Autowired
|
||||
// private CourseService courseService;
|
||||
// @PostMapping
|
||||
// @Operation(summary = "Placer un Pari (Bet)",
|
||||
// description = "Permet d'enregistrer tous les types de Pari (Bet) avec toutes les Formules possibles")
|
||||
// @ApiResponse(responseCode = "201", description = "Nouveau Pari Enregistré")
|
||||
// public ResponseEntity<Pari> placerPari(@RequestBody NewPari pari) {
|
||||
// try {
|
||||
// return new ResponseEntity<>(pariService.placerPari(fromNewPariDto(pari)), HttpStatus.CREATED);
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @GetMapping("/course/{courseId}")
|
||||
// @Operation(summary = "Affiche tous les Pari (Bet) d'une Course")
|
||||
// @ApiResponse(responseCode = "200", description = "Paris Trouvés")
|
||||
// public ResponseEntity<List<Pari>> obtenirParisParCourse(@PathVariable Long courseId) {
|
||||
// return ResponseEntity.ok(pariService.obtenirParisParCourse(courseId));
|
||||
// }
|
||||
|
||||
|
||||
// @PutMapping("/{ticket}")
|
||||
// @Operation(summary = "Mettre à jour un Pari Existant",description = "Cette opération concerne le status (), payé ou remboursé")
|
||||
// @ApiResponse(responseCode = "200", description = "Pari Modifié avec succès")
|
||||
// @ApiResponse(responseCode = "404", description = "Pari Non Trouvé")
|
||||
// public ResponseEntity<String> updateProduct(@PathVariable String ticket, @RequestBody updatePari updatePari) {
|
||||
// // Find the product by ID
|
||||
// Pari pari = pariService.findByTicket(ticket);
|
||||
|
||||
// if (pari != null) {
|
||||
|
||||
// pari.setStatut(updatePari.getStatus());
|
||||
// pari.setEstRembourse(updatePari.isEstRembourse());
|
||||
// pari.setEstPaye(updatePari.isEstPaye());
|
||||
|
||||
// Pari pariUpdate = pariService.update(pari);
|
||||
// return ResponseEntity.ok(ticket); // Return the updated product
|
||||
// } else {
|
||||
// return ResponseEntity.status(404).body(ticket);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // @GetMapping("/course/{courseId}/type/{typePari}")
|
||||
// public ResponseEntity<List<Pari>> obtenirParisParCourseEtType(
|
||||
// @PathVariable Long courseId, @PathVariable TypeFormule typeFormule) {
|
||||
// return ResponseEntity.ok(pariService.obtenirParisParCourseEtType(courseId, typeFormule));
|
||||
// }
|
||||
|
||||
// // @GetMapping("/cheval/{chevalId}")
|
||||
// public ResponseEntity<List<Pari>> obtenirParisParCheval(@PathVariable Long chevalId) {
|
||||
// return ResponseEntity.ok(pariService.obtenirParisParCheval(chevalId));
|
||||
// }
|
||||
|
||||
// private Pari fromNewPariDto(NewPari newPari){
|
||||
// return Pari.builder()
|
||||
// .datePari(newPari.getDatePari())
|
||||
// .course(courseService.obtenirCourseParId(newPari.getCourseId()))
|
||||
// .cheval(numeroToCheval(newPari.getCheval()))
|
||||
// .cheval1(numeroToCheval(newPari.getCheval1()))
|
||||
// .cheval2(numeroToCheval(newPari.getCheval2()))
|
||||
// .cheval3(numeroToCheval(newPari.getCheval3()))
|
||||
// .chevauxOrdre(newPari.getChevauxOrdre())
|
||||
// .chevauxSelectionnes(fromIntegerList(newPari.getChevauxSelectionnes()))
|
||||
// .numeroTicket(newPari.getNumeroTicket())
|
||||
// .nomParieur(newPari.getNomParieur())
|
||||
// .idParieur(newPari.getIdParieur())
|
||||
// .statut(StatutParis.EN_ATTENTE)
|
||||
// .mise(newPari.getMise())
|
||||
// .premier(numeroToCheval(newPari.getPremier()))
|
||||
// .deuxieme(numeroToCheval(newPari.getDeuxieme()))
|
||||
// .troisieme(numeroToCheval(newPari.getTroisieme()))
|
||||
// .typeFormule(newPari.getTypeFormule())
|
||||
// .typePari(newPari.getTypePari())
|
||||
// .estRembourse(false)
|
||||
// .estPaye(false)
|
||||
// .typeMulti(newPari.getTypeMulti())
|
||||
// .ordrePredit(newPari.getOrdrePredit())
|
||||
// .validationOrdreExact(newPari.getValidationOrdreExact())
|
||||
// .build();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@@ -1,54 +1,150 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.Cheval;
|
||||
import com.pmu.betengine.model.Course;
|
||||
import com.pmu.betengine.model.Resultat;
|
||||
import com.pmu.betengine.model.dto.NewResultat;
|
||||
import com.pmu.betengine.model.dto.ResultatDto;
|
||||
import com.pmu.betengine.service.CourseService;
|
||||
import com.pmu.betengine.service.ResultatService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/resultat")
|
||||
@Tag(name = "Gestion des Resultats des Courses", description = "Endpoints relatifs à l'objet resultat")
|
||||
public class ResultatController {
|
||||
@Autowired
|
||||
private ResultatService resultatCourseService;
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
private final ResultatService resultatService;
|
||||
private final CourseService courseService;
|
||||
|
||||
public ResultatController(ResultatService resultatService, CourseService courseService) {
|
||||
this.resultatService = resultatService;
|
||||
this.courseService = courseService;
|
||||
}
|
||||
|
||||
// CREATE
|
||||
@PostMapping
|
||||
@Operation(summary = "Enregistrer le Resultat d'une course",
|
||||
description = "Méthode permettant d'enregistrer le résultat d'une course")
|
||||
public ResponseEntity<?> enregistrerResultat(@RequestBody NewResultat resultatDto) {
|
||||
try {
|
||||
resultatCourseService.save(fromNewResultat(resultatDto));
|
||||
return ResponseEntity.ok().build();
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.badRequest().body(e.getMessage());
|
||||
}
|
||||
}
|
||||
public ResponseEntity<Resultat> create(@RequestBody Resultat dto) {
|
||||
|
||||
private Resultat fromNewResultat(NewResultat resultat){
|
||||
Course course = courseService.getCourseById(dto.getCourse().getId());
|
||||
|
||||
return Resultat.builder()
|
||||
.course(courseService.obtenirCourseParId(resultat.getIdCourse().longValue()))
|
||||
.aDeadHeat(resultat.isADeadHeat())
|
||||
.premiers(fromIntegerList(resultat.getChevauxPremiers()))
|
||||
.seconds(fromIntegerList(resultat.getChevauxDeuxiemes()))
|
||||
.troisiemes(fromIntegerList(resultat.getChevauxTroisiemes()))
|
||||
.quatriemes(fromIntegerList(resultat.getChevauxQuatriemes()))
|
||||
.cinquiemes(fromIntegerList(resultat.getChevauxCinquiemes()))
|
||||
.ordreArrivee(fromIntegerList(resultat.getOrdreArrivee()))
|
||||
Resultat resultat = Resultat.builder()
|
||||
.course(course)
|
||||
.ordreArrivee(dto.getOrdreArrivee() != null ? dto.getOrdreArrivee() : List.of())
|
||||
.chevauxDeadHeat(dto.getChevauxDeadHeat())
|
||||
.aDeadHeat(dto.isADeadHeat())
|
||||
.totalMises(dto.getTotalMises())
|
||||
.masseAPartager(dto.getMasseAPartager())
|
||||
.prelevementsLegaux(dto.getPrelevementsLegaux())
|
||||
.montantRembourse(dto.getMontantRembourse())
|
||||
.montantCagnotte(dto.getMontantCagnotte())
|
||||
.build();
|
||||
|
||||
return ResponseEntity.ok(resultatService.save(resultat));
|
||||
}
|
||||
}
|
||||
|
||||
// GET ALL
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Resultat>> getAll() {
|
||||
return ResponseEntity.ok(resultatService.getAll());
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Resultat> getById(@PathVariable Long id) {
|
||||
Resultat r = resultatService.getById(id);
|
||||
return r != null ? ResponseEntity.ok(r) : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
// GET BY COURSE
|
||||
@GetMapping("/course/{courseId}")
|
||||
public ResponseEntity<Resultat> getByCourse(@PathVariable Long courseId) {
|
||||
Resultat r = resultatService.getByCourseId(courseId);
|
||||
return r != null ? ResponseEntity.ok(r) : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Resultat> update(@PathVariable Long id, @RequestBody Resultat update) {
|
||||
Resultat existing = resultatService.getById(id);
|
||||
|
||||
if (existing == null) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
update.setId(id);
|
||||
return ResponseEntity.ok(resultatService.save(update));
|
||||
}
|
||||
|
||||
// DELETE BY ID
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
resultatService.delete(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
// DELETE BY COURSE
|
||||
@DeleteMapping("/course/{courseId}")
|
||||
public ResponseEntity<Void> deleteByCourse(@PathVariable Long courseId) {
|
||||
resultatService.deleteByCourseId(courseId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.controller;
|
||||
|
||||
// import com.pmu.betengine.model.Resultat;
|
||||
// import com.pmu.betengine.model.dto.NewResultat;
|
||||
// import com.pmu.betengine.model.dto.ResultatDto;
|
||||
// import com.pmu.betengine.service.CourseService;
|
||||
// import com.pmu.betengine.service.ResultatService;
|
||||
// import io.swagger.v3.oas.annotations.Operation;
|
||||
// import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.http.ResponseEntity;
|
||||
// import org.springframework.web.bind.annotation.PostMapping;
|
||||
// import org.springframework.web.bind.annotation.RequestBody;
|
||||
// import org.springframework.web.bind.annotation.RequestMapping;
|
||||
// import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
// import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
||||
|
||||
// @RestController
|
||||
// @RequestMapping("/api/v1/resultat")
|
||||
// @Tag(name = "Gestion des Resultats des Courses", description = "Endpoints relatifs à l'objet resultat")
|
||||
// public class ResultatController {
|
||||
// @Autowired
|
||||
// private ResultatService resultatCourseService;
|
||||
|
||||
// @Autowired
|
||||
// private CourseService courseService;
|
||||
|
||||
// @PostMapping
|
||||
// @Operation(summary = "Enregistrer le Resultat d'une course",
|
||||
// description = "Méthode permettant d'enregistrer le résultat d'une course")
|
||||
// public ResponseEntity<?> enregistrerResultat(@RequestBody NewResultat resultatDto) {
|
||||
// try {
|
||||
// resultatCourseService.save(fromNewResultat(resultatDto));
|
||||
// return ResponseEntity.ok().build();
|
||||
// } catch (Exception e) {
|
||||
// return ResponseEntity.badRequest().body(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// private Resultat fromNewResultat(NewResultat resultat){
|
||||
|
||||
// return Resultat.builder()
|
||||
// .course(courseService.obtenirCourseParId(resultat.getIdCourse().longValue()))
|
||||
// .aDeadHeat(resultat.isADeadHeat())
|
||||
// .premiers(fromIntegerList(resultat.getChevauxPremiers()))
|
||||
// .seconds(fromIntegerList(resultat.getChevauxDeuxiemes()))
|
||||
// .troisiemes(fromIntegerList(resultat.getChevauxTroisiemes()))
|
||||
// .quatriemes(fromIntegerList(resultat.getChevauxQuatriemes()))
|
||||
// .cinquiemes(fromIntegerList(resultat.getChevauxCinquiemes()))
|
||||
// .ordreArrivee(fromIntegerList(resultat.getOrdreArrivee()))
|
||||
// .build();
|
||||
// }
|
||||
// }
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.pmu.betengine.controller;
|
||||
|
||||
import com.pmu.betengine.model.dto.ReunionDTO;
|
||||
import com.pmu.betengine.model.dto.ReunionRequestDTO;
|
||||
import com.pmu.betengine.model.Reunion;
|
||||
import com.pmu.betengine.service.ReunionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -14,8 +12,8 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/reunions")
|
||||
@Tag(name = "Gestion des Réunions des Courses", description = "Endpoints relatifs à l'objet Reunion")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Tag(name = "Gestion des Réunions", description = "Endpoints relatifs aux Réunions")
|
||||
public class ReunionController {
|
||||
|
||||
private final ReunionService reunionService;
|
||||
@@ -25,30 +23,38 @@ public class ReunionController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<ReunionDTO>> getAllReunions() {
|
||||
@Operation(summary = "Lister toutes les Réunions")
|
||||
public ResponseEntity<List<Reunion>> getAllReunions() {
|
||||
return ResponseEntity.ok(reunionService.getAllReunions());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ReunionDTO> getReunionById(@PathVariable Long id) {
|
||||
@Operation(summary = "Obtenir une Réunion par ID")
|
||||
public ResponseEntity<Reunion> getReunionById(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(reunionService.getReunionById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "Enregistrer Une réunion",
|
||||
description = "Méthode permettant d'enregistrer la réunion")
|
||||
public ResponseEntity<ReunionDTO> createReunion(@Valid @RequestBody ReunionRequestDTO requestDTO) {
|
||||
return new ResponseEntity<>(reunionService.createReunion(requestDTO), HttpStatus.CREATED);
|
||||
@Operation(summary = "Créer une Réunion")
|
||||
public ResponseEntity<Reunion> createReunion(@RequestBody Reunion reunion) {
|
||||
return new ResponseEntity<>(reunionService.createReunion(reunion), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<ReunionDTO> updateReunion(@PathVariable Long id, @Valid @RequestBody ReunionRequestDTO requestDTO) {
|
||||
return ResponseEntity.ok(reunionService.updateReunion(id, requestDTO));
|
||||
@Operation(summary = "Modifier une Réunion")
|
||||
public ResponseEntity<Reunion> updateReunion(@PathVariable Long id, @RequestBody Reunion reunion) {
|
||||
return ResponseEntity.ok(reunionService.updateReunion(id, reunion));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteReunion(@PathVariable Long id) {
|
||||
reunionService.deleteReunion(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
@Operation(summary = "Supprimer une Réunion")
|
||||
public ResponseEntity<String> deleteReunion(@PathVariable Long id) {
|
||||
return ResponseEntity.ok(reunionService.deleteReunion(id));
|
||||
}
|
||||
|
||||
@GetMapping("/code/{code}")
|
||||
@Operation(summary = "Obtenir une Réunion par code")
|
||||
public ResponseEntity<Reunion> getReunionByCode(@PathVariable String code) {
|
||||
return ResponseEntity.ok(reunionService.getReunionByCode(code));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,70 +16,137 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "agent")
|
||||
@Entity
|
||||
@Table(name = "agents")
|
||||
public class Agent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
private String profile;
|
||||
private String principalCode;
|
||||
private String caisseProfile;
|
||||
private StatutAgent statut;
|
||||
private String statut;
|
||||
private String zone;
|
||||
private String kiosk;
|
||||
private String fonction;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy")
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
private LocalDate dateEmbauche;
|
||||
@NotBlank(message = "Le nom est obligatoire")
|
||||
|
||||
@Column(name = "date_embauche")
|
||||
private LocalDateTime dateEmbauche;
|
||||
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String autresNoms;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date de naissance doit être au format dd/MM/yyyy")
|
||||
@Column(name = "date_naissance", nullable = false)
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
|
||||
@Column(name = "date_naissance")
|
||||
private LocalDate dateNaissance;
|
||||
|
||||
private String lieuNaissance;
|
||||
private String ville;
|
||||
private String adresse;
|
||||
private Boolean autoriserAides;
|
||||
private String phone;
|
||||
private String pin;
|
||||
|
||||
private Double limiteInferieure;
|
||||
private Double limiteSuperieure;
|
||||
private Double limiteParTransaction;
|
||||
private Double limiteMinAirtime;
|
||||
private Double limiteMaxAirtime;
|
||||
|
||||
private Integer maxPeripheriques;
|
||||
private String limitId;
|
||||
// Légales
|
||||
|
||||
@Column(name = "limit_id")
|
||||
private Long limitId;
|
||||
|
||||
private String nationalite;
|
||||
private String cni;
|
||||
private String cniDelivreeLe;
|
||||
|
||||
@Column(name = "cni_delivree_le")
|
||||
private LocalDate cniDelivreeLe;
|
||||
|
||||
private String cniDelivreeA;
|
||||
private String residence;
|
||||
private String autreAdresse1;
|
||||
private String statutMarital;
|
||||
private String epoux;
|
||||
private String autreTelephone;
|
||||
// Situation familiale
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "agent_famille",
|
||||
joinColumns = @JoinColumn(name = "agent_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "famille_id"))
|
||||
private List<AgentFamilyMember> famille;
|
||||
// TPE assignés
|
||||
private String [] assignedTpeIds;
|
||||
@CreationTimestamp
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
@UpdateTimestamp
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column(name = "created_by")
|
||||
private String createdBy;
|
||||
}
|
||||
|
||||
// @Table(name = "agent")
|
||||
// public class Agent {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
|
||||
// private String code;
|
||||
// private String profile;
|
||||
// private String principalCode;
|
||||
// private String caisseProfile;
|
||||
// private StatutAgent statut;
|
||||
// private String zone;
|
||||
// private String kiosk;
|
||||
// private String fonction;
|
||||
// @Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy")
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
// private LocalDate dateEmbauche;
|
||||
// @NotBlank(message = "Le nom est obligatoire")
|
||||
// private String nom;
|
||||
// private String prenom;
|
||||
// private String autresNoms;
|
||||
// @Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date de naissance doit être au format dd/MM/yyyy")
|
||||
// @Column(name = "date_naissance", nullable = false)
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
// private LocalDate dateNaissance;
|
||||
// private String lieuNaissance;
|
||||
// private String ville;
|
||||
// private String adresse;
|
||||
// private Boolean autoriserAides;
|
||||
// private String phone;
|
||||
// private String pin;
|
||||
// private Double limiteInferieure;
|
||||
// private Double limiteSuperieure;
|
||||
// private Double limiteParTransaction;
|
||||
// private Double limiteMinAirtime;
|
||||
// private Double limiteMaxAirtime;
|
||||
// private Integer maxPeripheriques;
|
||||
// private String limitId;
|
||||
// // Légales
|
||||
// private String nationalite;
|
||||
// private String cni;
|
||||
// private String cniDelivreeLe;
|
||||
// private String cniDelivreeA;
|
||||
// private String residence;
|
||||
// private String autreAdresse1;
|
||||
// private String statutMarital;
|
||||
// private String epoux;
|
||||
// private String autreTelephone;
|
||||
// // Situation familiale
|
||||
// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
// @JoinTable(name = "agent_famille",
|
||||
// joinColumns = @JoinColumn(name = "agent_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "famille_id"))
|
||||
// private List<AgentFamilyMember> famille;
|
||||
// // TPE assignés
|
||||
// private String [] assignedTpeIds;
|
||||
// @CreationTimestamp
|
||||
// private LocalDateTime createdAt;
|
||||
// @UpdateTimestamp
|
||||
// private LocalDateTime updatedAt;
|
||||
// private String createdBy;
|
||||
// }
|
||||
|
||||
@@ -12,25 +12,45 @@ import lombok.NoArgsConstructor;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "agent_family_member")
|
||||
@Entity
|
||||
@Table(name = "agent_family_members")
|
||||
public class AgentFamilyMember {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
@NotBlank(message = "Le nom est obligatoire")
|
||||
public String nom;
|
||||
public String statut;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date de naissance doit être au format dd/MM/yyyy")
|
||||
@Column(name = "date_naissance", nullable = false)
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
public LocalDate dateNaissance;
|
||||
@NotBlank(message = "Le sexe est obligatoire")
|
||||
@Pattern(regexp = "^(M|F)$", message = "Le sexe doit être M (Masculin) ou F (Féminin)")
|
||||
@Column(nullable = false, length = 1)
|
||||
public String sexe;
|
||||
|
||||
@Column(name = "agent_id")
|
||||
private Long agentId;
|
||||
|
||||
private String nom;
|
||||
private String statut;
|
||||
|
||||
@Column(name = "date_naissance")
|
||||
private LocalDate dateNaissance;
|
||||
|
||||
private String sexe;
|
||||
}
|
||||
|
||||
// @Table(name = "agent_family_member")
|
||||
// public class AgentFamilyMember {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
// @NotBlank(message = "Le nom est obligatoire")
|
||||
// public String nom;
|
||||
// public String statut;
|
||||
// @Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date de naissance doit être au format dd/MM/yyyy")
|
||||
// @Column(name = "date_naissance", nullable = false)
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
// public LocalDate dateNaissance;
|
||||
// @NotBlank(message = "Le sexe est obligatoire")
|
||||
// @Pattern(regexp = "^(M|F)$", message = "Le sexe doit être M (Masculin) ou F (Féminin)")
|
||||
// @Column(nullable = false, length = 1)
|
||||
// public String sexe;
|
||||
// }
|
||||
|
||||
@@ -10,8 +10,10 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@@ -20,37 +22,105 @@ import java.util.List;
|
||||
@Builder
|
||||
@Table(name = "course")
|
||||
public class Course {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String numero;
|
||||
@OneToOne
|
||||
private Reunion reunion;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy HH:mm:ss")
|
||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
@Column(name = "heure_course")
|
||||
private LocalDateTime heureCourse;
|
||||
private String lieu;
|
||||
private int nombreChevauxInscrits;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer numero;
|
||||
|
||||
private String nom;
|
||||
|
||||
@Column(name = "date_depart_course")
|
||||
private LocalDateTime dateDepartCourse;
|
||||
|
||||
@Column(name = "date_debut_paris")
|
||||
private LocalDateTime dateDebutParis;
|
||||
|
||||
@Column(name = "date_fin_paris")
|
||||
private LocalDateTime dateFinParis;
|
||||
|
||||
@Column(name = "reunion_id")
|
||||
private Long reunionId;
|
||||
|
||||
@Column(name = "reunion_course")
|
||||
private Integer reunionCourse;
|
||||
|
||||
private String particularite;
|
||||
|
||||
private Integer partants;
|
||||
|
||||
private Integer distance;
|
||||
|
||||
private String condition;
|
||||
|
||||
private boolean estTerminee;
|
||||
private boolean estAnnulee;
|
||||
private boolean aDeadHeat;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private StatutCourse statut;
|
||||
private String statut;
|
||||
|
||||
@OneToOne(mappedBy = "course")
|
||||
private Resultat resultat;
|
||||
private int nombreChevauxInscrits;
|
||||
|
||||
@Column(name = "resultat_statut")
|
||||
private String resultatStatut;
|
||||
|
||||
@Column(name = "created_by")
|
||||
private String createdBy;
|
||||
|
||||
@Column(name = "validated_by")
|
||||
private String validatedBy;
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@OneToMany(mappedBy = "course", cascade = CascadeType.ALL)
|
||||
private List<NonPartant> nonPartants;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "course_chevaux",
|
||||
joinColumns = @JoinColumn(name = "course_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> chevaux;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,mappedBy = "course")
|
||||
private List<Pari> paris;
|
||||
public boolean estEligiblePourTrioOrdre() {
|
||||
return chevaux != null && chevaux.size() >= 3 && chevaux.size() <= 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public class Course {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
// private String numero;
|
||||
|
||||
// // FIX 1: Changement de @OneToOne à @ManyToOne (Une course appartient à une seule réunion)
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "reunion_id", nullable = false)
|
||||
// private Reunion reunion;
|
||||
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
// @Column(name = "heure_course")
|
||||
// private LocalDateTime heureCourse;
|
||||
// private String lieu;
|
||||
// private int nombreChevauxInscrits;
|
||||
// private boolean estTerminee;
|
||||
// private boolean estAnnulee;
|
||||
// private boolean aDeadHeat;
|
||||
|
||||
// @Enumerated(EnumType.STRING)
|
||||
// private StatutCourse statut;
|
||||
|
||||
// @OneToOne(mappedBy = "course")
|
||||
// private Resultat resultat;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "course_chevaux",
|
||||
// joinColumns = @JoinColumn(name = "course_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> chevaux;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,mappedBy = "course")
|
||||
// private List<Pari> paris;
|
||||
|
||||
// public boolean estEligiblePourTrioOrdre() {
|
||||
// return chevaux != null && chevaux.size() >= 3 && chevaux.size() <= 7;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.pmu.betengine.model;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "course_report_detail_rows")
|
||||
public class CourseReportDetailRow {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(name = "detail_id")
|
||||
private Long detailId;
|
||||
|
||||
@Column(name = "type_gain")
|
||||
private String typeGain;
|
||||
|
||||
@Column(name = "type_jeu")
|
||||
private String typeJeu;
|
||||
|
||||
private Double montant;
|
||||
|
||||
private Integer nombre;
|
||||
|
||||
private String statut;
|
||||
|
||||
private Boolean distributed;
|
||||
|
||||
private Boolean externe;
|
||||
}
|
||||
|
||||
@@ -11,28 +11,52 @@ import org.hibernate.annotations.UpdateTimestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "hippodrome")
|
||||
@Entity
|
||||
@Table(name = "hippodromes")
|
||||
public class Hippodrome {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
public String nom;
|
||||
public String ville;
|
||||
public String pays;
|
||||
public boolean actif;
|
||||
public Integer capacite;
|
||||
public String description;
|
||||
@CreationTimestamp
|
||||
private LocalDateTime createdAt;
|
||||
@UpdateTimestamp
|
||||
private LocalDateTime updatedAt;
|
||||
private String nom;
|
||||
private String ville;
|
||||
private String pays;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "hippodrome")
|
||||
private List<Reunion> reunions;
|
||||
private Boolean actif;
|
||||
private Integer capacite;
|
||||
|
||||
private String description;
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
|
||||
// @Table(name = "hippodrome")
|
||||
// public class Hippodrome {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
|
||||
// public String nom;
|
||||
// public String ville;
|
||||
// public String pays;
|
||||
// public boolean actif;
|
||||
// public Integer capacite;
|
||||
// public String description;
|
||||
// @CreationTimestamp
|
||||
// private LocalDateTime createdAt;
|
||||
// @UpdateTimestamp
|
||||
// private LocalDateTime updatedAt;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "hippodrome")
|
||||
// private List<Reunion> reunions;
|
||||
// }
|
||||
|
||||
41
src/main/java/com/pmu/betengine/model/NonPartant.java
Normal file
41
src/main/java/com/pmu/betengine/model/NonPartant.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.pmu.betengine.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "non_partants")
|
||||
public class NonPartant {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "course_id")
|
||||
private Course course;
|
||||
|
||||
private Integer numero;
|
||||
|
||||
@Column(name = "nom_cheval")
|
||||
private String nomCheval;
|
||||
|
||||
private String motif;
|
||||
|
||||
@Column(name = "declare_par")
|
||||
private String declarePar;
|
||||
|
||||
@Column(name = "date_declaration")
|
||||
private LocalDateTime dateDeclaration;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.pmu.betengine.model.type.TypeFormule;
|
||||
import com.pmu.betengine.model.type.TypeMulti;
|
||||
import com.pmu.betengine.model.type.TypePari;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -15,94 +14,155 @@ import lombok.NoArgsConstructor;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "pari")
|
||||
public class Pari{
|
||||
public class Pari {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String numeroTicket;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "type_pari")
|
||||
private TypePari typePari;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "type_formule")
|
||||
private TypeFormule typeFormule; // GAGNANT ou PLACE
|
||||
private TypeFormule typeFormule;
|
||||
|
||||
private double mise = 500.0;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy HH:mm:ss")
|
||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
|
||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
|
||||
private LocalDateTime datePari;
|
||||
|
||||
private boolean estPaye;
|
||||
private boolean estRembourse;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private StatutParis statut;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "course_id")
|
||||
private Course course;
|
||||
@Column(name = "parieur_id")
|
||||
private String idParieur;
|
||||
private String nomParieur;
|
||||
private StatutParis statut;
|
||||
private Double gain;
|
||||
|
||||
///////////////////Cheval////
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "cheval_id")
|
||||
private Cheval cheval;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "cheval1_id")
|
||||
private Cheval cheval1;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "cheval2_id")
|
||||
private Cheval cheval2;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "cheval3_id")
|
||||
private Cheval cheval3;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private Cheval premier;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private Cheval deuxieme;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private Cheval troisieme;
|
||||
|
||||
// TRIPLET
|
||||
// LIST OF SELECTED CHEVAL NUMBERS (Integer list)
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "pari_chevaux_ordre", joinColumns = @JoinColumn(name = "pari_id"))
|
||||
@Column(name = "cheval_id")
|
||||
@OrderColumn(name = "position")
|
||||
private List<Integer> chevauxOrdre;
|
||||
|
||||
// QUATRO, QUARTE PLUS, MULTI,
|
||||
@ManyToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "pari_chevaux",
|
||||
joinColumns = @JoinColumn(name = "pari_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> chevauxSelectionnes;
|
||||
|
||||
private List<Integer> chevauxSelectionnes;
|
||||
@ElementCollection
|
||||
private List<Integer> ordrePredit;
|
||||
private Boolean validationOrdreExact;
|
||||
|
||||
// MULTI
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TypeMulti typeMulti;
|
||||
|
||||
|
||||
public boolean estFormuleChamp() {
|
||||
return typeFormule.name().contains("CHAMP");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// package com.pmu.betengine.model;
|
||||
|
||||
// import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
// import com.pmu.betengine.model.statut.StatutParis;
|
||||
// import com.pmu.betengine.model.type.TypeFormule;
|
||||
// import com.pmu.betengine.model.type.TypeMulti;
|
||||
// import com.pmu.betengine.model.type.TypePari;
|
||||
// import jakarta.persistence.*;
|
||||
// import jakarta.validation.constraints.Pattern;
|
||||
// import lombok.AllArgsConstructor;
|
||||
// import lombok.Builder;
|
||||
// import lombok.Data;
|
||||
// import lombok.NoArgsConstructor;
|
||||
|
||||
// import java.time.LocalDateTime;
|
||||
// import java.util.List;
|
||||
|
||||
|
||||
// @Entity
|
||||
// @Data
|
||||
// @Builder
|
||||
// @NoArgsConstructor
|
||||
// @AllArgsConstructor
|
||||
// @Table(name = "pari")
|
||||
// public class Pari{
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
|
||||
// @Column(nullable = false)
|
||||
// private String numeroTicket;
|
||||
|
||||
// @Column(name = "type_pari")
|
||||
// private TypePari typePari;
|
||||
|
||||
// @Column(name = "type_formule")
|
||||
// private TypeFormule typeFormule; // GAGNANT ou PLACE
|
||||
// private double mise = 500.0;
|
||||
// @Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy HH:mm:ss")
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
// private LocalDateTime datePari;
|
||||
|
||||
// private boolean estPaye;
|
||||
// private boolean estRembourse;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// @JoinColumn(name = "course_id")
|
||||
// private Course course;
|
||||
// @Column(name = "parieur_id")
|
||||
// private String idParieur;
|
||||
// private String nomParieur;
|
||||
// private StatutParis statut;
|
||||
// private Double gain;
|
||||
|
||||
// ///////////////////Cheval////
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// @JoinColumn(name = "cheval_id")
|
||||
// private Cheval cheval;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// @JoinColumn(name = "cheval1_id")
|
||||
// private Cheval cheval1;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// @JoinColumn(name = "cheval2_id")
|
||||
// private Cheval cheval2;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// @JoinColumn(name = "cheval3_id")
|
||||
// private Cheval cheval3;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// private Cheval premier;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// private Cheval deuxieme;
|
||||
|
||||
// @ManyToOne(cascade = CascadeType.ALL)
|
||||
// private Cheval troisieme;
|
||||
|
||||
// // TRIPLET
|
||||
// @ElementCollection
|
||||
// @CollectionTable(name = "pari_chevaux_ordre", joinColumns = @JoinColumn(name = "pari_id"))
|
||||
// @Column(name = "cheval_id")
|
||||
// @OrderColumn(name = "position")
|
||||
// private List<Integer> chevauxOrdre;
|
||||
|
||||
// // QUATRO, QUARTE PLUS, MULTI,
|
||||
// @ManyToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
|
||||
// @JoinTable(name = "pari_chevaux",
|
||||
// joinColumns = @JoinColumn(name = "pari_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> chevauxSelectionnes;
|
||||
|
||||
// @ElementCollection
|
||||
// private List<Integer> ordrePredit;
|
||||
// private Boolean validationOrdreExact;
|
||||
|
||||
// // MULTI
|
||||
// @Enumerated(EnumType.STRING)
|
||||
// private TypeMulti typeMulti;
|
||||
|
||||
|
||||
// public boolean estFormuleChamp() {
|
||||
// return typeFormule.name().contains("CHAMP");
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
@@ -28,36 +28,6 @@ public class Resultat {
|
||||
@OrderColumn(name = "ordre_position")
|
||||
private List<Cheval> ordreArrivee;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "resultat_premiers",
|
||||
joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> premiers;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "resultat_seconds",
|
||||
joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> seconds;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "resultat_troisiemes",
|
||||
joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> troisiemes;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "resultat_quatriemes",
|
||||
joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> quatriemes;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "resultat_cinquiemes",
|
||||
joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> cinquiemes;
|
||||
|
||||
@ElementCollection
|
||||
private List<Long> chevauxDeadHeat;
|
||||
|
||||
@@ -75,3 +45,83 @@ public class Resultat {
|
||||
@Column(name = "montant_cagnotte")
|
||||
private double montantCagnotte;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.model;
|
||||
|
||||
// import jakarta.persistence.*;
|
||||
// import lombok.AllArgsConstructor;
|
||||
// import lombok.Builder;
|
||||
// import lombok.Data;
|
||||
// import lombok.NoArgsConstructor;
|
||||
|
||||
// import java.util.List;
|
||||
|
||||
// @Entity
|
||||
// @Data
|
||||
// @Builder
|
||||
// @NoArgsConstructor
|
||||
// @AllArgsConstructor
|
||||
// @Table(name = "resultat")
|
||||
// public class Resultat {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
|
||||
// @OneToOne
|
||||
// @JoinColumn(name = "course_id")
|
||||
// private Course course;
|
||||
|
||||
// @ManyToMany
|
||||
// @CollectionTable(name = "resultat_ordre_arrivee")
|
||||
// @OrderColumn(name = "ordre_position")
|
||||
// private List<Cheval> ordreArrivee;
|
||||
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "resultat_premiers",
|
||||
// joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> premiers;
|
||||
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "resultat_seconds",
|
||||
// joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> seconds;
|
||||
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "resultat_troisiemes",
|
||||
// joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> troisiemes;
|
||||
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "resultat_quatriemes",
|
||||
// joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> quatriemes;
|
||||
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "resultat_cinquiemes",
|
||||
// joinColumns = @JoinColumn(name = "resultat_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> cinquiemes;
|
||||
|
||||
// @ElementCollection
|
||||
// private List<Long> chevauxDeadHeat;
|
||||
|
||||
// private boolean aDeadHeat;
|
||||
|
||||
|
||||
// @Column(name = "total_mises")
|
||||
// private double totalMises;
|
||||
// @Column(name = "masse_apartager")
|
||||
// private double masseAPartager;
|
||||
// @Column(name = "prelevements_legaux")
|
||||
// private double prelevementsLegaux;
|
||||
// @Column(name = "montant_rembourse")
|
||||
// private double montantRembourse;
|
||||
// @Column(name = "montant_cagnotte")
|
||||
// private double montantCagnotte;
|
||||
// }
|
||||
|
||||
@@ -10,7 +10,9 @@ import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@@ -19,26 +21,54 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
@Table(name = "reunion")
|
||||
public class Reunion {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
public String code;
|
||||
public String nom;
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
private LocalDateTime date;
|
||||
public int numero;
|
||||
public StatutReunion statut;
|
||||
private String code;
|
||||
private String nom;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "hippodrome_id")
|
||||
public Hippodrome hippodrome;
|
||||
private LocalDate date;
|
||||
|
||||
public Integer totalCourses;
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
@CreationTimestamp
|
||||
private Integer numero;
|
||||
|
||||
private String statut;
|
||||
|
||||
@Column(name = "hippodrome_id")
|
||||
private Long hippodromeId;
|
||||
|
||||
@Column(name = "total_courses")
|
||||
private Integer totalCourses;
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
||||
@UpdateTimestamp
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
|
||||
// public class Reunion {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
|
||||
// public String code;
|
||||
// public String nom;
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy HH:mm", shape = JsonFormat.Shape.STRING)
|
||||
// private LocalDateTime date;
|
||||
// public int numero;
|
||||
// public StatutReunion statut;
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "hippodrome_id")
|
||||
// public Hippodrome hippodrome;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "reunion", cascade = CascadeType.ALL)
|
||||
// private List<Course> courses;
|
||||
|
||||
// public Integer totalCourses;
|
||||
// @CreationTimestamp
|
||||
// private LocalDateTime createdAt;
|
||||
// @UpdateTimestamp
|
||||
// private LocalDateTime updatedAt;
|
||||
// }
|
||||
44
src/main/java/com/pmu/betengine/model/User.java
Normal file
44
src/main/java/com/pmu/betengine/model/User.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.pmu.betengine.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private UUID id;
|
||||
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String identifiant;
|
||||
private String matriculeAgent;
|
||||
|
||||
@Column(name = "role_id")
|
||||
private UUID roleId;
|
||||
|
||||
private Boolean restrictionConnexion;
|
||||
private Boolean restrictionAutomatique;
|
||||
|
||||
private Integer nombreIpAutorise;
|
||||
private Integer nombreIpAutoAutorise;
|
||||
|
||||
private String statut;
|
||||
|
||||
@Column(name = "derniere_connexion")
|
||||
private LocalDateTime derniereConnexion;
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.pmu.betengine.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.pmu.betengine.model.statut.StatutReunion;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ReunionRequestDTO {
|
||||
private String code;
|
||||
private String nom;
|
||||
private String date;
|
||||
|
||||
// FIX: Changé String à LocalDateTime et ajouté le formatage
|
||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm", shape = JsonFormat.Shape.STRING)
|
||||
private LocalDateTime date;
|
||||
|
||||
private int numero;
|
||||
private StatutReunion statut;
|
||||
private Integer totalCourses;
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface AgentFamilyMemberRepository extends JpaRepository<AgentFamilyMember, Long> {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.AgentLimit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface AgentLimitRepository extends JpaRepository<AgentLimit, Long> {
|
||||
|
||||
Optional<AgentLimit> findByCode(String code);
|
||||
|
||||
List<AgentLimit> findByActif(boolean actif);
|
||||
|
||||
boolean existsByCode(String code);
|
||||
|
||||
List<AgentLimit> findByNomContainingIgnoreCase(String nom);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.Agent;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface AgentRepository extends JpaRepository<Agent, Long> {
|
||||
|
||||
Optional<Agent> findByCode(String code);
|
||||
|
||||
boolean existsByCode(String code);
|
||||
|
||||
List<Agent> findByStatut(String statut);
|
||||
|
||||
List<Agent> findByVille(String ville);
|
||||
|
||||
List<Agent> findByProfile(String profile);
|
||||
|
||||
List<Agent> findByNomContainingIgnoreCaseOrPrenomContainingIgnoreCase(String nom, String prenom);
|
||||
}
|
||||
@@ -9,7 +9,11 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ChevalRepository extends JpaRepository<Cheval, Long> {
|
||||
//List<Cheval> findByCourseId(Long courseId);
|
||||
|
||||
List<Cheval> findByNomEcurie(String nomEcurie);
|
||||
Optional<Cheval> getChevalByNumero (int numero);
|
||||
|
||||
Optional<Cheval> getChevalByNumero(int numero);
|
||||
|
||||
// Placeholder for future relation with Course
|
||||
// List<Cheval> findByCourseId(Long courseId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.CourseReportDetailRow;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CourseReportDetailRowRepository extends JpaRepository<CourseReportDetailRow, Long> {
|
||||
|
||||
List<CourseReportDetailRow> findByDetailId(Long detailId);
|
||||
|
||||
List<CourseReportDetailRow> findByTypeGain(String typeGain);
|
||||
|
||||
List<CourseReportDetailRow> findByTypeJeu(String typeJeu);
|
||||
|
||||
List<CourseReportDetailRow> findByStatut(String statut);
|
||||
|
||||
List<CourseReportDetailRow> findByDistributed(Boolean distributed);
|
||||
|
||||
List<CourseReportDetailRow> findByExterne(Boolean externe);
|
||||
}
|
||||
@@ -5,8 +5,14 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface CourseRepository extends JpaRepository<Course, Long> {
|
||||
|
||||
// Find courses by "estTerminee" boolean (if you still track this)
|
||||
List<Course> findByEstTerminee(boolean estTerminee);
|
||||
|
||||
// Search courses by name
|
||||
List<Course> findByNomContainingIgnoreCase(String nom);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.Hippodrome;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface HippodromeRepository extends JpaRepository<Hippodrome, Long> {
|
||||
|
||||
Optional<Hippodrome> findByNom(String nom);
|
||||
|
||||
boolean existsByNom(String nom);
|
||||
|
||||
List<Hippodrome> findByVille(String ville);
|
||||
|
||||
@@ -19,10 +17,5 @@ public interface HippodromeRepository extends JpaRepository<Hippodrome, Long> {
|
||||
|
||||
List<Hippodrome> findByActif(boolean actif);
|
||||
|
||||
boolean existsByNom(String nom);
|
||||
|
||||
@Query("SELECT h FROM Hippodrome h WHERE h.nom LIKE %:nom%")
|
||||
List<Hippodrome> findByNomContaining(String nom);
|
||||
|
||||
Optional<Hippodrome> findByReunionId(Long reunionId);
|
||||
List<Hippodrome> findByNomContainingIgnoreCase(String nom);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.NonPartant;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface NonPartantRepository extends JpaRepository<NonPartant, Long> {
|
||||
|
||||
List<NonPartant> findByCourseId(Long courseId);
|
||||
|
||||
List<NonPartant> findByNomChevalContainingIgnoreCase(String nomCheval);
|
||||
|
||||
List<NonPartant> findByMotifContainingIgnoreCase(String motif);
|
||||
}
|
||||
@@ -3,17 +3,37 @@ package com.pmu.betengine.repository;
|
||||
import com.pmu.betengine.model.Pari;
|
||||
import com.pmu.betengine.model.type.TypeFormule;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface PariRepository extends JpaRepository<Pari, Long> {
|
||||
List<Pari> findByCourseId(Long courseId);
|
||||
List<Pari> findByCourseIdAndTypeFormule(Long courseId, TypeFormule typeFormule);
|
||||
List<Pari> findByChevalId(Long chevalId);
|
||||
|
||||
Optional<Pari> findByNumeroTicket(String ticket);
|
||||
|
||||
// List<Pari> findByChevalIdAndTypePari(Long chevalId, String typePari);
|
||||
}
|
||||
List<Pari> findByCourseId(Long courseId);
|
||||
|
||||
List<Pari> findByCourseIdAndTypeFormule(Long courseId, TypeFormule typeFormule);
|
||||
}
|
||||
|
||||
|
||||
// package com.pmu.betengine.repository;
|
||||
|
||||
// import com.pmu.betengine.model.Pari;
|
||||
// import com.pmu.betengine.model.type.TypeFormule;
|
||||
// import org.springframework.data.jpa.repository.JpaRepository;
|
||||
// import org.springframework.stereotype.Repository;
|
||||
|
||||
// import java.util.List;
|
||||
// import java.util.Optional;
|
||||
|
||||
// @Repository
|
||||
// public interface PariRepository extends JpaRepository<Pari, Long> {
|
||||
// List<Pari> findByCourseId(Long courseId);
|
||||
// List<Pari> findByCourseIdAndTypeFormule(Long courseId, TypeFormule typeFormule);
|
||||
// List<Pari> findByChevalId(Long chevalId);
|
||||
// Optional<Pari> findByNumeroTicket(String ticket);
|
||||
|
||||
// // List<Pari> findByChevalIdAndTypePari(Long chevalId, String typePari);
|
||||
// }
|
||||
@@ -2,24 +2,54 @@ package com.pmu.betengine.repository;
|
||||
|
||||
import com.pmu.betengine.model.Resultat;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ResultatRepository extends JpaRepository<Resultat, Long> {
|
||||
|
||||
Optional<Resultat> findByCourseId(Long courseId);
|
||||
|
||||
@Query("SELECT r FROM Resultat r WHERE r.course.id = :courseId")
|
||||
Optional<Resultat> findByCourse(@Param("courseId") Long courseId);
|
||||
|
||||
@Query("SELECT CASE WHEN COUNT(r) > 0 THEN true ELSE false END FROM Resultat r WHERE r.course.id = :courseId")
|
||||
boolean existsByCourseId(@Param("courseId") Long courseId);
|
||||
boolean existsByCourseId(Long courseId);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("DELETE FROM Resultat r WHERE r.course.id = :courseId")
|
||||
void deleteByCourseId(@Param("courseId") Long courseId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// package com.pmu.betengine.repository;
|
||||
|
||||
// import com.pmu.betengine.model.Resultat;
|
||||
// import org.springframework.data.jpa.repository.JpaRepository;
|
||||
// import org.springframework.data.jpa.repository.Query;
|
||||
// import org.springframework.data.repository.query.Param;
|
||||
// import org.springframework.stereotype.Repository;
|
||||
|
||||
// import java.util.Optional;
|
||||
|
||||
// @Repository
|
||||
// public interface ResultatRepository extends JpaRepository<Resultat, Long> {
|
||||
// Optional<Resultat> findByCourseId(Long courseId);
|
||||
|
||||
// @Query("SELECT r FROM Resultat r WHERE r.course.id = :courseId")
|
||||
// Optional<Resultat> findByCourse(@Param("courseId") Long courseId);
|
||||
|
||||
// @Query("SELECT CASE WHEN COUNT(r) > 0 THEN true ELSE false END FROM Resultat r WHERE r.course.id = :courseId")
|
||||
// boolean existsByCourseId(@Param("courseId") Long courseId);
|
||||
|
||||
// @Query("DELETE FROM Resultat r WHERE r.course.id = :courseId")
|
||||
// void deleteByCourseId(@Param("courseId") Long courseId);
|
||||
|
||||
|
||||
// }
|
||||
@@ -8,6 +8,8 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ReunionRepository extends JpaRepository<Reunion, Long> {
|
||||
|
||||
Optional<Reunion> findByCode(String code);
|
||||
|
||||
boolean existsByCode(String code);
|
||||
}
|
||||
|
||||
@@ -1,121 +1,84 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.AgentFamilyMember;
|
||||
import com.pmu.betengine.model.dto.AgentFamilyMemberDTO;
|
||||
import com.pmu.betengine.model.dto.AgentFamilyMemberRequestDTO;
|
||||
import com.pmu.betengine.repository.AgentFamilyMemberRepository;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AgentFamilyMemberService {
|
||||
|
||||
private final AgentFamilyMemberRepository agentFamilyMemberRepository;
|
||||
private final ModelMapper modelMapper;
|
||||
private final AgentFamilyMemberRepository repository;
|
||||
|
||||
public AgentFamilyMemberService(AgentFamilyMemberRepository agentFamilyMemberRepository,
|
||||
ModelMapper modelMapper) {
|
||||
this.agentFamilyMemberRepository = agentFamilyMemberRepository;
|
||||
this.modelMapper = modelMapper;
|
||||
public AgentFamilyMemberService(AgentFamilyMemberRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<AgentFamilyMemberDTO> getAllFamilyMembers() {
|
||||
return agentFamilyMemberRepository.findAllOrderByNom()
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
// Create
|
||||
public AgentFamilyMember createFamilyMember(AgentFamilyMember member) {
|
||||
if (repository.existsByNomAndDateNaissance(member.getNom(), member.getDateNaissance())) {
|
||||
throw new RuntimeException("Un membre avec ce nom et cette date de naissance existe déjà");
|
||||
}
|
||||
return repository.save(member);
|
||||
}
|
||||
|
||||
public AgentFamilyMemberDTO getFamilyMemberById(Long id) {
|
||||
AgentFamilyMember member = agentFamilyMemberRepository.findById(id)
|
||||
// Get all
|
||||
public List<AgentFamilyMember> getAllFamilyMembers() {
|
||||
return repository.findAllOrderByNom();
|
||||
}
|
||||
|
||||
// Get by ID
|
||||
public AgentFamilyMember getFamilyMemberById(Long id) {
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Membre de famille non trouvé avec l'id: " + id));
|
||||
return convertToDTO(member);
|
||||
}
|
||||
|
||||
public AgentFamilyMemberDTO createFamilyMember(AgentFamilyMemberRequestDTO requestDTO) {
|
||||
// Vérifier si le membre existe déjà
|
||||
if (agentFamilyMemberRepository.existsByNomAndDateNaissance(requestDTO.getNom(), requestDTO.getDateNaissance())) {
|
||||
// Update
|
||||
public AgentFamilyMember updateFamilyMember(Long id, AgentFamilyMember updated) {
|
||||
AgentFamilyMember existing = getFamilyMemberById(id);
|
||||
|
||||
// Vérification des doublons sauf pour l'enregistrement courant
|
||||
if ((!existing.getNom().equals(updated.getNom()) ||
|
||||
!existing.getDateNaissance().equals(updated.getDateNaissance())) &&
|
||||
repository.existsByNomAndDateNaissance(updated.getNom(), updated.getDateNaissance())) {
|
||||
throw new RuntimeException("Un membre avec ce nom et cette date de naissance existe déjà");
|
||||
}
|
||||
|
||||
AgentFamilyMember member = convertToEntity(requestDTO);
|
||||
AgentFamilyMember saved = agentFamilyMemberRepository.save(member);
|
||||
return convertToDTO(saved);
|
||||
existing.setAgentId(updated.getAgentId());
|
||||
existing.setNom(updated.getNom());
|
||||
existing.setStatut(updated.getStatut());
|
||||
existing.setDateNaissance(updated.getDateNaissance());
|
||||
existing.setSexe(updated.getSexe());
|
||||
|
||||
return repository.save(existing);
|
||||
}
|
||||
|
||||
public AgentFamilyMemberDTO updateFamilyMember(Long id, AgentFamilyMemberRequestDTO requestDTO) {
|
||||
AgentFamilyMember existing = agentFamilyMemberRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Membre de famille non trouvé avec l'id: " + id));
|
||||
|
||||
// Vérifier les doublons (sauf pour l'enregistrement actuel)
|
||||
if (!existing.getNom().equals(requestDTO.getNom()) ||
|
||||
!existing.getDateNaissance().equals(requestDTO.getDateNaissance())) {
|
||||
|
||||
if (agentFamilyMemberRepository.existsByNomAndDateNaissance(requestDTO.getNom(), requestDTO.getDateNaissance())) {
|
||||
throw new RuntimeException("Un membre avec ce nom et cette date de naissance existe déjà");
|
||||
}
|
||||
}
|
||||
|
||||
// Mise à jour des champs
|
||||
modelMapper.map(requestDTO, existing);
|
||||
|
||||
return convertToDTO(agentFamilyMemberRepository.save(existing));
|
||||
}
|
||||
|
||||
public void deleteFamilyMember(Long id) {
|
||||
if (!agentFamilyMemberRepository.existsById(id)) {
|
||||
// Delete
|
||||
public String deleteFamilyMember(Long id) {
|
||||
if (!repository.existsById(id)) {
|
||||
throw new RuntimeException("Membre de famille non trouvé avec l'id: " + id);
|
||||
}
|
||||
agentFamilyMemberRepository.deleteById(id);
|
||||
repository.deleteById(id);
|
||||
return "Membre de famille avec l'ID " + id + " supprimé avec succès.";
|
||||
}
|
||||
|
||||
public List<AgentFamilyMemberDTO> getFamilyMembersByStatut(String statut) {
|
||||
return agentFamilyMemberRepository.findByStatut(statut)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
// Search / Filters
|
||||
public List<AgentFamilyMember> getFamilyMembersByStatut(String statut) {
|
||||
return repository.findByStatut(statut);
|
||||
}
|
||||
|
||||
public List<AgentFamilyMemberDTO> getFamilyMembersBySexe(String sexe) {
|
||||
return agentFamilyMemberRepository.findBySexe(sexe)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
public List<AgentFamilyMember> getFamilyMembersBySexe(String sexe) {
|
||||
return repository.findBySexe(sexe);
|
||||
}
|
||||
|
||||
public List<AgentFamilyMemberDTO> searchFamilyMembers(String keyword) {
|
||||
return agentFamilyMemberRepository.searchByKeyword(keyword)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
public List<AgentFamilyMember> searchFamilyMembers(String keyword) {
|
||||
return repository.searchByKeyword(keyword);
|
||||
}
|
||||
|
||||
public List<AgentFamilyMemberDTO> getFamilyMembersByNom(String nom) {
|
||||
return agentFamilyMemberRepository.findByNomContainingIgnoreCase(nom)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private AgentFamilyMemberDTO convertToDTO(AgentFamilyMember member) {
|
||||
AgentFamilyMemberDTO dto = modelMapper.map(member, AgentFamilyMemberDTO.class);
|
||||
|
||||
// Ajouter le libellé du sexe
|
||||
if ("M".equals(member.getSexe())) {
|
||||
dto.setSexeLibelle("Masculin");
|
||||
} else if ("F".equals(member.getSexe())) {
|
||||
dto.setSexeLibelle("Féminin");
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private AgentFamilyMember convertToEntity(AgentFamilyMemberRequestDTO dto) {
|
||||
return modelMapper.map(dto, AgentFamilyMember.class);
|
||||
public List<AgentFamilyMember> getFamilyMembersByNom(String nom) {
|
||||
return repository.findByNomContainingIgnoreCase(nom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.AgentLimit;
|
||||
import com.pmu.betengine.repository.AgentLimitRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AgentLimitService {
|
||||
|
||||
private final AgentLimitRepository repository;
|
||||
|
||||
public AgentLimitService(AgentLimitRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
// Create
|
||||
public AgentLimit createAgentLimit(AgentLimit agentLimit) {
|
||||
if (repository.existsByCode(agentLimit.getCode())) {
|
||||
throw new RuntimeException("Un AgentLimit avec ce code existe déjà: " + agentLimit.getCode());
|
||||
}
|
||||
return repository.save(agentLimit);
|
||||
}
|
||||
|
||||
// Get all
|
||||
public List<AgentLimit> getAllAgentLimits() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
// Get by ID
|
||||
public AgentLimit getAgentLimitById(Long id) {
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("AgentLimit non trouvé avec l'id: " + id));
|
||||
}
|
||||
|
||||
// Update
|
||||
public AgentLimit updateAgentLimit(Long id, AgentLimit updated) {
|
||||
AgentLimit existing = getAgentLimitById(id);
|
||||
|
||||
if (!existing.getCode().equals(updated.getCode()) && repository.existsByCode(updated.getCode())) {
|
||||
throw new RuntimeException("Un AgentLimit avec ce code existe déjà: " + updated.getCode());
|
||||
}
|
||||
|
||||
existing.setCode(updated.getCode());
|
||||
existing.setConfigCode(updated.getConfigCode());
|
||||
existing.setNom(updated.getNom());
|
||||
existing.setDefault(updated.isDefault());
|
||||
existing.setActif(updated.isActif());
|
||||
existing.setBetMin(updated.getBetMin());
|
||||
existing.setBetMax(updated.getBetMax());
|
||||
existing.setMaxBet(updated.getMaxBet());
|
||||
existing.setMaxDisburseBet(updated.getMaxDisburseBet());
|
||||
existing.setAirtimeMin(updated.getAirtimeMin());
|
||||
existing.setAirtimeMax(updated.getAirtimeMax());
|
||||
existing.setCreatedBy(updated.getCreatedBy());
|
||||
|
||||
return repository.save(existing);
|
||||
}
|
||||
|
||||
// Delete
|
||||
public String deleteAgentLimit(Long id) {
|
||||
if (!repository.existsById(id)) {
|
||||
throw new RuntimeException("AgentLimit non trouvé avec l'id: " + id);
|
||||
}
|
||||
repository.deleteById(id);
|
||||
return "AgentLimit avec l'ID " + id + " supprimé avec succès.";
|
||||
}
|
||||
|
||||
// Search / Filters
|
||||
public List<AgentLimit> getAgentLimitsByActif(boolean actif) {
|
||||
return repository.findByActif(actif);
|
||||
}
|
||||
|
||||
public List<AgentLimit> searchAgentLimitsByNom(String nom) {
|
||||
return repository.findByNomContainingIgnoreCase(nom);
|
||||
}
|
||||
|
||||
}
|
||||
112
src/main/java/com/pmu/betengine/service/AgentService.java
Normal file
112
src/main/java/com/pmu/betengine/service/AgentService.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.Agent;
|
||||
import com.pmu.betengine.repository.AgentRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AgentService {
|
||||
|
||||
private final AgentRepository agentRepository;
|
||||
|
||||
public AgentService(AgentRepository agentRepository) {
|
||||
this.agentRepository = agentRepository;
|
||||
}
|
||||
|
||||
// Create
|
||||
public Agent createAgent(Agent agent) {
|
||||
if (agentRepository.existsByCode(agent.getCode())) {
|
||||
throw new RuntimeException("Un agent avec ce code existe déjà: " + agent.getCode());
|
||||
}
|
||||
agent.setCreatedAt(LocalDateTime.now());
|
||||
return agentRepository.save(agent);
|
||||
}
|
||||
|
||||
// Get all
|
||||
public List<Agent> getAllAgents() {
|
||||
return agentRepository.findAll();
|
||||
}
|
||||
|
||||
// Get by ID
|
||||
public Agent getAgentById(Long id) {
|
||||
return agentRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Agent non trouvé avec l'id: " + id));
|
||||
}
|
||||
|
||||
// Update
|
||||
public Agent updateAgent(Long id, Agent updatedAgent) {
|
||||
Agent existing = getAgentById(id);
|
||||
|
||||
existing.setCode(updatedAgent.getCode());
|
||||
existing.setProfile(updatedAgent.getProfile());
|
||||
existing.setPrincipalCode(updatedAgent.getPrincipalCode());
|
||||
existing.setCaisseProfile(updatedAgent.getCaisseProfile());
|
||||
existing.setStatut(updatedAgent.getStatut());
|
||||
existing.setZone(updatedAgent.getZone());
|
||||
existing.setKiosk(updatedAgent.getKiosk());
|
||||
existing.setFonction(updatedAgent.getFonction());
|
||||
existing.setDateEmbauche(updatedAgent.getDateEmbauche());
|
||||
existing.setNom(updatedAgent.getNom());
|
||||
existing.setPrenom(updatedAgent.getPrenom());
|
||||
existing.setAutresNoms(updatedAgent.getAutresNoms());
|
||||
existing.setDateNaissance(updatedAgent.getDateNaissance());
|
||||
existing.setLieuNaissance(updatedAgent.getLieuNaissance());
|
||||
existing.setVille(updatedAgent.getVille());
|
||||
existing.setAdresse(updatedAgent.getAdresse());
|
||||
existing.setAutoriserAides(updatedAgent.getAutoriserAides());
|
||||
existing.setPhone(updatedAgent.getPhone());
|
||||
existing.setPin(updatedAgent.getPin());
|
||||
existing.setLimiteInferieure(updatedAgent.getLimiteInferieure());
|
||||
existing.setLimiteSuperieure(updatedAgent.getLimiteSuperieure());
|
||||
existing.setLimiteParTransaction(updatedAgent.getLimiteParTransaction());
|
||||
existing.setLimiteMinAirtime(updatedAgent.getLimiteMinAirtime());
|
||||
existing.setLimiteMaxAirtime(updatedAgent.getLimiteMaxAirtime());
|
||||
existing.setMaxPeripheriques(updatedAgent.getMaxPeripheriques());
|
||||
existing.setLimitId(updatedAgent.getLimitId());
|
||||
existing.setNationalite(updatedAgent.getNationalite());
|
||||
existing.setCni(updatedAgent.getCni());
|
||||
existing.setCniDelivreeLe(updatedAgent.getCniDelivreeLe());
|
||||
existing.setCniDelivreeA(updatedAgent.getCniDelivreeA());
|
||||
existing.setResidence(updatedAgent.getResidence());
|
||||
existing.setAutreAdresse1(updatedAgent.getAutreAdresse1());
|
||||
existing.setStatutMarital(updatedAgent.getStatutMarital());
|
||||
existing.setEpoux(updatedAgent.getEpoux());
|
||||
existing.setAutreTelephone(updatedAgent.getAutreTelephone());
|
||||
existing.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
return agentRepository.save(existing);
|
||||
}
|
||||
|
||||
// Delete
|
||||
public String deleteAgent(Long id) {
|
||||
if (!agentRepository.existsById(id)) {
|
||||
throw new RuntimeException("Agent non trouvé avec l'id: " + id);
|
||||
}
|
||||
agentRepository.deleteById(id);
|
||||
return "Agent avec l'ID " + id + " supprimé avec succès.";
|
||||
}
|
||||
|
||||
// Find by code
|
||||
public Agent getAgentByCode(String code) {
|
||||
return agentRepository.findByCode(code)
|
||||
.orElseThrow(() -> new RuntimeException("Agent non trouvé avec le code: " + code));
|
||||
}
|
||||
|
||||
// Find by statut
|
||||
public List<Agent> getAgentsByStatut(String statut) {
|
||||
return agentRepository.findByStatut(statut);
|
||||
}
|
||||
|
||||
// Find by ville
|
||||
public List<Agent> getAgentsByVille(String ville) {
|
||||
return agentRepository.findByVille(ville);
|
||||
}
|
||||
|
||||
// Search by name
|
||||
public List<Agent> searchAgentsByName(String query) {
|
||||
return agentRepository.findByNomContainingIgnoreCaseOrPrenomContainingIgnoreCase(query, query);
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,47 @@ package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.Cheval;
|
||||
import com.pmu.betengine.repository.ChevalRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ChevalService {
|
||||
|
||||
@Autowired
|
||||
private ChevalRepository chevalRepository;
|
||||
private final ChevalRepository chevalRepository;
|
||||
|
||||
public ChevalService(ChevalRepository chevalRepository) {
|
||||
this.chevalRepository = chevalRepository;
|
||||
}
|
||||
|
||||
public Cheval ajouterCheval(Cheval cheval) {
|
||||
return chevalRepository.save(cheval);
|
||||
}
|
||||
|
||||
public List<Cheval> obtenirChevauxParCourse(Long courseId) {
|
||||
return null;// chevalRepository.findByCourseId(courseId);
|
||||
// Replace with actual repository method when Course relation exists
|
||||
return null; // chevalRepository.findByCourseId(courseId);
|
||||
}
|
||||
|
||||
public List<Cheval> obtenirChevauxParEcurie(String nomEcurie) {
|
||||
return chevalRepository.findByNomEcurie(nomEcurie);
|
||||
}
|
||||
|
||||
public Cheval obtenirChevalParNumero(int numero) {
|
||||
return chevalRepository.getChevalByNumero(numero)
|
||||
.orElseThrow(() -> new RuntimeException("Cheval non trouvé avec le numéro: " + numero));
|
||||
}
|
||||
|
||||
public List<Cheval> obtenirTousLesChevaux() {
|
||||
return chevalRepository.findAll();
|
||||
}
|
||||
|
||||
public void supprimerCheval(Long id) {
|
||||
if (!chevalRepository.existsById(id)) {
|
||||
throw new RuntimeException("Cheval non trouvé avec l'id: " + id);
|
||||
}
|
||||
chevalRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.CourseReportDetailRow;
|
||||
import com.pmu.betengine.repository.CourseReportDetailRowRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class CourseReportDetailRowService {
|
||||
|
||||
private final CourseReportDetailRowRepository repository;
|
||||
|
||||
public CourseReportDetailRowService(CourseReportDetailRowRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public CourseReportDetailRow create(CourseReportDetailRow row) {
|
||||
return repository.save(row);
|
||||
}
|
||||
|
||||
public CourseReportDetailRow getById(Long id) {
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("CourseReportDetailRow non trouvé avec l'id: " + id));
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public CourseReportDetailRow update(Long id, CourseReportDetailRow row) {
|
||||
CourseReportDetailRow existing = getById(id);
|
||||
|
||||
existing.setDetailId(row.getDetailId());
|
||||
existing.setTypeGain(row.getTypeGain());
|
||||
existing.setTypeJeu(row.getTypeJeu());
|
||||
existing.setMontant(row.getMontant());
|
||||
existing.setNombre(row.getNombre());
|
||||
existing.setStatut(row.getStatut());
|
||||
existing.setDistributed(row.getDistributed());
|
||||
existing.setExterne(row.getExterne());
|
||||
|
||||
return repository.save(existing);
|
||||
}
|
||||
|
||||
public void delete(Long id) {
|
||||
if (!repository.existsById(id)) {
|
||||
throw new RuntimeException("CourseReportDetailRow non trouvé avec l'id: " + id);
|
||||
}
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByDetailId(Long detailId) {
|
||||
return repository.findByDetailId(detailId);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByTypeGain(String typeGain) {
|
||||
return repository.findByTypeGain(typeGain);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByTypeJeu(String typeJeu) {
|
||||
return repository.findByTypeJeu(typeJeu);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByStatut(String statut) {
|
||||
return repository.findByStatut(statut);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByDistributed(Boolean distributed) {
|
||||
return repository.findByDistributed(distributed);
|
||||
}
|
||||
|
||||
public List<CourseReportDetailRow> getByExterne(Boolean externe) {
|
||||
return repository.findByExterne(externe);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
|
||||
import com.pmu.betengine.model.Course;
|
||||
import com.pmu.betengine.repository.CourseRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class CourseService {
|
||||
@@ -15,23 +15,62 @@ public class CourseService {
|
||||
@Autowired
|
||||
private CourseRepository courseRepository;
|
||||
|
||||
public Course creerCourse(Course course) {
|
||||
return courseRepository.save(course);
|
||||
}
|
||||
// Create
|
||||
public Course createCourse(Course course) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
course.setCreatedAt(now);
|
||||
course.setUpdatedAt(now);
|
||||
return courseRepository.save(course);
|
||||
}
|
||||
|
||||
public List<Course> obtenirToutesCourses() {
|
||||
// Get all
|
||||
public List<Course> getAllCourses() {
|
||||
return courseRepository.findAll();
|
||||
}
|
||||
|
||||
public Course obtenirCourseParId(Long id) {
|
||||
return courseRepository.findById(id).orElse(null);
|
||||
// Get by ID
|
||||
public Course getCourseById(Long id) {
|
||||
return courseRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Course not found"));
|
||||
}
|
||||
|
||||
public List<Course> obtenirCoursesTerminees() {
|
||||
return courseRepository.findByEstTerminee(true);
|
||||
// Update
|
||||
public Course updateCourse(Long id, Course updatedCourse) {
|
||||
Course course = getCourseById(id);
|
||||
course.setNom(updatedCourse.getNom());
|
||||
course.setType(updatedCourse.getType());
|
||||
course.setNumero(updatedCourse.getNumero());
|
||||
course.setDateDepartCourse(updatedCourse.getDateDepartCourse());
|
||||
course.setDateDebutParis(updatedCourse.getDateDebutParis());
|
||||
course.setDateFinParis(updatedCourse.getDateFinParis());
|
||||
course.setReunionId(updatedCourse.getReunionId());
|
||||
course.setReunionCourse(updatedCourse.getReunionCourse());
|
||||
course.setParticularite(updatedCourse.getParticularite());
|
||||
course.setPartants(updatedCourse.getPartants());
|
||||
course.setDistance(updatedCourse.getDistance());
|
||||
course.setCondition(updatedCourse.getCondition());
|
||||
course.setStatut(updatedCourse.getStatut());
|
||||
course.setResultatStatut(updatedCourse.getResultatStatut());
|
||||
course.setCreatedBy(updatedCourse.getCreatedBy());
|
||||
course.setValidatedBy(updatedCourse.getValidatedBy());
|
||||
course.setUpdatedAt(updatedCourse.getUpdatedAt());
|
||||
return courseRepository.save(course);
|
||||
}
|
||||
|
||||
public List<Course> obtenirCoursesAVenir() {
|
||||
return courseRepository.findByEstTerminee(false);
|
||||
// Delete
|
||||
public void deleteCourse(Long id) {
|
||||
courseRepository.deleteById(id);
|
||||
}
|
||||
|
||||
// Search by name
|
||||
public List<Course> searchCourses(String query) {
|
||||
return courseRepository.findByNomContainingIgnoreCase(query);
|
||||
}
|
||||
|
||||
// Update statut
|
||||
public Course updateStatut(Long id, String statut) {
|
||||
Course course = getCourseById(id);
|
||||
course.setStatut(statut);
|
||||
return courseRepository.save(course);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +1,57 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.Hippodrome;
|
||||
import com.pmu.betengine.model.Reunion;
|
||||
import com.pmu.betengine.model.dto.HippodromeDTO;
|
||||
import com.pmu.betengine.model.dto.HippodromeRequestDTO;
|
||||
import com.pmu.betengine.repository.HippodromeRepository;
|
||||
import com.pmu.betengine.repository.ReunionRepository;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class HippodromeService {
|
||||
|
||||
private final HippodromeRepository hippodromeRepository;
|
||||
private final ReunionRepository reunionRepository;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public HippodromeService(HippodromeRepository hippodromeRepository,
|
||||
ReunionRepository reunionRepository,
|
||||
ModelMapper modelMapper) {
|
||||
public HippodromeService(HippodromeRepository hippodromeRepository) {
|
||||
this.hippodromeRepository = hippodromeRepository;
|
||||
this.reunionRepository = reunionRepository;
|
||||
this.modelMapper = modelMapper;
|
||||
}
|
||||
|
||||
public List<HippodromeDTO> getAllHippodromes() {
|
||||
return hippodromeRepository.findAll()
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
public Hippodrome createHippodrome(Hippodrome hippodrome) {
|
||||
if (hippodromeRepository.existsByNom(hippodrome.getNom())) {
|
||||
throw new RuntimeException("Un hippodrome avec ce nom existe déjà: " + hippodrome.getNom());
|
||||
}
|
||||
|
||||
public HippodromeDTO getHippodromeById(Long id) {
|
||||
Hippodrome hippodrome = hippodromeRepository.findById(id)
|
||||
hippodrome.setCreatedAt(LocalDateTime.now());
|
||||
hippodrome.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
return hippodromeRepository.save(hippodrome);
|
||||
}
|
||||
|
||||
|
||||
// Get all
|
||||
public List<Hippodrome> getAllHippodromes() {
|
||||
return hippodromeRepository.findAll();
|
||||
}
|
||||
|
||||
// Get by ID
|
||||
public Hippodrome getHippodromeById(Long id) {
|
||||
return hippodromeRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Hippodrome non trouvé avec l'id: " + id));
|
||||
return convertToDTO(hippodrome);
|
||||
}
|
||||
|
||||
public HippodromeDTO createHippodrome(HippodromeRequestDTO requestDTO) {
|
||||
if (hippodromeRepository.existsByNom(requestDTO.getNom())) {
|
||||
throw new RuntimeException("Un hippodrome avec ce nom existe déjà: " + requestDTO.getNom());
|
||||
}
|
||||
|
||||
Hippodrome hippodrome = convertToEntity(requestDTO);
|
||||
|
||||
Hippodrome saved = hippodromeRepository.save(hippodrome);
|
||||
return convertToDTO(saved);
|
||||
}
|
||||
|
||||
public HippodromeDTO updateHippodrome(Long id, HippodromeRequestDTO requestDTO) {
|
||||
Hippodrome existing = hippodromeRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Hippodrome non trouvé avec l'id: " + id));
|
||||
|
||||
// Vérification du nom si modifié
|
||||
if (!existing.getNom().equals(requestDTO.getNom()) &&
|
||||
hippodromeRepository.existsByNom(requestDTO.getNom())) {
|
||||
throw new RuntimeException("Un hippodrome avec ce nom existe déjà: " + requestDTO.getNom());
|
||||
}
|
||||
|
||||
// Mise à jour des champs
|
||||
modelMapper.map(requestDTO, existing);
|
||||
|
||||
|
||||
|
||||
return convertToDTO(hippodromeRepository.save(existing));
|
||||
// Update
|
||||
public Hippodrome updateHippodrome(Long id, Hippodrome updatedHippodrome) {
|
||||
Hippodrome existing = getHippodromeById(id);
|
||||
existing.setNom(updatedHippodrome.getNom());
|
||||
existing.setVille(updatedHippodrome.getVille());
|
||||
existing.setPays(updatedHippodrome.getPays());
|
||||
existing.setActif(updatedHippodrome.getActif());
|
||||
existing.setCapacite(updatedHippodrome.getCapacite());
|
||||
existing.setDescription(updatedHippodrome.getDescription());
|
||||
return hippodromeRepository.save(existing);
|
||||
}
|
||||
|
||||
// Delete
|
||||
public void deleteHippodrome(Long id) {
|
||||
if (!hippodromeRepository.existsById(id)) {
|
||||
throw new RuntimeException("Hippodrome non trouvé avec l'id: " + id);
|
||||
@@ -79,43 +59,18 @@ public class HippodromeService {
|
||||
hippodromeRepository.deleteById(id);
|
||||
}
|
||||
|
||||
public List<HippodromeDTO> getHippodromesByVille(String ville) {
|
||||
return hippodromeRepository.findByVille(ville)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
// Search by ville
|
||||
public List<Hippodrome> getHippodromesByVille(String ville) {
|
||||
return hippodromeRepository.findByVille(ville);
|
||||
}
|
||||
|
||||
public List<HippodromeDTO> getHippodromesActifs() {
|
||||
return hippodromeRepository.findByActif(true)
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
// Get only active hippodromes
|
||||
public List<Hippodrome> getHippodromesActifs() {
|
||||
return hippodromeRepository.findByActif(true);
|
||||
}
|
||||
|
||||
public HippodromeDTO getHippodromeByReunion(Long reunionId) {
|
||||
Hippodrome hippodrome = hippodromeRepository.findByReunionId(reunionId)
|
||||
.orElseThrow(() -> new RuntimeException("Aucun hippodrome trouvé pour la réunion avec l'id: " + reunionId));
|
||||
return convertToDTO(hippodrome);
|
||||
}
|
||||
|
||||
private HippodromeDTO convertToDTO(Hippodrome hippodrome) {
|
||||
HippodromeDTO dto = modelMapper.map(hippodrome, HippodromeDTO.class);
|
||||
|
||||
// Formatage des dates
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
||||
if (hippodrome.getCreatedAt() != null) {
|
||||
dto.setCreatedAt(hippodrome.getCreatedAt().format(formatter));
|
||||
}
|
||||
if (hippodrome.getUpdatedAt() != null) {
|
||||
dto.setUpdatedAt(hippodrome.getUpdatedAt().format(formatter));
|
||||
}
|
||||
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private Hippodrome convertToEntity(HippodromeRequestDTO dto) {
|
||||
return modelMapper.map(dto, Hippodrome.class);
|
||||
// Search by name
|
||||
public List<Hippodrome> searchHippodromesByNom(String nom) {
|
||||
return hippodromeRepository.findByNomContainingIgnoreCase(nom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.NonPartant;
|
||||
import com.pmu.betengine.repository.NonPartantRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
// import java.util.Long;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class NonPartantService {
|
||||
|
||||
private final NonPartantRepository repository;
|
||||
|
||||
public NonPartantService(NonPartantRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public NonPartant createNonPartant(NonPartant np) {
|
||||
return repository.save(np);
|
||||
}
|
||||
|
||||
public List<NonPartant> getAllNonPartants() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public NonPartant getNonPartantById(Long id) {
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("NonPartant non trouvé avec l'id: " + id));
|
||||
}
|
||||
|
||||
public NonPartant updateNonPartant(Long id, NonPartant updated) {
|
||||
NonPartant existing = getNonPartantById(id);
|
||||
existing.setCourse(updated.getCourse());
|
||||
existing.setNumero(updated.getNumero());
|
||||
existing.setNomCheval(updated.getNomCheval());
|
||||
existing.setMotif(updated.getMotif());
|
||||
existing.setDeclarePar(updated.getDeclarePar());
|
||||
existing.setDateDeclaration(updated.getDateDeclaration());
|
||||
return repository.save(existing);
|
||||
}
|
||||
|
||||
public void deleteNonPartant(Long id) {
|
||||
if (!repository.existsById(id)) {
|
||||
throw new RuntimeException("NonPartant non trouvé avec l'id: " + id);
|
||||
}
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
public List<NonPartant> getByCourseId(Long courseId) {
|
||||
return repository.findByCourseId(courseId);
|
||||
}
|
||||
|
||||
public List<NonPartant> searchByNomCheval(String nomCheval) {
|
||||
return repository.findByNomChevalContainingIgnoreCase(nomCheval);
|
||||
}
|
||||
|
||||
public List<NonPartant> searchByMotif(String motif) {
|
||||
return repository.findByMotifContainingIgnoreCase(motif);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,8 @@ import com.pmu.betengine.model.Course;
|
||||
import com.pmu.betengine.model.Pari;
|
||||
import com.pmu.betengine.model.statut.StatutParis;
|
||||
import com.pmu.betengine.model.type.TypeFormule;
|
||||
import com.pmu.betengine.model.type.TypePari;
|
||||
import com.pmu.betengine.repository.ChevalRepository;
|
||||
import com.pmu.betengine.repository.CourseRepository;
|
||||
import com.pmu.betengine.repository.PariRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,52 +13,135 @@ import java.util.List;
|
||||
@Service
|
||||
public class PariService {
|
||||
|
||||
@Autowired
|
||||
private PariRepository pariRepository;
|
||||
private final PariRepository pariRepository;
|
||||
private final CourseRepository courseRepository;
|
||||
|
||||
@Autowired
|
||||
private CourseRepository courseRepository;
|
||||
public PariService(PariRepository pariRepository, CourseRepository courseRepository) {
|
||||
this.pariRepository = pariRepository;
|
||||
this.courseRepository = courseRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ChevalRepository chevalRepository;
|
||||
// CREATE
|
||||
public Pari save(Pari pari) {
|
||||
|
||||
private static final double MISE_DE_BASE = 500.0;
|
||||
|
||||
|
||||
|
||||
public Pari placerPari(Pari pari) {
|
||||
TypePari tp= pari.getTypePari();
|
||||
// Vérifier que le type de pari est valide pour la course
|
||||
pari.setStatut(StatutParis.EN_ATTENTE);
|
||||
Course course = (Course) pari.getCourse();
|
||||
if ("GAGNANT".equals(pari.getTypeFormule().name()) && course.getNombreChevauxInscrits() < 2) {
|
||||
throw new IllegalArgumentException("Pari GAGNANT impossible: moins de 2 chevaux");
|
||||
}
|
||||
|
||||
if ("PLACE".equals(pari.getTypeFormule().name()) && course.getNombreChevauxInscrits() < 3) {
|
||||
throw new IllegalArgumentException("Pari PLACE impossible: moins de 3 chevaux");
|
||||
Course course = pari.getCourse();
|
||||
|
||||
// Business rules
|
||||
if (pari.getTypeFormule() == TypeFormule.GAGNANT && course.getNombreChevauxInscrits() < 2) {
|
||||
throw new IllegalArgumentException("Pari GAGNANT impossible: moins de 2 chevaux.");
|
||||
}
|
||||
if (pari.getTypeFormule() == TypeFormule.PLACE && course.getNombreChevauxInscrits() < 3) {
|
||||
throw new IllegalArgumentException("Pari PLACE impossible: moins de 3 chevaux.");
|
||||
}
|
||||
|
||||
return pariRepository.save(pari);
|
||||
}
|
||||
|
||||
public Pari update(Pari pari){
|
||||
return pariRepository.save(pari);
|
||||
}
|
||||
// GET ALL
|
||||
public List<Pari> getAll() {
|
||||
return pariRepository.findAll();
|
||||
}
|
||||
|
||||
public Pari findByTicket(String ticket){
|
||||
// GET BY ID
|
||||
public Pari getById(Long id) {
|
||||
return pariRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
return pariRepository.findByNumeroTicket(ticket).orElse(null);
|
||||
}
|
||||
public List<Pari> obtenirParisParCourse(Long courseId) {
|
||||
// DELETE
|
||||
public void delete(Long id) {
|
||||
pariRepository.deleteById(id);
|
||||
}
|
||||
|
||||
// GET BY COURSE
|
||||
public List<Pari> getByCourse(Long courseId) {
|
||||
return pariRepository.findByCourseId(courseId);
|
||||
}
|
||||
|
||||
public List<Pari> obtenirParisParCourseEtType(Long courseId, TypeFormule typeFormule) {
|
||||
// GET BY TICKET
|
||||
public Pari findByTicket(String ticket) {
|
||||
return pariRepository.findByNumeroTicket(ticket).orElse(null);
|
||||
}
|
||||
|
||||
// GET BY COURSE + TYPE
|
||||
public List<Pari> getByCourseAndType(Long courseId, TypeFormule typeFormule) {
|
||||
return pariRepository.findByCourseIdAndTypeFormule(courseId, typeFormule);
|
||||
}
|
||||
|
||||
public List<Pari> obtenirParisParCheval(Long chevalId) {
|
||||
return pariRepository.findByChevalId(chevalId);
|
||||
// UPDATE
|
||||
public Pari update(Pari pari) {
|
||||
return pariRepository.save(pari);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.service;
|
||||
|
||||
// import com.pmu.betengine.model.Course;
|
||||
// import com.pmu.betengine.model.Pari;
|
||||
// import com.pmu.betengine.model.statut.StatutParis;
|
||||
// import com.pmu.betengine.model.type.TypeFormule;
|
||||
// import com.pmu.betengine.model.type.TypePari;
|
||||
// import com.pmu.betengine.repository.ChevalRepository;
|
||||
// import com.pmu.betengine.repository.CourseRepository;
|
||||
// import com.pmu.betengine.repository.PariRepository;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
// import java.util.List;
|
||||
|
||||
// @Service
|
||||
// public class PariService {
|
||||
|
||||
// @Autowired
|
||||
// private PariRepository pariRepository;
|
||||
|
||||
// @Autowired
|
||||
// private CourseRepository courseRepository;
|
||||
|
||||
// @Autowired
|
||||
// private ChevalRepository chevalRepository;
|
||||
|
||||
// private static final double MISE_DE_BASE = 500.0;
|
||||
|
||||
|
||||
|
||||
// public Pari placerPari(Pari pari) {
|
||||
// TypePari tp= pari.getTypePari();
|
||||
// // Vérifier que le type de pari est valide pour la course
|
||||
// pari.setStatut(StatutParis.EN_ATTENTE);
|
||||
// Course course = (Course) pari.getCourse();
|
||||
// if ("GAGNANT".equals(pari.getTypeFormule().name()) && course.getNombreChevauxInscrits() < 2) {
|
||||
// throw new IllegalArgumentException("Pari GAGNANT impossible: moins de 2 chevaux");
|
||||
// }
|
||||
|
||||
// if ("PLACE".equals(pari.getTypeFormule().name()) && course.getNombreChevauxInscrits() < 3) {
|
||||
// throw new IllegalArgumentException("Pari PLACE impossible: moins de 3 chevaux");
|
||||
// }
|
||||
|
||||
// return pariRepository.save(pari);
|
||||
// }
|
||||
|
||||
// public Pari update(Pari pari){
|
||||
// return pariRepository.save(pari);
|
||||
// }
|
||||
|
||||
// public Pari findByTicket(String ticket){
|
||||
|
||||
// return pariRepository.findByNumeroTicket(ticket).orElse(null);
|
||||
// }
|
||||
// public List<Pari> obtenirParisParCourse(Long courseId) {
|
||||
// return pariRepository.findByCourseId(courseId);
|
||||
// }
|
||||
|
||||
// public List<Pari> obtenirParisParCourseEtType(Long courseId, TypeFormule typeFormule) {
|
||||
// return pariRepository.findByCourseIdAndTypeFormule(courseId, typeFormule);
|
||||
// }
|
||||
|
||||
// public List<Pari> obtenirParisParCheval(Long chevalId) {
|
||||
// return pariRepository.findByChevalId(chevalId);
|
||||
// }
|
||||
// }
|
||||
@@ -5,23 +5,72 @@ import com.pmu.betengine.repository.ResultatRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ResultatService {
|
||||
|
||||
private final ResultatRepository resultatCourseRepository;
|
||||
private final ResultatRepository resultatRepository;
|
||||
|
||||
public Optional<Resultat> findByCourseId(Long courseId) {
|
||||
return resultatCourseRepository.findByCourseId(courseId);
|
||||
// CREATE / UPDATE
|
||||
public Resultat save(Resultat resultat) {
|
||||
return resultatRepository.save(resultat);
|
||||
}
|
||||
|
||||
public Resultat save(Resultat resultatCourse) {
|
||||
return resultatCourseRepository.save(resultatCourse);
|
||||
// GET ALL
|
||||
public List<Resultat> getAll() {
|
||||
return resultatRepository.findAll();
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
public Resultat getById(Long id) {
|
||||
return resultatRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
// GET BY COURSE
|
||||
public Resultat getByCourseId(Long courseId) {
|
||||
return resultatRepository.findByCourseId(courseId).orElse(null);
|
||||
}
|
||||
|
||||
// DELETE BY ID
|
||||
public void delete(Long id) {
|
||||
resultatRepository.deleteById(id);
|
||||
}
|
||||
|
||||
// DELETE BY COURSE
|
||||
public void deleteByCourseId(Long courseId) {
|
||||
resultatCourseRepository.deleteByCourseId(courseId);
|
||||
resultatRepository.deleteByCourseId(courseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.service;
|
||||
|
||||
// import com.pmu.betengine.model.Resultat;
|
||||
// import com.pmu.betengine.repository.ResultatRepository;
|
||||
// import lombok.RequiredArgsConstructor;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
// import java.util.Optional;
|
||||
|
||||
// @Service
|
||||
// @RequiredArgsConstructor
|
||||
// public class ResultatService {
|
||||
|
||||
// private final ResultatRepository resultatCourseRepository;
|
||||
|
||||
// public Optional<Resultat> findByCourseId(Long courseId) {
|
||||
// return resultatCourseRepository.findByCourseId(courseId);
|
||||
// }
|
||||
|
||||
// public Resultat save(Resultat resultatCourse) {
|
||||
// return resultatCourseRepository.save(resultatCourse);
|
||||
// }
|
||||
|
||||
// public void deleteByCourseId(Long courseId) {
|
||||
// resultatCourseRepository.deleteByCourseId(courseId);
|
||||
// }
|
||||
// }
|
||||
@@ -1,71 +1,68 @@
|
||||
package com.pmu.betengine.service;
|
||||
|
||||
import com.pmu.betengine.model.Reunion;
|
||||
import com.pmu.betengine.model.dto.ReunionDTO;
|
||||
import com.pmu.betengine.model.dto.ReunionRequestDTO;
|
||||
import com.pmu.betengine.repository.ReunionRepository;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ReunionService {
|
||||
|
||||
private final ReunionRepository reunionRepository;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public ReunionService(ReunionRepository reunionRepository, ModelMapper modelMapper) {
|
||||
public ReunionService(ReunionRepository reunionRepository) {
|
||||
this.reunionRepository = reunionRepository;
|
||||
this.modelMapper = modelMapper;
|
||||
}
|
||||
|
||||
public List<ReunionDTO> getAllReunions() {
|
||||
return reunionRepository.findAll()
|
||||
.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public ReunionDTO getReunionById(Long id) {
|
||||
Reunion reunion = reunionRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Reunion non trouvée"));
|
||||
return convertToDTO(reunion);
|
||||
}
|
||||
|
||||
public ReunionDTO createReunion(ReunionRequestDTO requestDTO) {
|
||||
if (reunionRepository.existsByCode(requestDTO.getCode())) {
|
||||
throw new RuntimeException("Code déjà existant");
|
||||
// Create
|
||||
public Reunion createReunion(Reunion reunion) {
|
||||
if (reunionRepository.existsByCode(reunion.getCode())) {
|
||||
throw new RuntimeException("Code déjà existant: " + reunion.getCode());
|
||||
}
|
||||
|
||||
Reunion reunion = convertToEntity(requestDTO);
|
||||
reunion.setCreatedAt(LocalDateTime.now());
|
||||
Reunion saved = reunionRepository.save(reunion);
|
||||
return convertToDTO(saved);
|
||||
reunion.setUpdatedAt(LocalDateTime.now());
|
||||
return reunionRepository.save(reunion);
|
||||
}
|
||||
|
||||
public ReunionDTO updateReunion(Long id, ReunionRequestDTO requestDTO) {
|
||||
Reunion existing = reunionRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Reunion non trouvée"));
|
||||
// Get all
|
||||
public List<Reunion> getAllReunions() {
|
||||
return reunionRepository.findAll();
|
||||
}
|
||||
|
||||
modelMapper.map(requestDTO, existing);
|
||||
// Get by ID
|
||||
public Reunion getReunionById(Long id) {
|
||||
return reunionRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Réunion non trouvée avec l'id: " + id));
|
||||
}
|
||||
|
||||
// Update
|
||||
public Reunion updateReunion(Long id, Reunion updatedReunion) {
|
||||
Reunion existing = getReunionById(id);
|
||||
existing.setCode(updatedReunion.getCode());
|
||||
existing.setNom(updatedReunion.getNom());
|
||||
existing.setDate(updatedReunion.getDate());
|
||||
existing.setNumero(updatedReunion.getNumero());
|
||||
existing.setStatut(updatedReunion.getStatut());
|
||||
existing.setHippodromeId(updatedReunion.getHippodromeId());
|
||||
existing.setTotalCourses(updatedReunion.getTotalCourses());
|
||||
existing.setUpdatedAt(LocalDateTime.now());
|
||||
return convertToDTO(reunionRepository.save(existing));
|
||||
return reunionRepository.save(existing);
|
||||
}
|
||||
|
||||
public void deleteReunion(Long id) {
|
||||
// Delete
|
||||
public String deleteReunion(Long id) {
|
||||
if (!reunionRepository.existsById(id)) {
|
||||
throw new RuntimeException("Réunion non trouvée avec l'id: " + id);
|
||||
}
|
||||
reunionRepository.deleteById(id);
|
||||
return "Réunion avec l'ID " + id + " supprimée avec succès.";
|
||||
}
|
||||
|
||||
private ReunionDTO convertToDTO(Reunion reunion) {
|
||||
return modelMapper.map(reunion, ReunionDTO.class);
|
||||
// Find by code
|
||||
public Reunion getReunionByCode(String code) {
|
||||
return reunionRepository.findByCode(code)
|
||||
.orElseThrow(() -> new RuntimeException("Réunion non trouvée avec le code: " + code));
|
||||
}
|
||||
|
||||
private Reunion convertToEntity(ReunionRequestDTO dto) {
|
||||
return modelMapper.map(dto, Reunion.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user