Compare commits
3 Commits
main
...
65c5fd5c6e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65c5fd5c6e | ||
|
|
7d2cc98d2c | ||
|
|
c13e5b1dfc |
@@ -41,6 +41,7 @@ dependencies {
|
|||||||
implementation('io.jsonwebtoken:jjwt-jackson:0.11.5')
|
implementation('io.jsonwebtoken:jjwt-jackson:0.11.5')
|
||||||
|
|
||||||
implementation('org.modelmapper:modelmapper:3.2.0')
|
implementation('org.modelmapper:modelmapper:3.2.0')
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- api
|
- api
|
||||||
api_db:
|
api_db:
|
||||||
image: postgres
|
image: postgres:15
|
||||||
container_name: api_db
|
container_name: api_db
|
||||||
ports:
|
ports:
|
||||||
- 5555:5432
|
- 5555:5432
|
||||||
@@ -22,7 +22,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=postgres
|
- POSTGRES_USER=postgres
|
||||||
- POSTGRES_PASSWORD=password
|
- POSTGRES_PASSWORD=password
|
||||||
- POSTGRES_DBNAME="plr"
|
- POSTGRES_DB="plr"
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- api
|
- 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.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class BetEngineApplication {
|
public class BetEngineApplication {
|
||||||
@@ -10,4 +12,8 @@ public class BetEngineApplication {
|
|||||||
SpringApplication.run(BetEngineApplication.class, args);
|
SpringApplication.run(BetEngineApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
|
public void onApplicationReady() {
|
||||||
|
System.out.println("******************* PMU Bet Engine is running and connected successfully! *******************");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,19 @@ public class CorsConfig {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public WebMvcConfigurer corsConfigurer() {
|
||||||
|
// return new WebMvcConfigurer() {
|
||||||
|
// @Override
|
||||||
|
// public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
// registry.addMapping("/**")
|
||||||
|
// .allowedOrigins("*") // Same as configuration.addAllowedOrigin("*")
|
||||||
|
// .allowedHeaders("*") // Same as configuration.addAllowedHeader("*")
|
||||||
|
// .allowedMethods("*") // Same as configuration.addAllowedMethod("*")
|
||||||
|
// .maxAge(3600);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
|
||||||
@@ -29,5 +31,10 @@ public class SecurityConfig {
|
|||||||
.addFilterBefore(apiKeyFilter, UsernamePasswordAuthenticationFilter.class)
|
.addFilterBefore(apiKeyFilter, UsernamePasswordAuthenticationFilter.class)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
import com.pmu.betengine.model.dto.AgentFamilyMemberDTO;
|
import com.pmu.betengine.model.AgentFamilyMember;
|
||||||
import com.pmu.betengine.model.dto.AgentFamilyMemberRequestDTO;
|
|
||||||
import com.pmu.betengine.service.AgentFamilyMemberService;
|
import com.pmu.betengine.service.AgentFamilyMemberService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
|
||||||
@RequestMapping("/api/v1/agent-family-members")
|
@RequestMapping("/api/v1/agent-family-members")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@Tag(name = "Gestion des Membres de famille", description = "Endpoints relatifs à l'objet AgentFamilyMember")
|
@Tag(name = "Gestion des Membres de famille", description = "Endpoints relatifs à l'objet AgentFamilyMember")
|
||||||
public class AgentFamilyMemberController {
|
public class AgentFamilyMemberController {
|
||||||
|
|
||||||
private final AgentFamilyMemberService agentFamilyMemberService;
|
private final AgentFamilyMemberService service;
|
||||||
|
|
||||||
/* public AgentFamilyMemberController(AgentFamilyMemberService agentFamilyMemberService) {
|
public AgentFamilyMemberController(AgentFamilyMemberService service) {
|
||||||
this.agentFamilyMemberService = agentFamilyMemberService;
|
this.service = service;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getAllFamilyMembers() {
|
@Operation(summary = "Lister tous les membres de famille")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.getAllFamilyMembers());
|
public ResponseEntity<List<AgentFamilyMember>> getAllFamilyMembers() {
|
||||||
|
return ResponseEntity.ok(service.getAllFamilyMembers());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<AgentFamilyMemberDTO> getFamilyMemberById(@PathVariable Long id) {
|
@Operation(summary = "Obtenir un membre de famille par ID")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMemberById(id));
|
public ResponseEntity<AgentFamilyMember> getFamilyMemberById(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(service.getFamilyMemberById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Ajouter un AgentFamilyMember dans la base")
|
@Operation(summary = "Créer un membre de famille")
|
||||||
public ResponseEntity<AgentFamilyMemberDTO> createFamilyMember(@Valid @RequestBody AgentFamilyMemberRequestDTO requestDTO) {
|
public ResponseEntity<AgentFamilyMember> createFamilyMember(@RequestBody AgentFamilyMember member) {
|
||||||
return new ResponseEntity<>(agentFamilyMemberService.createFamilyMember(requestDTO), HttpStatus.CREATED);
|
return new ResponseEntity<>(service.createFamilyMember(member), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ResponseEntity<AgentFamilyMemberDTO> updateFamilyMember(@PathVariable Long id, @Valid @RequestBody AgentFamilyMemberRequestDTO requestDTO) {
|
@Operation(summary = "Modifier un membre de famille")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.updateFamilyMember(id, requestDTO));
|
public ResponseEntity<AgentFamilyMember> updateFamilyMember(@PathVariable Long id,
|
||||||
|
@RequestBody AgentFamilyMember member) {
|
||||||
|
return ResponseEntity.ok(service.updateFamilyMember(id, member));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseEntity<Void> deleteFamilyMember(@PathVariable Long id) {
|
@Operation(summary = "Supprimer un membre de famille")
|
||||||
agentFamilyMemberService.deleteFamilyMember(id);
|
public ResponseEntity<String> deleteFamilyMember(@PathVariable Long id) {
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.ok(service.deleteFamilyMember(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/statut/{statut}")
|
@GetMapping("/statut/{statut}")
|
||||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersByStatut(@PathVariable String statut) {
|
@Operation(summary = "Lister les membres par statut")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersByStatut(statut));
|
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersByStatut(@PathVariable String statut) {
|
||||||
|
return ResponseEntity.ok(service.getFamilyMembersByStatut(statut));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/sexe/{sexe}")
|
@GetMapping("/sexe/{sexe}")
|
||||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersBySexe(@PathVariable String sexe) {
|
@Operation(summary = "Lister les membres par sexe")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersBySexe(sexe));
|
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersBySexe(@PathVariable String sexe) {
|
||||||
|
return ResponseEntity.ok(service.getFamilyMembersBySexe(sexe));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public ResponseEntity<List<AgentFamilyMemberDTO>> searchFamilyMembers(@RequestParam String keyword) {
|
@Operation(summary = "Rechercher des membres par mot-clé")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.searchFamilyMembers(keyword));
|
public ResponseEntity<List<AgentFamilyMember>> searchFamilyMembers(@RequestParam String keyword) {
|
||||||
|
return ResponseEntity.ok(service.searchFamilyMembers(keyword));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/nom/{nom}")
|
@GetMapping("/nom/{nom}")
|
||||||
public ResponseEntity<List<AgentFamilyMemberDTO>> getFamilyMembersByNom(@PathVariable String nom) {
|
@Operation(summary = "Lister les membres par nom")
|
||||||
return ResponseEntity.ok(agentFamilyMemberService.getFamilyMembersByNom(nom));
|
public ResponseEntity<List<AgentFamilyMember>> getFamilyMembersByNom(@PathVariable String nom) {
|
||||||
|
return ResponseEntity.ok(service.getFamilyMembersByNom(nom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
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")
|
||||||
|
@Operation(summary = "Lister les limites actives")
|
||||||
|
public ResponseEntity<List<AgentLimit>> getAgentLimitsByActif() {
|
||||||
|
return ResponseEntity.ok(service.getAgentLimitsByActif(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/inactif")
|
||||||
|
@Operation(summary = "Lister les limites inactives")
|
||||||
|
public ResponseEntity<List<AgentLimit>> getAgentLimitsByInactif() {
|
||||||
|
return ResponseEntity.ok(service.getAgentLimitsByActif(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @GetMapping("/search")
|
||||||
|
// @Operation(summary = "Rechercher les limites par nom")
|
||||||
|
// public ResponseEntity<List<AgentLimit>> searchAgentLimitsByNom(@RequestParam String nom) {
|
||||||
|
// return ResponseEntity.ok(service.searchAgentLimitsByNom(nom));
|
||||||
|
// }
|
||||||
|
@GetMapping("/search/{nom}")
|
||||||
|
public ResponseEntity<List<AgentLimit>> searchAgentLimitsByNom(@PathVariable String nom) {
|
||||||
|
return ResponseEntity.ok(service.searchAgentLimitsByNom(nom));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.AuthRequest;
|
||||||
|
import com.pmu.betengine.model.AuthResponse;
|
||||||
|
import com.pmu.betengine.model.User;
|
||||||
|
import com.pmu.betengine.service.AuthService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/auth")
|
||||||
|
@CrossOrigin
|
||||||
|
public class AuthController {
|
||||||
|
|
||||||
|
private final AuthService authService;
|
||||||
|
|
||||||
|
public AuthController(AuthService authService) {
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/login")
|
||||||
|
public ResponseEntity<User> login(@RequestBody AuthRequest request) {
|
||||||
|
User loggedUser = authService.login(request);
|
||||||
|
return ResponseEntity.ok(loggedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,26 +4,35 @@ import com.pmu.betengine.model.Cheval;
|
|||||||
import com.pmu.betengine.service.ChevalService;
|
import com.pmu.betengine.service.ChevalService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/cheval")
|
@RequestMapping("/api/v1/chevaux")
|
||||||
@Tag(name = "Gestion des Chevaux", description = "Endpoints relatifs à l'objet cheval")
|
@CrossOrigin(origins = "*")
|
||||||
|
@Tag(name = "Gestion des Chevaux", description = "Endpoints relatifs à l'objet Cheval")
|
||||||
public class ChevalController {
|
public class ChevalController {
|
||||||
|
|
||||||
@Autowired
|
private final ChevalService chevalService;
|
||||||
private ChevalService chevalService;
|
|
||||||
|
public ChevalController(ChevalService chevalService) {
|
||||||
|
this.chevalService = chevalService;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Ajouter un cheval dans la base")
|
@Operation(summary = "Ajouter un cheval")
|
||||||
public ResponseEntity<Cheval> ajouterCheval(@RequestBody Cheval cheval) {
|
public ResponseEntity<Cheval> ajouterCheval(@RequestBody Cheval cheval) {
|
||||||
return ResponseEntity.ok(chevalService.ajouterCheval(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}")
|
@GetMapping("/course/{courseId}")
|
||||||
@Operation(summary = "Affiche les chevaux d'une Course donnée")
|
@Operation(summary = "Affiche les chevaux d'une Course donnée")
|
||||||
public ResponseEntity<List<Cheval>> obtenirChevauxParCourse(@PathVariable Long courseId) {
|
public ResponseEntity<List<Cheval>> obtenirChevauxParCourse(@PathVariable Long courseId) {
|
||||||
@@ -35,5 +44,17 @@ public class ChevalController {
|
|||||||
public ResponseEntity<List<Cheval>> obtenirChevauxParEcurie(@PathVariable String nomEcurie) {
|
public ResponseEntity<List<Cheval>> obtenirChevauxParEcurie(@PathVariable String nomEcurie) {
|
||||||
return ResponseEntity.ok(chevalService.obtenirChevauxParEcurie(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,103 @@
|
|||||||
package com.pmu.betengine.controller;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
import com.pmu.betengine.model.Cheval;
|
|
||||||
import com.pmu.betengine.model.Course;
|
import com.pmu.betengine.model.Course;
|
||||||
import com.pmu.betengine.model.dto.NewCourse;
|
import com.pmu.betengine.model.NonPartant;
|
||||||
import com.pmu.betengine.model.statut.StatutCourse;
|
import com.pmu.betengine.model.SearchParam;
|
||||||
import com.pmu.betengine.service.CourseService;
|
import com.pmu.betengine.service.CourseService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/course")
|
@RequestMapping("/api/v1/courses")
|
||||||
@Tag(name = "Gestion des Courses", description = "Endpoints relatifs à l'objet course")
|
@CrossOrigin(origins = "*")
|
||||||
|
@Tag(name = "Gestion des Courses", description = "Endpoints relatifs aux Courses")
|
||||||
public class CourseController {
|
public class CourseController {
|
||||||
|
|
||||||
@Autowired
|
private final CourseService courseService;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public CourseController(CourseService courseService) {
|
||||||
|
this.courseService = courseService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<Course>> obtenirToutesCourses() {
|
@Operation(summary = "Lister toutes les Courses")
|
||||||
return ResponseEntity.ok(courseService.obtenirToutesCourses());
|
public ResponseEntity<List<Course>> getAllCourses() {
|
||||||
|
return ResponseEntity.ok(courseService.getAllCourses());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@Operation(summary = "Obtenir une Course à travers son ID")
|
@Operation(summary = "Obtenir une Course par ID")
|
||||||
public ResponseEntity<Course> obtenirCourseParId(@PathVariable Long id) {
|
public ResponseEntity<Course> getCourseById(@PathVariable Long id) {
|
||||||
Course course = courseService.obtenirCourseParId(id);
|
return ResponseEntity.ok(courseService.getCourseById(id));
|
||||||
return course != null ? ResponseEntity.ok(course) : ResponseEntity.notFound().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/terminees")
|
// @GetMapping("/reunion/{reunionId}")
|
||||||
@Operation(summary = "Afficher toutes les courses terminées")
|
// @Operation(summary = "Lister les Courses d'une réunion")
|
||||||
public ResponseEntity<List<Course>> obtenirCoursesTerminees() {
|
// public ResponseEntity<List<Course>> getCoursesByReunion(@PathVariable Long reunionId) {
|
||||||
return ResponseEntity.ok(courseService.obtenirCoursesTerminees());
|
// return ResponseEntity.ok(courseService.getCoursesByReunionId(reunionId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
@GetMapping("/reunion/{reunionId}")
|
||||||
|
@Operation(summary = "Lister les Courses VALIDATED d'une réunion")
|
||||||
|
public ResponseEntity<List<Course>> getValidatedCoursesByReunion(@PathVariable Long reunionId) {
|
||||||
|
return ResponseEntity.ok(courseService.getCoursesByReunionIdAndStatut(reunionId, "VALIDATED"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/avenir")
|
|
||||||
@Operation(summary = "Afficher les Courses à venir")
|
|
||||||
public ResponseEntity<List<Course>> obtenirCoursesAVenir() {
|
@PostMapping
|
||||||
return ResponseEntity.ok(courseService.obtenirCoursesAVenir());
|
@Operation(summary = "Créer une Course")
|
||||||
|
public ResponseEntity<Course> createCourse(@RequestBody Course course) {
|
||||||
|
return new ResponseEntity<>(courseService.createCourse(course), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Course fromDto(NewCourse dto){
|
@PutMapping("/{id}")
|
||||||
return Course.builder()
|
@Operation(summary = "Modifier une Course")
|
||||||
.heureCourse(dto.getHeureCourse())
|
public ResponseEntity<Course> updateCourse(@PathVariable Long id, @RequestBody Course course) {
|
||||||
.numero(dto.getNumero())
|
return ResponseEntity.ok(courseService.updateCourse(id, course));
|
||||||
.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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{courseId}/non-partants")
|
||||||
|
@Operation(summary = "Remplacer la liste des non-partants d'une course")
|
||||||
|
public ResponseEntity<List<String>> replaceCourseNonPartants(
|
||||||
|
@PathVariable Long courseId,
|
||||||
|
@RequestBody List<String> nonPartants) {
|
||||||
|
return ResponseEntity.ok(courseService.replaceCourseNonPartants(courseId, nonPartants));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/searchByParams")
|
||||||
|
@Operation(summary = "Rechercher des Courses avec critères")
|
||||||
|
public ResponseEntity<List<Course>> searchCourses(@RequestBody SearchParam searchParam) {
|
||||||
|
return ResponseEntity.ok(courseService.search(searchParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
import com.pmu.betengine.model.dto.HippodromeDTO;
|
import com.pmu.betengine.model.Hippodrome;
|
||||||
import com.pmu.betengine.model.dto.HippodromeRequestDTO;
|
|
||||||
import com.pmu.betengine.service.HippodromeService;
|
import com.pmu.betengine.service.HippodromeService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/hippodromes")
|
@RequestMapping("/api/v1/hippodromes")
|
||||||
@CrossOrigin(origins = "*")
|
@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 {
|
public class HippodromeController {
|
||||||
|
|
||||||
private final HippodromeService hippodromeService;
|
private final HippodromeService hippodromeService;
|
||||||
@@ -26,45 +23,51 @@ public class HippodromeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<HippodromeDTO>> getAllHippodromes() {
|
@Operation(summary = "Lister tous les Hippodromes")
|
||||||
|
public ResponseEntity<List<Hippodrome>> getAllHippodromes() {
|
||||||
return ResponseEntity.ok(hippodromeService.getAllHippodromes());
|
return ResponseEntity.ok(hippodromeService.getAllHippodromes());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@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));
|
return ResponseEntity.ok(hippodromeService.getHippodromeById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Enregistrer Un Hippodrome",
|
@Operation(summary = "Créer un Hippodrome")
|
||||||
description = "Méthode permettant d'enregistrer l'Hippodrome")
|
public ResponseEntity<Hippodrome> createHippodrome(@RequestBody Hippodrome hippodrome) {
|
||||||
public ResponseEntity<HippodromeDTO> createHippodrome(@Valid @RequestBody HippodromeRequestDTO requestDTO) {
|
return new ResponseEntity<>(hippodromeService.createHippodrome(hippodrome), HttpStatus.CREATED);
|
||||||
return new ResponseEntity<>(hippodromeService.createHippodrome(requestDTO), HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ResponseEntity<HippodromeDTO> updateHippodrome(@PathVariable Long id, @Valid @RequestBody HippodromeRequestDTO requestDTO) {
|
@Operation(summary = "Modifier un Hippodrome")
|
||||||
return ResponseEntity.ok(hippodromeService.updateHippodrome(id, requestDTO));
|
public ResponseEntity<Hippodrome> updateHippodrome(@PathVariable Long id, @RequestBody Hippodrome hippodrome) {
|
||||||
|
return ResponseEntity.ok(hippodromeService.updateHippodrome(id, hippodrome));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@Operation(summary = "Supprimer un Hippodrome")
|
||||||
public ResponseEntity<Void> deleteHippodrome(@PathVariable Long id) {
|
public ResponseEntity<Void> deleteHippodrome(@PathVariable Long id) {
|
||||||
hippodromeService.deleteHippodrome(id);
|
hippodromeService.deleteHippodrome(id);
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/ville/{ville}")
|
@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));
|
return ResponseEntity.ok(hippodromeService.getHippodromesByVille(ville));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/actifs")
|
@GetMapping("/actifs")
|
||||||
public ResponseEntity<List<HippodromeDTO>> getHippodromesActifs() {
|
@Operation(summary = "Lister les Hippodromes actifs")
|
||||||
|
public ResponseEntity<List<Hippodrome>> getHippodromesActifs() {
|
||||||
return ResponseEntity.ok(hippodromeService.getHippodromesActifs());
|
return ResponseEntity.ok(hippodromeService.getHippodromesActifs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/reunion/{reunionId}")
|
@GetMapping("/search")
|
||||||
public ResponseEntity<HippodromeDTO> getHippodromeByReunion(@PathVariable Long reunionId) {
|
@Operation(summary = "Rechercher des Hippodromes par nom")
|
||||||
return ResponseEntity.ok(hippodromeService.getHippodromeByReunion(reunionId));
|
public ResponseEntity<List<Hippodrome>> searchHippodromes(@RequestParam String nom) {
|
||||||
|
return ResponseEntity.ok(hippodromeService.searchHippodromesByNom(nom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Mise;
|
||||||
|
import com.pmu.betengine.service.MiseService;
|
||||||
|
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/mises")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@Tag(name = "Gestion des Mises", description = "Endpoints relatifs aux Mises")
|
||||||
|
public class MiseController {
|
||||||
|
|
||||||
|
private final MiseService miseService;
|
||||||
|
|
||||||
|
public MiseController(MiseService miseService) {
|
||||||
|
this.miseService = miseService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Operation(summary = "Lister toutes les Mises")
|
||||||
|
public ResponseEntity<List<Mise>> getAllMises() {
|
||||||
|
return ResponseEntity.ok(miseService.getAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@Operation(summary = "Obtenir une Mise par ID")
|
||||||
|
public ResponseEntity<Mise> getMiseById(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(miseService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "Créer une Mise")
|
||||||
|
public ResponseEntity<Mise> createMise(@RequestBody Mise mise) {
|
||||||
|
return new ResponseEntity<>(miseService.create(mise), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
@Operation(summary = "Modifier une Mise")
|
||||||
|
public ResponseEntity<Mise> updateMise(@PathVariable Long id, @RequestBody Mise mise) {
|
||||||
|
return ResponseEntity.ok(miseService.update(id, mise));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@Operation(summary = "Supprimer une Mise")
|
||||||
|
public ResponseEntity<Void> deleteMise(@PathVariable Long id) {
|
||||||
|
miseService.delete(id);
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
import com.pmu.betengine.model.Pari;
|
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.CourseService;
|
||||||
import com.pmu.betengine.service.PariService;
|
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.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import static com.pmu.betengine.util.ChevalUtil.fromIntegerList;
|
|
||||||
import static com.pmu.betengine.util.ChevalUtil.numeroToCheval;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/pari")
|
@RequestMapping("/api/v1/pari")
|
||||||
@Tag(name = "Gestion des Pari (Bet)", description = "Endpoints relatifs à l'objet pari")
|
|
||||||
public class PariController {
|
public class PariController {
|
||||||
|
|
||||||
@Autowired
|
private final PariService pariService;
|
||||||
private PariService pariService;
|
private final CourseService courseService;
|
||||||
@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}")
|
public PariController(PariService pariService, CourseService courseService) {
|
||||||
@Operation(summary = "Affiche tous les Pari (Bet) d'une Course")
|
this.pariService = pariService;
|
||||||
@ApiResponse(responseCode = "200", description = "Paris Trouvés")
|
this.courseService = courseService;
|
||||||
public ResponseEntity<List<Pari>> obtenirParisParCourse(@PathVariable Long courseId) {
|
|
||||||
return ResponseEntity.ok(pariService.obtenirParisParCourse(courseId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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}")
|
@PutMapping("/{ticket}")
|
||||||
@Operation(summary = "Mettre à jour un Pari Existant",description = "Cette opération concerne le status (), payé ou remboursé")
|
public ResponseEntity<Pari> update(
|
||||||
@ApiResponse(responseCode = "200", description = "Pari Modifié avec succès")
|
@PathVariable String ticket,
|
||||||
@ApiResponse(responseCode = "404", description = "Pari Non Trouvé")
|
@RequestBody Pari update
|
||||||
public ResponseEntity<String> updateProduct(@PathVariable String ticket, @RequestBody updatePari updatePari) {
|
) {
|
||||||
// Find the product by ID
|
|
||||||
Pari pari = pariService.findByTicket(ticket);
|
Pari pari = pariService.findByTicket(ticket);
|
||||||
|
|
||||||
if (pari != null) {
|
if (pari == null) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pari.setStatut(update.getStatut());
|
||||||
|
pari.setEstRembourse(update.isEstRembourse());
|
||||||
|
pari.setEstPaye(update.isEstPaye());
|
||||||
|
|
||||||
|
return ResponseEntity.ok(pariService.update(pari));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/course/{courseId}/type/{typePari}")
|
// DELETE
|
||||||
public ResponseEntity<List<Pari>> obtenirParisParCourseEtType(
|
@DeleteMapping("/{id}")
|
||||||
@PathVariable Long courseId, @PathVariable TypeFormule typeFormule) {
|
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||||
return ResponseEntity.ok(pariService.obtenirParisParCourseEtType(courseId, typeFormule));
|
pariService.delete(id);
|
||||||
}
|
return ResponseEntity.noContent().build();
|
||||||
|
|
||||||
// @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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Permission;
|
||||||
|
import com.pmu.betengine.service.PermissionService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/permissions")
|
||||||
|
@CrossOrigin
|
||||||
|
public class PermissionController {
|
||||||
|
|
||||||
|
private final PermissionService permissionService;
|
||||||
|
|
||||||
|
public PermissionController(PermissionService permissionService) {
|
||||||
|
this.permissionService = permissionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Permission> create(@RequestBody Permission permission) {
|
||||||
|
return ResponseEntity.ok(permissionService.create(permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ResponseEntity<Permission> update(@PathVariable Long id, @RequestBody Permission permission) {
|
||||||
|
return ResponseEntity.ok(permissionService.update(id, permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseEntity<Permission> getById(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(permissionService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<List<Permission>> getAll() {
|
||||||
|
return ResponseEntity.ok(permissionService.getAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||||
|
permissionService.delete(id);
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +1,184 @@
|
|||||||
package com.pmu.betengine.controller;
|
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.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.CourseService;
|
||||||
import com.pmu.betengine.service.ResultatService;
|
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.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/resultat")
|
@RequestMapping("/api/v1/resultat")
|
||||||
@Tag(name = "Gestion des Resultats des Courses", description = "Endpoints relatifs à l'objet resultat")
|
|
||||||
public class ResultatController {
|
public class ResultatController {
|
||||||
@Autowired
|
|
||||||
private ResultatService resultatCourseService;
|
|
||||||
|
|
||||||
@Autowired
|
private final ResultatService resultatService;
|
||||||
private CourseService courseService;
|
private final CourseService courseService;
|
||||||
|
|
||||||
|
public ResultatController(ResultatService resultatService, CourseService courseService) {
|
||||||
|
this.resultatService = resultatService;
|
||||||
|
this.courseService = courseService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CREATE
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Enregistrer le Resultat d'une course",
|
public ResponseEntity<Resultat> create(@RequestBody Resultat dto) {
|
||||||
description = "Méthode permettant d'enregistrer le résultat d'une course")
|
|
||||||
public ResponseEntity<?> enregistrerResultat(@RequestBody NewResultat resultatDto) {
|
Course course = courseService.getCourseById(dto.getCourse().getId());
|
||||||
try {
|
|
||||||
resultatCourseService.save(fromNewResultat(resultatDto));
|
Resultat resultat = Resultat.builder()
|
||||||
return ResponseEntity.ok().build();
|
.course(course)
|
||||||
} catch (Exception e) {
|
.ordreArrivee(dto.getOrdreArrivee() != null ? dto.getOrdreArrivee() : List.of())
|
||||||
return ResponseEntity.badRequest().body(e.getMessage());
|
.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<?> getByCourse(@PathVariable Long courseId) {
|
||||||
|
Resultat r = resultatService.getByCourseId(courseId);
|
||||||
|
if (r != null) {
|
||||||
|
return ResponseEntity.ok(r);
|
||||||
|
} else {
|
||||||
|
Map<String, String> response = new HashMap<>();
|
||||||
|
response.put("message", "Aucun résultat disponible pour cette course");
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Resultat fromNewResultat(NewResultat resultat){
|
// UPDATE
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ResponseEntity<Resultat> update(@PathVariable Long id, @RequestBody Resultat update) {
|
||||||
|
Resultat existing = resultatService.getById(id);
|
||||||
|
|
||||||
return Resultat.builder()
|
if (existing == null) {
|
||||||
.course(courseService.obtenirCourseParId(resultat.getIdCourse().longValue()))
|
return ResponseEntity.notFound().build();
|
||||||
.aDeadHeat(resultat.isADeadHeat())
|
}
|
||||||
.premiers(fromIntegerList(resultat.getChevauxPremiers()))
|
|
||||||
.seconds(fromIntegerList(resultat.getChevauxDeuxiemes()))
|
update.setId(id);
|
||||||
.troisiemes(fromIntegerList(resultat.getChevauxTroisiemes()))
|
return ResponseEntity.ok(resultatService.save(update));
|
||||||
.quatriemes(fromIntegerList(resultat.getChevauxQuatriemes()))
|
|
||||||
.cinquiemes(fromIntegerList(resultat.getChevauxCinquiemes()))
|
|
||||||
.ordreArrivee(fromIntegerList(resultat.getOrdreArrivee()))
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/publish")
|
||||||
|
public ResponseEntity<Resultat> publishResultat(@RequestBody Resultat dto) {
|
||||||
|
|
||||||
|
// Fetch the course
|
||||||
|
Course course = courseService.getCourseById(dto.getCourse().getId());
|
||||||
|
|
||||||
|
// Build the resultat object
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Save resultat and update course statut
|
||||||
|
Resultat saved = resultatService.saveAndUpdateCourse(resultat);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
import com.pmu.betengine.model.dto.ReunionDTO;
|
import com.pmu.betengine.model.Reunion;
|
||||||
import com.pmu.betengine.model.dto.ReunionRequestDTO;
|
|
||||||
import com.pmu.betengine.service.ReunionService;
|
import com.pmu.betengine.service.ReunionService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -14,8 +12,8 @@ import java.util.List;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/reunions")
|
@RequestMapping("/api/v1/reunions")
|
||||||
@Tag(name = "Gestion des Réunions des Courses", description = "Endpoints relatifs à l'objet Reunion")
|
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
|
@Tag(name = "Gestion des Réunions", description = "Endpoints relatifs aux Réunions")
|
||||||
public class ReunionController {
|
public class ReunionController {
|
||||||
|
|
||||||
private final ReunionService reunionService;
|
private final ReunionService reunionService;
|
||||||
@@ -25,30 +23,38 @@ public class ReunionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<ReunionDTO>> getAllReunions() {
|
@Operation(summary = "Lister toutes les Réunions")
|
||||||
|
public ResponseEntity<List<Reunion>> getAllReunions() {
|
||||||
return ResponseEntity.ok(reunionService.getAllReunions());
|
return ResponseEntity.ok(reunionService.getAllReunions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@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));
|
return ResponseEntity.ok(reunionService.getReunionById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Enregistrer Une réunion",
|
@Operation(summary = "Créer une Réunion")
|
||||||
description = "Méthode permettant d'enregistrer la réunion")
|
public ResponseEntity<Reunion> createReunion(@RequestBody Reunion reunion) {
|
||||||
public ResponseEntity<ReunionDTO> createReunion(@Valid @RequestBody ReunionRequestDTO requestDTO) {
|
return new ResponseEntity<>(reunionService.createReunion(reunion), HttpStatus.CREATED);
|
||||||
return new ResponseEntity<>(reunionService.createReunion(requestDTO), HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ResponseEntity<ReunionDTO> updateReunion(@PathVariable Long id, @Valid @RequestBody ReunionRequestDTO requestDTO) {
|
@Operation(summary = "Modifier une Réunion")
|
||||||
return ResponseEntity.ok(reunionService.updateReunion(id, requestDTO));
|
public ResponseEntity<Reunion> updateReunion(@PathVariable Long id, @RequestBody Reunion reunion) {
|
||||||
|
return ResponseEntity.ok(reunionService.updateReunion(id, reunion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseEntity<Void> deleteReunion(@PathVariable Long id) {
|
@Operation(summary = "Supprimer une Réunion")
|
||||||
reunionService.deleteReunion(id);
|
public ResponseEntity<String> deleteReunion(@PathVariable Long id) {
|
||||||
return ResponseEntity.noContent().build();
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Role;
|
||||||
|
import com.pmu.betengine.service.RoleService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/roles")
|
||||||
|
@CrossOrigin
|
||||||
|
public class RoleController {
|
||||||
|
|
||||||
|
private final RoleService roleService;
|
||||||
|
|
||||||
|
public RoleController(RoleService roleService) {
|
||||||
|
this.roleService = roleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Role> create(@RequestBody Role role) {
|
||||||
|
return ResponseEntity.ok(roleService.create(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ResponseEntity<Role> update(@PathVariable Long id, @RequestBody Role role) {
|
||||||
|
return ResponseEntity.ok(roleService.update(id, role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseEntity<Role> getById(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(roleService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<List<Role>> getAll() {
|
||||||
|
return ResponseEntity.ok(roleService.getAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||||
|
roleService.delete(id);
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.pmu.betengine.controller;
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.TPE;
|
||||||
import com.pmu.betengine.model.dto.TPEDTO;
|
import com.pmu.betengine.model.dto.TPEDTO;
|
||||||
import com.pmu.betengine.model.dto.TPERequestDTO;
|
import com.pmu.betengine.model.dto.TPERequestDTO;
|
||||||
import com.pmu.betengine.model.statut.StatutTPE;
|
import com.pmu.betengine.model.statut.StatutTPE;
|
||||||
@@ -18,6 +19,7 @@ import java.util.Map;
|
|||||||
@RequestMapping("/api/v1/tpes")
|
@RequestMapping("/api/v1/tpes")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@Tag(name = "Gestion des TPE", description = "Endpoints relatifs à l'objet TPE")
|
@Tag(name = "Gestion des TPE", description = "Endpoints relatifs à l'objet TPE")
|
||||||
|
|
||||||
public class TPEController {
|
public class TPEController {
|
||||||
|
|
||||||
private final TPEService tpeService;
|
private final TPEService tpeService;
|
||||||
@@ -27,94 +29,84 @@ public class TPEController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<TPEDTO>> getAllTPEs() {
|
public ResponseEntity<List<TPE>> getAllTPEs() {
|
||||||
return ResponseEntity.ok(tpeService.getAllTPEs());
|
return ResponseEntity.ok(tpeService.getAllTPEs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<TPEDTO> getTPEById(@PathVariable Long id) {
|
public ResponseEntity<TPE> getTPEById(@PathVariable Long id) {
|
||||||
return ResponseEntity.ok(tpeService.getTPEById(id));
|
return ResponseEntity.ok(tpeService.getTPEById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "Enregistrer Un TPE",
|
public ResponseEntity<TPE> createTPE(@RequestBody TPE tpe) {
|
||||||
description = "Méthode permettant d'enregistrer un TPE")
|
return new ResponseEntity<>(tpeService.createTPE(tpe), HttpStatus.CREATED);
|
||||||
public ResponseEntity<TPEDTO> createTPE(@Valid @RequestBody TPERequestDTO requestDTO) {
|
|
||||||
return new ResponseEntity<>(tpeService.createTPE(requestDTO), HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@Operation(summary = "Modifier Un TPE",
|
public ResponseEntity<TPE> updateTPE(@PathVariable Long id, @RequestBody TPE tpe) {
|
||||||
description = "Méthode permettant de modifier un TPE")
|
return ResponseEntity.ok(tpeService.updateTPE(id, tpe));
|
||||||
public ResponseEntity<TPEDTO> updateTPE(@PathVariable Long id, @Valid @RequestBody TPERequestDTO requestDTO) {
|
|
||||||
return ResponseEntity.ok(tpeService.updateTPE(id, requestDTO));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@Operation(summary = "Supprimer Un TPE",
|
|
||||||
description = "Méthode permettant de supprimer un TPE")
|
|
||||||
public ResponseEntity<Void> deleteTPE(@PathVariable Long id) {
|
public ResponseEntity<Void> deleteTPE(@PathVariable Long id) {
|
||||||
tpeService.deleteTPE(id);
|
tpeService.deleteTPE(id);
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}/statut")
|
@PatchMapping("/{id}/statut")
|
||||||
@Operation(summary = "Modifier le Statut d'un TPE",
|
public ResponseEntity<TPE> updateStatut(@PathVariable Long id, @RequestBody Map<String, String> request) {
|
||||||
description = "Méthode permettant de modifier le statut d'un TPE")
|
|
||||||
public ResponseEntity<TPEDTO> updateStatut(@PathVariable Long id, @RequestBody Map<String, String> request) {
|
|
||||||
String statutStr = request.get("statut");
|
String statutStr = request.get("statut");
|
||||||
try {
|
StatutTPE statut = StatutTPE.valueOf(statutStr.toUpperCase());
|
||||||
StatutTPE statut = StatutTPE.valueOf(statutStr.toUpperCase());
|
return ResponseEntity.ok(tpeService.updateStatut(id, statut));
|
||||||
return ResponseEntity.ok(tpeService.updateStatut(id, statut));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new RuntimeException("Statut invalide: " + statutStr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}/assigner")
|
// @PatchMapping("/{id}/assigner")
|
||||||
@Operation(summary = "Assigner Un TPE",
|
// public ResponseEntity<TPE> assignerTPE(@PathVariable Long id, @RequestParam Long agentId) {
|
||||||
description = "Méthode permettant d'd'assigner un TPE")
|
// return ResponseEntity.ok(tpeService.assignerTPE(id, agentId));
|
||||||
public ResponseEntity<TPEDTO> assignerTPE(@PathVariable Long id) {
|
// }
|
||||||
return ResponseEntity.ok(tpeService.assignerTPE(id));
|
@PatchMapping("/assigner")
|
||||||
|
@Operation(summary = "Assigner Un TPE", description = "Assigner un TPE à un Agent")
|
||||||
|
public ResponseEntity<TPE> assignerTPE(@RequestBody Map<String, Long> request) {
|
||||||
|
Long tpeId = request.get("tpeId");
|
||||||
|
Long agentId = request.get("agentId");
|
||||||
|
return ResponseEntity.ok(tpeService.assignerTPE(tpeId, agentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}/liberer")
|
|
||||||
@Operation(summary = "Libérer Un TPE",
|
@PatchMapping("/liberer/{id}")
|
||||||
description = "Méthode permettant de libérer un TPE")
|
public ResponseEntity<TPE> libererTPE(@PathVariable Long id) {
|
||||||
public ResponseEntity<TPEDTO> libererTPE(@PathVariable Long id) {
|
|
||||||
return ResponseEntity.ok(tpeService.libererTPE(id));
|
return ResponseEntity.ok(tpeService.libererTPE(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/statut/{statut}")
|
@GetMapping("/statut/{statut}")
|
||||||
@Operation(summary = "Lister les TPE par statut",
|
public ResponseEntity<List<TPE>> getTPEsByStatut(@PathVariable StatutTPE statut) {
|
||||||
description = "Méthode permettant d'obtenir les TPE du statut en parametre")
|
|
||||||
public ResponseEntity<List<TPEDTO>> getTPEsByStatut(@PathVariable StatutTPE statut) {
|
|
||||||
return ResponseEntity.ok(tpeService.getTPEsByStatut(statut));
|
return ResponseEntity.ok(tpeService.getTPEsByStatut(statut));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/disponibles")
|
@GetMapping("/disponibles")
|
||||||
@Operation(summary = "Lister les TPE Disponibles",
|
public ResponseEntity<List<TPE>> getTPEsDisponibles() {
|
||||||
description = "Méthode permettant de lister les TPE disponibles")
|
|
||||||
public ResponseEntity<List<TPEDTO>> getTPEsDisponibles() {
|
|
||||||
return ResponseEntity.ok(tpeService.getTPEsDisponibles());
|
return ResponseEntity.ok(tpeService.getTPEsDisponibles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public ResponseEntity<List<TPEDTO>> searchTPEs(@RequestParam String q) {
|
public ResponseEntity<List<TPE>> searchTPEs(@RequestParam String q) {
|
||||||
return ResponseEntity.ok(tpeService.searchTPEs(q));
|
return ResponseEntity.ok(tpeService.searchTPEs(q));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/stats/count-by-statut")
|
@GetMapping("/stats/count-by-statut")
|
||||||
public ResponseEntity<Map<StatutTPE, Long>> getCountByStatut() {
|
public ResponseEntity<Map<StatutTPE, Long>> getCountByStatut() {
|
||||||
Map<StatutTPE, Long> stats = Map.of(
|
return ResponseEntity.ok(Map.of(
|
||||||
|
StatutTPE.VALIDE, tpeService.countTPEsByStatut(StatutTPE.VALIDE),
|
||||||
|
StatutTPE.INVALIDE, tpeService.countTPEsByStatut(StatutTPE.INVALIDE),
|
||||||
|
StatutTPE.EN_PANNE, tpeService.countTPEsByStatut(StatutTPE.EN_PANNE),
|
||||||
|
StatutTPE.BLOQUE, tpeService.countTPEsByStatut(StatutTPE.BLOQUE),
|
||||||
StatutTPE.DISPONIBLE, tpeService.countTPEsByStatut(StatutTPE.DISPONIBLE),
|
StatutTPE.DISPONIBLE, tpeService.countTPEsByStatut(StatutTPE.DISPONIBLE),
|
||||||
StatutTPE.AFFECTE, tpeService.countTPEsByStatut(StatutTPE.AFFECTE),
|
StatutTPE.AFFECTE, tpeService.countTPEsByStatut(StatutTPE.AFFECTE),
|
||||||
StatutTPE.EN_PANNE, tpeService.countTPEsByStatut(StatutTPE.EN_PANNE),
|
|
||||||
StatutTPE.EN_MAINTENANCE, tpeService.countTPEsByStatut(StatutTPE.EN_MAINTENANCE),
|
StatutTPE.EN_MAINTENANCE, tpeService.countTPEsByStatut(StatutTPE.EN_MAINTENANCE),
|
||||||
StatutTPE.HORS_SERVICE, tpeService.countTPEsByStatut(StatutTPE.HORS_SERVICE),
|
StatutTPE.HORS_SERVICE, tpeService.countTPEsByStatut(StatutTPE.HORS_SERVICE),
|
||||||
StatutTPE.VOLE, tpeService.countTPEsByStatut(StatutTPE.VOLE)
|
StatutTPE.VOLE, tpeService.countTPEsByStatut(StatutTPE.VOLE)
|
||||||
);
|
));
|
||||||
return ResponseEntity.ok(stats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/stats/assignes")
|
@GetMapping("/stats/assignes")
|
||||||
@@ -122,3 +114,4 @@ public class TPEController {
|
|||||||
return ResponseEntity.ok(tpeService.countTPEsAssignes());
|
return ResponseEntity.ok(tpeService.countTPEsAssignes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.pmu.betengine.controller;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.User;
|
||||||
|
import com.pmu.betengine.service.UserService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/users")
|
||||||
|
@CrossOrigin
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
public UserController(UserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<User> create(@RequestBody User user) {
|
||||||
|
return ResponseEntity.ok(userService.create(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ResponseEntity<User> update(@PathVariable Long id, @RequestBody User user) {
|
||||||
|
return ResponseEntity.ok(userService.update(id, user));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseEntity<User> getById(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(userService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<List<User>> getAll() {
|
||||||
|
return ResponseEntity.ok(userService.getAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||||
|
userService.delete(id);
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.pmu.betengine.model;
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.pmu.betengine.model.statut.StatutAgent;
|
import com.pmu.betengine.model.statut.StatutAgent;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -16,70 +17,78 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "agent")
|
@Entity
|
||||||
|
@Table(name = "agents")
|
||||||
public class Agent {
|
public class Agent {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String profile;
|
private String profile;
|
||||||
private String principalCode;
|
private String principalCode;
|
||||||
private String caisseProfile;
|
private String caisseProfile;
|
||||||
private StatutAgent statut;
|
private String statut;
|
||||||
private String zone;
|
private String zone;
|
||||||
private String kiosk;
|
private String kiosk;
|
||||||
private String fonction;
|
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)
|
@Column(name = "date_embauche")
|
||||||
private LocalDate dateEmbauche;
|
private LocalDateTime dateEmbauche;
|
||||||
@NotBlank(message = "Le nom est obligatoire")
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private String prenom;
|
private String prenom;
|
||||||
private String autresNoms;
|
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)
|
@Column(name = "date_naissance")
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
|
||||||
private LocalDate dateNaissance;
|
private LocalDate dateNaissance;
|
||||||
|
|
||||||
private String lieuNaissance;
|
private String lieuNaissance;
|
||||||
private String ville;
|
private String ville;
|
||||||
private String adresse;
|
private String adresse;
|
||||||
private Boolean autoriserAides;
|
private Boolean autoriserAides;
|
||||||
private String phone;
|
private String phone;
|
||||||
private String pin;
|
private String pin;
|
||||||
|
|
||||||
private Double limiteInferieure;
|
private Double limiteInferieure;
|
||||||
private Double limiteSuperieure;
|
private Double limiteSuperieure;
|
||||||
private Double limiteParTransaction;
|
private Double limiteParTransaction;
|
||||||
private Double limiteMinAirtime;
|
private Double limiteMinAirtime;
|
||||||
private Double limiteMaxAirtime;
|
private Double limiteMaxAirtime;
|
||||||
|
|
||||||
private Integer maxPeripheriques;
|
private Integer maxPeripheriques;
|
||||||
private String limitId;
|
|
||||||
// Légales
|
@OneToMany(mappedBy = "agent")
|
||||||
|
@JsonIgnore
|
||||||
|
private List<TPE> tpes;
|
||||||
|
|
||||||
|
@Column(name = "limit_id")
|
||||||
|
private Long limitId;
|
||||||
|
|
||||||
private String nationalite;
|
private String nationalite;
|
||||||
private String cni;
|
private String cni;
|
||||||
private String cniDelivreeLe;
|
|
||||||
|
@Column(name = "cni_delivree_le")
|
||||||
|
private LocalDate cniDelivreeLe;
|
||||||
|
|
||||||
private String cniDelivreeA;
|
private String cniDelivreeA;
|
||||||
private String residence;
|
private String residence;
|
||||||
private String autreAdresse1;
|
private String autreAdresse1;
|
||||||
private String statutMarital;
|
private String statutMarital;
|
||||||
private String epoux;
|
private String epoux;
|
||||||
private String autreTelephone;
|
private String autreTelephone;
|
||||||
// Situation familiale
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
@Column(name = "created_at")
|
||||||
@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;
|
private LocalDateTime createdAt;
|
||||||
@UpdateTimestamp
|
|
||||||
|
@Column(name = "updated_at")
|
||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
@Column(name = "created_by")
|
||||||
private String createdBy;
|
private String createdBy;
|
||||||
}
|
}
|
||||||
@@ -12,25 +12,45 @@ import lombok.NoArgsConstructor;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "agent_family_member")
|
@Entity
|
||||||
|
@Table(name = "agent_family_members")
|
||||||
public class AgentFamilyMember {
|
public class AgentFamilyMember {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
@NotBlank(message = "Le nom est obligatoire")
|
|
||||||
public String nom;
|
@Column(name = "agent_id")
|
||||||
public String statut;
|
private Long agentId;
|
||||||
@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)
|
private String nom;
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
private String statut;
|
||||||
public LocalDate dateNaissance;
|
|
||||||
@NotBlank(message = "Le sexe est obligatoire")
|
@Column(name = "date_naissance")
|
||||||
@Pattern(regexp = "^(M|F)$", message = "Le sexe doit être M (Masculin) ou F (Féminin)")
|
private LocalDate dateNaissance;
|
||||||
@Column(nullable = false, length = 1)
|
|
||||||
public String sexe;
|
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;
|
||||||
|
// }
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class AgentLimit {
|
|||||||
public String nom;
|
public String nom;
|
||||||
public boolean isDefault;
|
public boolean isDefault;
|
||||||
public boolean actif;
|
public boolean actif;
|
||||||
// Bet limits (Double for nullable number fields)
|
// Bet limits
|
||||||
public Double betMin;
|
public Double betMin;
|
||||||
public Double betMax;
|
public Double betMax;
|
||||||
public Double maxBet;
|
public Double maxBet;
|
||||||
|
|||||||
23
src/main/java/com/pmu/betengine/model/AuthRequest.java
Normal file
23
src/main/java/com/pmu/betengine/model/AuthRequest.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
public class AuthRequest {
|
||||||
|
|
||||||
|
private String identifiant;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getIdentifiant() {
|
||||||
|
return identifiant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentifiant(String identifiant) {
|
||||||
|
this.identifiant = identifiant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/main/java/com/pmu/betengine/model/AuthResponse.java
Normal file
32
src/main/java/com/pmu/betengine/model/AuthResponse.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
public class AuthResponse {
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
private Long userId;
|
||||||
|
private String nom;
|
||||||
|
private String prenom;
|
||||||
|
|
||||||
|
public AuthResponse(String message, Long userId, String nom, String prenom) {
|
||||||
|
this.message = message;
|
||||||
|
this.userId = userId;
|
||||||
|
this.nom = nom;
|
||||||
|
this.prenom = prenom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNom() {
|
||||||
|
return nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrenom() {
|
||||||
|
return prenom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,10 @@ import lombok.Builder;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@@ -20,37 +22,42 @@ import java.util.List;
|
|||||||
@Builder
|
@Builder
|
||||||
@Table(name = "course")
|
@Table(name = "course")
|
||||||
public class Course {
|
public class Course {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
private String numero;
|
private String type;
|
||||||
@OneToOne
|
private Integer numero;
|
||||||
private Reunion reunion;
|
private String nom;
|
||||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy HH:mm:ss")
|
@Column(name = "date_depart_course")
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
private LocalDateTime dateDepartCourse;
|
||||||
@Column(name = "heure_course")
|
@Column(name = "date_debut_paris")
|
||||||
private LocalDateTime heureCourse;
|
private LocalDateTime dateDebutParis;
|
||||||
private String lieu;
|
@Column(name = "date_fin_paris")
|
||||||
private int nombreChevauxInscrits;
|
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 estTerminee;
|
||||||
private boolean estAnnulee;
|
private boolean estAnnulee;
|
||||||
private boolean aDeadHeat;
|
private boolean aDeadHeat;
|
||||||
|
private String statut;
|
||||||
|
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;
|
||||||
|
@Column(name = "nom_partants")
|
||||||
|
private List<String> nonPartants;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private StatutCourse statut;
|
|
||||||
|
|
||||||
@OneToOne(mappedBy = "course")
|
|
||||||
private Resultat resultat;
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "hippodrome")
|
@Entity
|
||||||
|
@Table(name = "hippodromes")
|
||||||
public class Hippodrome {
|
public class Hippodrome {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
public String nom;
|
private String nom;
|
||||||
public String ville;
|
private String ville;
|
||||||
public String pays;
|
private 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 Boolean actif;
|
||||||
private List<Reunion> reunions;
|
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;
|
||||||
|
// }
|
||||||
|
|||||||
25
src/main/java/com/pmu/betengine/model/Mise.java
Normal file
25
src/main/java/com/pmu/betengine/model/Mise.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "mises")
|
||||||
|
public class Mise {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
String typePari;
|
||||||
|
Double montantMise;
|
||||||
|
}
|
||||||
35
src/main/java/com/pmu/betengine/model/NonPartant.java
Normal file
35
src/main/java/com/pmu/betengine/model/NonPartant.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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.TypeMulti;
|
||||||
import com.pmu.betengine.model.type.TypePari;
|
import com.pmu.betengine.model.type.TypePari;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.Pattern;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -15,94 +14,155 @@ import lombok.NoArgsConstructor;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "pari")
|
@Table(name = "pari")
|
||||||
public class Pari{
|
public class Pari {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String numeroTicket;
|
private String numeroTicket;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = "type_pari")
|
@Column(name = "type_pari")
|
||||||
private TypePari typePari;
|
private TypePari typePari;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = "type_formule")
|
@Column(name = "type_formule")
|
||||||
private TypeFormule typeFormule; // GAGNANT ou PLACE
|
private TypeFormule typeFormule;
|
||||||
|
|
||||||
private double mise = 500.0;
|
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 = "yyyy-MM-dd'T'HH:mm:ss")
|
||||||
private LocalDateTime datePari;
|
private LocalDateTime datePari;
|
||||||
|
|
||||||
private boolean estPaye;
|
private boolean estPaye;
|
||||||
private boolean estRembourse;
|
private boolean estRembourse;
|
||||||
|
private StatutParis statut;
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
@ManyToOne
|
||||||
@JoinColumn(name = "course_id")
|
@JoinColumn(name = "course_id")
|
||||||
private Course course;
|
private Course course;
|
||||||
@Column(name = "parieur_id")
|
// LIST OF SELECTED CHEVAL NUMBERS
|
||||||
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
|
@ElementCollection
|
||||||
@CollectionTable(name = "pari_chevaux_ordre", joinColumns = @JoinColumn(name = "pari_id"))
|
private List<String> chevauxSelectionnes;
|
||||||
@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
|
@ElementCollection
|
||||||
private List<Integer> ordrePredit;
|
private List<String> ordrePredit;
|
||||||
private Boolean validationOrdreExact;
|
private Boolean validationOrdreExact;
|
||||||
|
|
||||||
// MULTI
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private TypeMulti typeMulti;
|
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");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|||||||
23
src/main/java/com/pmu/betengine/model/Permission.java
Normal file
23
src/main/java/com/pmu/betengine/model/Permission.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "permissions")
|
||||||
|
public class Permission {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "resultat")
|
@Table(name = "resultat")
|
||||||
public class Resultat {
|
public class Resultat {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -23,55 +24,37 @@ public class Resultat {
|
|||||||
@JoinColumn(name = "course_id")
|
@JoinColumn(name = "course_id")
|
||||||
private Course course;
|
private Course course;
|
||||||
|
|
||||||
@ManyToMany
|
@ElementCollection
|
||||||
@CollectionTable(name = "resultat_ordre_arrivee")
|
@CollectionTable(
|
||||||
|
name = "resultat_ordre_arrivee",
|
||||||
|
joinColumns = @JoinColumn(name = "resultat_id")
|
||||||
|
)
|
||||||
@OrderColumn(name = "ordre_position")
|
@OrderColumn(name = "ordre_position")
|
||||||
private List<Cheval> ordreArrivee;
|
@Column(name = "cheval_nom")
|
||||||
|
private List<String> 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
|
@ElementCollection
|
||||||
private List<Long> chevauxDeadHeat;
|
@CollectionTable(
|
||||||
|
name = "resultat_chevaux_deadheat",
|
||||||
|
joinColumns = @JoinColumn(name = "resultat_id")
|
||||||
|
)
|
||||||
|
@Column(name = "cheval_nom")
|
||||||
|
private List<String> chevauxDeadHeat;
|
||||||
|
|
||||||
private boolean aDeadHeat;
|
private boolean aDeadHeat;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "total_mises")
|
@Column(name = "total_mises")
|
||||||
private double totalMises;
|
private double totalMises;
|
||||||
|
|
||||||
@Column(name = "masse_apartager")
|
@Column(name = "masse_apartager")
|
||||||
private double masseAPartager;
|
private double masseAPartager;
|
||||||
|
|
||||||
@Column(name = "prelevements_legaux")
|
@Column(name = "prelevements_legaux")
|
||||||
private double prelevementsLegaux;
|
private double prelevementsLegaux;
|
||||||
|
|
||||||
@Column(name = "montant_rembourse")
|
@Column(name = "montant_rembourse")
|
||||||
private double montantRembourse;
|
private double montantRembourse;
|
||||||
|
|
||||||
@Column(name = "montant_cagnotte")
|
@Column(name = "montant_cagnotte")
|
||||||
private double montantCagnotte;
|
private double montantCagnotte;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.hibernate.annotations.CreationTimestamp;
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
import org.hibernate.annotations.UpdateTimestamp;
|
import org.hibernate.annotations.UpdateTimestamp;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@@ -19,26 +21,29 @@ import java.time.LocalDateTime;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table(name = "reunion")
|
@Table(name = "reunion")
|
||||||
public class Reunion {
|
public class Reunion {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
public String code;
|
private String code;
|
||||||
public String nom;
|
private String nom;
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
|
||||||
private LocalDateTime date;
|
|
||||||
public int numero;
|
|
||||||
public StatutReunion statut;
|
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
private LocalDate date;
|
||||||
@JoinColumn(name = "hippodrome_id")
|
|
||||||
public Hippodrome hippodrome;
|
|
||||||
|
|
||||||
public Integer totalCourses;
|
private Integer numero;
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
|
||||||
@CreationTimestamp
|
private String statut;
|
||||||
|
|
||||||
|
@Column(name = "hippodrome_id")
|
||||||
|
private Long hippodromeId;
|
||||||
|
|
||||||
|
@Column(name = "total_courses")
|
||||||
|
private Integer totalCourses;
|
||||||
|
|
||||||
|
@Column(name = "created_at")
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
@JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING)
|
|
||||||
@UpdateTimestamp
|
@Column(name = "updated_at")
|
||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/main/java/com/pmu/betengine/model/Role.java
Normal file
33
src/main/java/com/pmu/betengine/model/Role.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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 = "roles")
|
||||||
|
public class Role {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(
|
||||||
|
name = "role_permissions",
|
||||||
|
joinColumns = @JoinColumn(name = "role_id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(name = "permission_id")
|
||||||
|
)
|
||||||
|
private List<Permission> permissions;
|
||||||
|
}
|
||||||
31
src/main/java/com/pmu/betengine/model/SearchParam.java
Normal file
31
src/main/java/com/pmu/betengine/model/SearchParam.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.pmu.betengine.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SearchParam implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private LocalDate date;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
private Long categoryId;
|
||||||
|
|
||||||
|
private String criteria;
|
||||||
|
private String query;
|
||||||
|
private String annee;
|
||||||
|
private String mois;
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private int page = 0;
|
||||||
|
private int pageSize = 10;
|
||||||
|
|
||||||
|
public SearchParam() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,6 +54,11 @@ public class TPE {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private StatutTPE statut = StatutTPE.DISPONIBLE;
|
private StatutTPE statut = StatutTPE.DISPONIBLE;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "agent_id")
|
||||||
|
private Agent agent;
|
||||||
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private boolean assigne = false;
|
private boolean assigne = false;
|
||||||
|
|
||||||
|
|||||||
53
src/main/java/com/pmu/betengine/model/User.java
Normal file
53
src/main/java/com/pmu/betengine/model/User.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
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;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "users")
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nom;
|
||||||
|
private String prenom;
|
||||||
|
private String identifiant;
|
||||||
|
private String password;
|
||||||
|
private String matriculeAgent;
|
||||||
|
|
||||||
|
@Column(name = "role_id")
|
||||||
|
private Long 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;
|
package com.pmu.betengine.model.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.pmu.betengine.model.statut.StatutReunion;
|
import com.pmu.betengine.model.statut.StatutReunion;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ReunionRequestDTO {
|
public class ReunionRequestDTO {
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
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 int numero;
|
||||||
private StatutReunion statut;
|
private StatutReunion statut;
|
||||||
private Integer totalCourses;
|
private Integer totalCourses;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.pmu.betengine.model.statut;
|
||||||
|
|
||||||
|
public enum StatutUser {
|
||||||
|
ACTIF,
|
||||||
|
INACTIF,
|
||||||
|
SUSPENDU
|
||||||
|
}
|
||||||
@@ -28,6 +28,4 @@ public enum TypeFormule {
|
|||||||
CHAMP_TOTAL_1,
|
CHAMP_TOTAL_1,
|
||||||
CHAMP_PARTIEL_1,
|
CHAMP_PARTIEL_1,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ public enum TypePaiement {
|
|||||||
QUARTE_PLUS_ORDRE_INEXACT,
|
QUARTE_PLUS_ORDRE_INEXACT,
|
||||||
BONUS_3,
|
BONUS_3,
|
||||||
BONUS_3_BIS,
|
BONUS_3_BIS,
|
||||||
|
|
||||||
MULTI_4,
|
MULTI_4,
|
||||||
|
|
||||||
MULTI_5,
|
MULTI_5,
|
||||||
MULTI_6,
|
MULTI_6,
|
||||||
MULTI_7,
|
MULTI_7,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package com.pmu.betengine.model.type;
|
package com.pmu.betengine.model.type;
|
||||||
|
|
||||||
public enum TypePari {
|
public enum TypePari {
|
||||||
SIMPLE,
|
SIMPLE,
|
||||||
JUMELE_GAGNANT,
|
JUMELE_GAGNANT,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface AgentFamilyMemberRepository extends JpaRepository<AgentFamilyMember, Long> {
|
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
|
@Repository
|
||||||
public interface ChevalRepository extends JpaRepository<Cheval, Long> {
|
public interface ChevalRepository extends JpaRepository<Cheval, Long> {
|
||||||
//List<Cheval> findByCourseId(Long courseId);
|
|
||||||
List<Cheval> findByNomEcurie(String nomEcurie);
|
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);
|
||||||
|
}
|
||||||
@@ -2,11 +2,39 @@ package com.pmu.betengine.repository;
|
|||||||
|
|
||||||
import com.pmu.betengine.model.Course;
|
import com.pmu.betengine.model.Course;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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 org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CourseRepository extends JpaRepository<Course, Long> {
|
public interface CourseRepository extends JpaRepository<Course, Long> {
|
||||||
|
|
||||||
|
// Find courses by "estTerminee" boolean (if you still track this)
|
||||||
List<Course> findByEstTerminee(boolean estTerminee);
|
List<Course> findByEstTerminee(boolean estTerminee);
|
||||||
|
|
||||||
|
// Search courses by name
|
||||||
|
List<Course> findByNomContainingIgnoreCase(String nom);
|
||||||
|
|
||||||
|
List<Course> findByReunionId(Long reunionId);
|
||||||
|
|
||||||
|
List<Course> findByReunionIdAndStatut(Long reunionId, String statut);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM Course c " +
|
||||||
|
"WHERE c.dateDebutParis >= :startOfDay " +
|
||||||
|
"AND c.dateDebutParis < :endOfDay " +
|
||||||
|
"AND c.dateFinParis >= :now " +
|
||||||
|
"AND c.statut = 'VALIDATED'")
|
||||||
|
List<Course> findByDateDebutParisAndNotFinished(
|
||||||
|
@Param("startOfDay") LocalDateTime startOfDay,
|
||||||
|
@Param("endOfDay") LocalDateTime endOfDay,
|
||||||
|
@Param("now") LocalDateTime now
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package com.pmu.betengine.repository;
|
|||||||
|
|
||||||
import com.pmu.betengine.model.Hippodrome;
|
import com.pmu.betengine.model.Hippodrome;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface HippodromeRepository extends JpaRepository<Hippodrome, Long> {
|
public interface HippodromeRepository extends JpaRepository<Hippodrome, Long> {
|
||||||
|
|
||||||
Optional<Hippodrome> findByNom(String nom);
|
boolean existsByNom(String nom);
|
||||||
|
|
||||||
List<Hippodrome> findByVille(String ville);
|
List<Hippodrome> findByVille(String ville);
|
||||||
|
|
||||||
@@ -19,10 +17,5 @@ public interface HippodromeRepository extends JpaRepository<Hippodrome, Long> {
|
|||||||
|
|
||||||
List<Hippodrome> findByActif(boolean actif);
|
List<Hippodrome> findByActif(boolean actif);
|
||||||
|
|
||||||
boolean existsByNom(String nom);
|
List<Hippodrome> findByNomContainingIgnoreCase(String nom);
|
||||||
|
|
||||||
@Query("SELECT h FROM Hippodrome h WHERE h.nom LIKE %:nom%")
|
|
||||||
List<Hippodrome> findByNomContaining(String nom);
|
|
||||||
|
|
||||||
Optional<Hippodrome> findByReunionId(Long reunionId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.pmu.betengine.repository;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Mise;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface MiseRepository extends JpaRepository<Mise, Long> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
@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.Pari;
|
||||||
import com.pmu.betengine.model.type.TypeFormule;
|
import com.pmu.betengine.model.type.TypeFormule;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface PariRepository extends JpaRepository<Pari, Long> {
|
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);
|
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);
|
||||||
|
// }
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.pmu.betengine.repository;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Permission;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface PermissionRepository extends JpaRepository<Permission, Long> {
|
||||||
|
}
|
||||||
@@ -2,24 +2,54 @@ package com.pmu.betengine.repository;
|
|||||||
|
|
||||||
import com.pmu.betengine.model.Resultat;
|
import com.pmu.betengine.model.Resultat;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ResultatRepository extends JpaRepository<Resultat, Long> {
|
public interface ResultatRepository extends JpaRepository<Resultat, Long> {
|
||||||
|
|
||||||
Optional<Resultat> findByCourseId(Long courseId);
|
Optional<Resultat> findByCourseId(Long courseId);
|
||||||
|
|
||||||
@Query("SELECT r FROM Resultat r WHERE r.course.id = :courseId")
|
@Query("SELECT r FROM Resultat r WHERE r.course.id = :courseId")
|
||||||
Optional<Resultat> findByCourse(@Param("courseId") Long 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(Long courseId);
|
||||||
boolean existsByCourseId(@Param("courseId") Long courseId);
|
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Transactional
|
||||||
@Query("DELETE FROM Resultat r WHERE r.course.id = :courseId")
|
@Query("DELETE FROM Resultat r WHERE r.course.id = :courseId")
|
||||||
void deleteByCourseId(@Param("courseId") Long 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
|
@Repository
|
||||||
public interface ReunionRepository extends JpaRepository<Reunion, Long> {
|
public interface ReunionRepository extends JpaRepository<Reunion, Long> {
|
||||||
|
|
||||||
Optional<Reunion> findByCode(String code);
|
Optional<Reunion> findByCode(String code);
|
||||||
|
|
||||||
boolean existsByCode(String code);
|
boolean existsByCode(String code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.pmu.betengine.repository;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Role;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface RoleRepository extends JpaRepository<Role, Long> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.pmu.betengine.repository;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.User;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
|
|
||||||
|
// Récupérer un utilisateur par identifiant (connexion)
|
||||||
|
Optional<User> findByIdentifiant(String identifiant);
|
||||||
|
|
||||||
|
// Vérifier si un identifiant existe déjà (création)
|
||||||
|
boolean existsByIdentifiant(String identifiant);
|
||||||
|
|
||||||
|
// Vérifier si un matricule existe déjà (création)
|
||||||
|
boolean existsByMatriculeAgent(String matriculeAgent);
|
||||||
|
}
|
||||||
@@ -1,121 +1,84 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
import com.pmu.betengine.model.AgentFamilyMember;
|
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 com.pmu.betengine.repository.AgentFamilyMemberRepository;
|
||||||
import org.modelmapper.ModelMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class AgentFamilyMemberService {
|
public class AgentFamilyMemberService {
|
||||||
|
|
||||||
private final AgentFamilyMemberRepository agentFamilyMemberRepository;
|
private final AgentFamilyMemberRepository repository;
|
||||||
private final ModelMapper modelMapper;
|
|
||||||
|
|
||||||
public AgentFamilyMemberService(AgentFamilyMemberRepository agentFamilyMemberRepository,
|
public AgentFamilyMemberService(AgentFamilyMemberRepository repository) {
|
||||||
ModelMapper modelMapper) {
|
this.repository = repository;
|
||||||
this.agentFamilyMemberRepository = agentFamilyMemberRepository;
|
|
||||||
this.modelMapper = modelMapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AgentFamilyMemberDTO> getAllFamilyMembers() {
|
// Create
|
||||||
return agentFamilyMemberRepository.findAllOrderByNom()
|
public AgentFamilyMember createFamilyMember(AgentFamilyMember member) {
|
||||||
.stream()
|
if (repository.existsByNomAndDateNaissance(member.getNom(), member.getDateNaissance())) {
|
||||||
.map(this::convertToDTO)
|
throw new RuntimeException("Un membre avec ce nom et cette date de naissance existe déjà");
|
||||||
.collect(Collectors.toList());
|
}
|
||||||
|
return repository.save(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentFamilyMemberDTO getFamilyMemberById(Long id) {
|
// Get all
|
||||||
AgentFamilyMember member = agentFamilyMemberRepository.findById(id)
|
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));
|
.orElseThrow(() -> new RuntimeException("Membre de famille non trouvé avec l'id: " + id));
|
||||||
return convertToDTO(member);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentFamilyMemberDTO createFamilyMember(AgentFamilyMemberRequestDTO requestDTO) {
|
// Update
|
||||||
// Vérifier si le membre existe déjà
|
public AgentFamilyMember updateFamilyMember(Long id, AgentFamilyMember updated) {
|
||||||
if (agentFamilyMemberRepository.existsByNomAndDateNaissance(requestDTO.getNom(), requestDTO.getDateNaissance())) {
|
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à");
|
throw new RuntimeException("Un membre avec ce nom et cette date de naissance existe déjà");
|
||||||
}
|
}
|
||||||
|
|
||||||
AgentFamilyMember member = convertToEntity(requestDTO);
|
existing.setAgentId(updated.getAgentId());
|
||||||
AgentFamilyMember saved = agentFamilyMemberRepository.save(member);
|
existing.setNom(updated.getNom());
|
||||||
return convertToDTO(saved);
|
existing.setStatut(updated.getStatut());
|
||||||
|
existing.setDateNaissance(updated.getDateNaissance());
|
||||||
|
existing.setSexe(updated.getSexe());
|
||||||
|
|
||||||
|
return repository.save(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentFamilyMemberDTO updateFamilyMember(Long id, AgentFamilyMemberRequestDTO requestDTO) {
|
// Delete
|
||||||
AgentFamilyMember existing = agentFamilyMemberRepository.findById(id)
|
public String deleteFamilyMember(Long id) {
|
||||||
.orElseThrow(() -> new RuntimeException("Membre de famille non trouvé avec l'id: " + id));
|
if (!repository.existsById(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)) {
|
|
||||||
throw new RuntimeException("Membre de famille non trouvé avec l'id: " + 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) {
|
// Search / Filters
|
||||||
return agentFamilyMemberRepository.findByStatut(statut)
|
public List<AgentFamilyMember> getFamilyMembersByStatut(String statut) {
|
||||||
.stream()
|
return repository.findByStatut(statut);
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AgentFamilyMemberDTO> getFamilyMembersBySexe(String sexe) {
|
public List<AgentFamilyMember> getFamilyMembersBySexe(String sexe) {
|
||||||
return agentFamilyMemberRepository.findBySexe(sexe)
|
return repository.findBySexe(sexe);
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AgentFamilyMemberDTO> searchFamilyMembers(String keyword) {
|
public List<AgentFamilyMember> searchFamilyMembers(String keyword) {
|
||||||
return agentFamilyMemberRepository.searchByKeyword(keyword)
|
return repository.searchByKeyword(keyword);
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AgentFamilyMemberDTO> getFamilyMembersByNom(String nom) {
|
public List<AgentFamilyMember> getFamilyMembersByNom(String nom) {
|
||||||
return agentFamilyMemberRepository.findByNomContainingIgnoreCase(nom)
|
return repository.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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
agentLimit.actif=true;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/main/java/com/pmu/betengine/service/AuthService.java
Normal file
40
src/main/java/com/pmu/betengine/service/AuthService.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.AuthRequest;
|
||||||
|
import com.pmu.betengine.model.AuthResponse;
|
||||||
|
import com.pmu.betengine.model.User;
|
||||||
|
import com.pmu.betengine.repository.UserRepository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AuthService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
@Autowired
|
||||||
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
|
public AuthService(UserRepository userRepository) {
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public User login(AuthRequest request) {
|
||||||
|
User user = userRepository.findByIdentifiant(request.getIdentifiant())
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||||
|
|
||||||
|
if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
|
||||||
|
throw new RuntimeException("Invalid credentials");
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setDerniereConnexion(LocalDateTime.now());
|
||||||
|
return userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,26 +2,47 @@ package com.pmu.betengine.service;
|
|||||||
|
|
||||||
import com.pmu.betengine.model.Cheval;
|
import com.pmu.betengine.model.Cheval;
|
||||||
import com.pmu.betengine.repository.ChevalRepository;
|
import com.pmu.betengine.repository.ChevalRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional
|
||||||
public class ChevalService {
|
public class ChevalService {
|
||||||
|
|
||||||
@Autowired
|
private final ChevalRepository chevalRepository;
|
||||||
private ChevalRepository chevalRepository;
|
|
||||||
|
public ChevalService(ChevalRepository chevalRepository) {
|
||||||
|
this.chevalRepository = chevalRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public Cheval ajouterCheval(Cheval cheval) {
|
public Cheval ajouterCheval(Cheval cheval) {
|
||||||
return chevalRepository.save(cheval);
|
return chevalRepository.save(cheval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Cheval> obtenirChevauxParCourse(Long courseId) {
|
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) {
|
public List<Cheval> obtenirChevauxParEcurie(String nomEcurie) {
|
||||||
return chevalRepository.findByNomEcurie(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,37 +1,158 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
|
||||||
import com.pmu.betengine.model.Course;
|
import com.pmu.betengine.model.Course;
|
||||||
|
import com.pmu.betengine.model.NonPartant;
|
||||||
|
import com.pmu.betengine.model.SearchParam;
|
||||||
import com.pmu.betengine.repository.CourseRepository;
|
import com.pmu.betengine.repository.CourseRepository;
|
||||||
|
import com.pmu.betengine.repository.ReunionRepository;
|
||||||
|
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CourseService {
|
public class CourseService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseRepository courseRepository;
|
private CourseRepository courseRepository;
|
||||||
|
@Autowired
|
||||||
|
private ReunionRepository reunionRepository;
|
||||||
|
|
||||||
public Course creerCourse(Course course) {
|
// Create
|
||||||
return courseRepository.save(course);
|
public Course createCourse(Course course) {
|
||||||
|
// Vérifie si la réunion existe
|
||||||
|
if (course.getReunionId() == null ||
|
||||||
|
!reunionRepository.existsById(course.getReunionId())) {
|
||||||
|
throw new IllegalArgumentException("Impossible de créer la course : réunion invalide");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Course> obtenirToutesCourses() {
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
course.setCreatedAt(now);
|
||||||
|
course.setUpdatedAt(now);
|
||||||
|
|
||||||
|
return courseRepository.save(course);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all
|
||||||
|
public List<Course> getAllCourses() {
|
||||||
return courseRepository.findAll();
|
return courseRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Course obtenirCourseParId(Long id) {
|
// Get by ID
|
||||||
return courseRepository.findById(id).orElse(null);
|
public Course getCourseById(Long id) {
|
||||||
|
return courseRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Course not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Course> obtenirCoursesTerminees() {
|
// Update
|
||||||
return courseRepository.findByEstTerminee(true);
|
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() {
|
// Delete
|
||||||
return courseRepository.findByEstTerminee(false);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Course> getCoursesByReunionId(Long reunionId) {
|
||||||
|
return courseRepository.findByReunionId(reunionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Course> getCoursesByReunionIdAndStatut(Long reunionId, String statut) {
|
||||||
|
return courseRepository.findByReunionIdAndStatut(reunionId, statut);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<String> replaceCourseNonPartants(Long courseId, List<String> newNonPartants) {
|
||||||
|
if (courseId == null) {
|
||||||
|
throw new IllegalArgumentException("L'identifiant de la course est obligatoire.");
|
||||||
|
}
|
||||||
|
Course course = courseRepository.findById(courseId)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Aucune course trouvée avec l'ID : " + courseId));
|
||||||
|
|
||||||
|
if (newNonPartants == null) {
|
||||||
|
throw new IllegalArgumentException("La liste des non-partants ne peut pas être nulle.");
|
||||||
|
}
|
||||||
|
course.setNonPartants(newNonPartants);
|
||||||
|
course.setUpdatedAt(LocalDateTime.now());
|
||||||
|
courseRepository.save(course);
|
||||||
|
return course.getNonPartants();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<Course> search(SearchParam searchParam) {
|
||||||
|
System.out.println("******************** THE SEARCH PARAM " + searchParam);
|
||||||
|
|
||||||
|
if (searchParam.getCriteria() == null) {
|
||||||
|
throw new IllegalArgumentException("Le paramètre 'criteria' est obligatoire et ne peut pas être null");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String criteria = searchParam.getCriteria();
|
||||||
|
|
||||||
|
if (criteria.equals("1")) {
|
||||||
|
return courseRepository.findAll();
|
||||||
|
} else if(criteria.equals("2") && searchParam.getDate() != null) {
|
||||||
|
LocalDate date = searchParam.getDate();
|
||||||
|
LocalDateTime startOfDay = date.atStartOfDay();
|
||||||
|
LocalDateTime endOfDay = startOfDay.plusDays(1);
|
||||||
|
return courseRepository.findByDateDebutParisAndNotFinished(
|
||||||
|
startOfDay,
|
||||||
|
endOfDay,
|
||||||
|
LocalDateTime.now()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Cas par défaut
|
||||||
|
return courseRepository.findAll();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException("Erreur lors de la recherche des courses");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,77 +1,57 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
import com.pmu.betengine.model.Hippodrome;
|
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.HippodromeRepository;
|
||||||
import com.pmu.betengine.repository.ReunionRepository;
|
|
||||||
import org.modelmapper.ModelMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
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.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
|
||||||
public class HippodromeService {
|
public class HippodromeService {
|
||||||
|
|
||||||
private final HippodromeRepository hippodromeRepository;
|
private final HippodromeRepository hippodromeRepository;
|
||||||
private final ReunionRepository reunionRepository;
|
|
||||||
private final ModelMapper modelMapper;
|
|
||||||
|
|
||||||
public HippodromeService(HippodromeRepository hippodromeRepository,
|
public HippodromeService(HippodromeRepository hippodromeRepository) {
|
||||||
ReunionRepository reunionRepository,
|
|
||||||
ModelMapper modelMapper) {
|
|
||||||
this.hippodromeRepository = hippodromeRepository;
|
this.hippodromeRepository = hippodromeRepository;
|
||||||
this.reunionRepository = reunionRepository;
|
|
||||||
this.modelMapper = modelMapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HippodromeDTO> getAllHippodromes() {
|
public Hippodrome createHippodrome(Hippodrome hippodrome) {
|
||||||
return hippodromeRepository.findAll()
|
if (hippodromeRepository.existsByNom(hippodrome.getNom())) {
|
||||||
.stream()
|
throw new RuntimeException("Un hippodrome avec ce nom existe déjà: " + hippodrome.getNom());
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HippodromeDTO getHippodromeById(Long id) {
|
hippodrome.setCreatedAt(LocalDateTime.now());
|
||||||
Hippodrome hippodrome = hippodromeRepository.findById(id)
|
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));
|
.orElseThrow(() -> new RuntimeException("Hippodrome non trouvé avec l'id: " + id));
|
||||||
return convertToDTO(hippodrome);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HippodromeDTO createHippodrome(HippodromeRequestDTO requestDTO) {
|
// Update
|
||||||
if (hippodromeRepository.existsByNom(requestDTO.getNom())) {
|
public Hippodrome updateHippodrome(Long id, Hippodrome updatedHippodrome) {
|
||||||
throw new RuntimeException("Un hippodrome avec ce nom existe déjà: " + requestDTO.getNom());
|
Hippodrome existing = getHippodromeById(id);
|
||||||
}
|
existing.setNom(updatedHippodrome.getNom());
|
||||||
|
existing.setVille(updatedHippodrome.getVille());
|
||||||
Hippodrome hippodrome = convertToEntity(requestDTO);
|
existing.setPays(updatedHippodrome.getPays());
|
||||||
|
existing.setActif(updatedHippodrome.getActif());
|
||||||
Hippodrome saved = hippodromeRepository.save(hippodrome);
|
existing.setCapacite(updatedHippodrome.getCapacite());
|
||||||
return convertToDTO(saved);
|
existing.setDescription(updatedHippodrome.getDescription());
|
||||||
}
|
return hippodromeRepository.save(existing);
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
public void deleteHippodrome(Long id) {
|
public void deleteHippodrome(Long id) {
|
||||||
if (!hippodromeRepository.existsById(id)) {
|
if (!hippodromeRepository.existsById(id)) {
|
||||||
throw new RuntimeException("Hippodrome non trouvé avec l'id: " + id);
|
throw new RuntimeException("Hippodrome non trouvé avec l'id: " + id);
|
||||||
@@ -79,43 +59,18 @@ public class HippodromeService {
|
|||||||
hippodromeRepository.deleteById(id);
|
hippodromeRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HippodromeDTO> getHippodromesByVille(String ville) {
|
// Search by ville
|
||||||
return hippodromeRepository.findByVille(ville)
|
public List<Hippodrome> getHippodromesByVille(String ville) {
|
||||||
.stream()
|
return hippodromeRepository.findByVille(ville);
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HippodromeDTO> getHippodromesActifs() {
|
// Get only active hippodromes
|
||||||
return hippodromeRepository.findByActif(true)
|
public List<Hippodrome> getHippodromesActifs() {
|
||||||
.stream()
|
return hippodromeRepository.findByActif(true);
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HippodromeDTO getHippodromeByReunion(Long reunionId) {
|
// Search by name
|
||||||
Hippodrome hippodrome = hippodromeRepository.findByReunionId(reunionId)
|
public List<Hippodrome> searchHippodromesByNom(String nom) {
|
||||||
.orElseThrow(() -> new RuntimeException("Aucun hippodrome trouvé pour la réunion avec l'id: " + reunionId));
|
return hippodromeRepository.findByNomContainingIgnoreCase(nom);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
src/main/java/com/pmu/betengine/service/MiseService.java
Normal file
41
src/main/java/com/pmu/betengine/service/MiseService.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Mise;
|
||||||
|
import com.pmu.betengine.repository.MiseRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MiseService {
|
||||||
|
|
||||||
|
private final MiseRepository repository;
|
||||||
|
|
||||||
|
public MiseService(MiseRepository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mise create(Mise mise) {
|
||||||
|
return repository.save(mise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mise getById(Long id) {
|
||||||
|
return repository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Mise not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Mise> getAll() {
|
||||||
|
return repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mise update(Long id, Mise mise) {
|
||||||
|
Mise existing = getById(id);
|
||||||
|
existing.setTypePari(mise.getTypePari());
|
||||||
|
existing.setMontantMise(mise.getMontantMise());
|
||||||
|
return repository.save(existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Long id) {
|
||||||
|
repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
@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.Pari;
|
||||||
import com.pmu.betengine.model.statut.StatutParis;
|
import com.pmu.betengine.model.statut.StatutParis;
|
||||||
import com.pmu.betengine.model.type.TypeFormule;
|
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.CourseRepository;
|
||||||
import com.pmu.betengine.repository.PariRepository;
|
import com.pmu.betengine.repository.PariRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,52 +13,142 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class PariService {
|
public class PariService {
|
||||||
|
|
||||||
@Autowired
|
private final PariRepository pariRepository;
|
||||||
private PariRepository pariRepository;
|
private final CourseRepository courseRepository;
|
||||||
|
|
||||||
@Autowired
|
public PariService(PariRepository pariRepository, CourseRepository courseRepository) {
|
||||||
private CourseRepository courseRepository;
|
this.pariRepository = pariRepository;
|
||||||
|
this.courseRepository = courseRepository;
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
// CREATE
|
||||||
private ChevalRepository chevalRepository;
|
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);
|
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) {
|
Course course = pari.getCourse();
|
||||||
throw new IllegalArgumentException("Pari PLACE impossible: moins de 3 chevaux");
|
|
||||||
|
// // 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.");
|
||||||
|
// }
|
||||||
|
// Business rules
|
||||||
|
if (pari.getTypeFormule() == TypeFormule.GAGNANT && course.getPartants() < 2) {
|
||||||
|
throw new IllegalArgumentException("Pari GAGNANT impossible: moins de 2 chevaux.");
|
||||||
|
}
|
||||||
|
if (pari.getTypeFormule() == TypeFormule.PLACE && course.getPartants() < 3) {
|
||||||
|
throw new IllegalArgumentException("Pari PLACE impossible: moins de 3 chevaux.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return pariRepository.save(pari);
|
return pariRepository.save(pari);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pari update(Pari pari){
|
// GET ALL
|
||||||
return pariRepository.save(pari);
|
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);
|
// DELETE
|
||||||
}
|
public void delete(Long id) {
|
||||||
public List<Pari> obtenirParisParCourse(Long courseId) {
|
pariRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET BY COURSE
|
||||||
|
public List<Pari> getByCourse(Long courseId) {
|
||||||
return pariRepository.findByCourseId(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);
|
return pariRepository.findByCourseIdAndTypeFormule(courseId, typeFormule);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Pari> obtenirParisParCheval(Long chevalId) {
|
// UPDATE
|
||||||
return pariRepository.findByChevalId(chevalId);
|
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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Permission;
|
||||||
|
import com.pmu.betengine.repository.PermissionRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PermissionService {
|
||||||
|
|
||||||
|
private final PermissionRepository permissionRepository;
|
||||||
|
|
||||||
|
public PermissionService(PermissionRepository permissionRepository) {
|
||||||
|
this.permissionRepository = permissionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Permission create(Permission permission) {
|
||||||
|
return permissionRepository.save(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Permission update(Long id, Permission updatedPermission) {
|
||||||
|
return permissionRepository.findById(id).map(permission -> {
|
||||||
|
permission.setName(updatedPermission.getName());
|
||||||
|
permission.setDescription(updatedPermission.getDescription());
|
||||||
|
return permissionRepository.save(permission);
|
||||||
|
}).orElseThrow(() -> new RuntimeException("Permission not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Permission getById(Long id) {
|
||||||
|
return permissionRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Permission not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Permission> getAll() {
|
||||||
|
return permissionRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Long id) {
|
||||||
|
permissionRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,102 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Course;
|
||||||
import com.pmu.betengine.model.Resultat;
|
import com.pmu.betengine.model.Resultat;
|
||||||
import com.pmu.betengine.repository.ResultatRepository;
|
import com.pmu.betengine.repository.ResultatRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ResultatService {
|
public class ResultatService {
|
||||||
|
|
||||||
private final ResultatRepository resultatCourseRepository;
|
private final ResultatRepository resultatRepository;
|
||||||
|
private final CourseService courseService;
|
||||||
|
|
||||||
public Optional<Resultat> findByCourseId(Long courseId) {
|
// CREATE / UPDATE
|
||||||
return resultatCourseRepository.findByCourseId(courseId);
|
public Resultat save(Resultat resultat) {
|
||||||
|
return resultatRepository.save(resultat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resultat save(Resultat resultatCourse) {
|
// GET ALL
|
||||||
return resultatCourseRepository.save(resultatCourse);
|
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) {
|
public void deleteByCourseId(Long courseId) {
|
||||||
resultatCourseRepository.deleteByCourseId(courseId);
|
resultatRepository.deleteByCourseId(courseId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public Resultat saveAndUpdateCourse(Resultat resultat) {
|
||||||
|
// Save the resultat
|
||||||
|
Resultat savedResultat = resultatRepository.save(resultat);
|
||||||
|
|
||||||
|
// Update the course statut
|
||||||
|
Course course = savedResultat.getCourse();
|
||||||
|
if (course != null) {
|
||||||
|
course.setStatut("RESULT_PUBLISHED"); // or whatever statut you want
|
||||||
|
courseService.updateCourse(course.getId(), course);
|
||||||
|
}
|
||||||
|
|
||||||
|
return savedResultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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,78 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
import com.pmu.betengine.model.Reunion;
|
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 com.pmu.betengine.repository.ReunionRepository;
|
||||||
import org.modelmapper.ModelMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
|
||||||
public class ReunionService {
|
public class ReunionService {
|
||||||
|
|
||||||
private final ReunionRepository reunionRepository;
|
private final ReunionRepository reunionRepository;
|
||||||
private final ModelMapper modelMapper;
|
|
||||||
|
|
||||||
public ReunionService(ReunionRepository reunionRepository, ModelMapper modelMapper) {
|
public ReunionService(ReunionRepository reunionRepository) {
|
||||||
this.reunionRepository = reunionRepository;
|
this.reunionRepository = reunionRepository;
|
||||||
this.modelMapper = modelMapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReunionDTO> getAllReunions() {
|
// Create
|
||||||
return reunionRepository.findAll()
|
public Reunion createReunion(Reunion reunion) {
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReunionDTO getReunionById(Long id) {
|
// Check if hippodrome ID is missing
|
||||||
Reunion reunion = reunionRepository.findById(id)
|
if (reunion.getHippodromeId() == null) {
|
||||||
.orElseThrow(() -> new RuntimeException("Reunion non trouvée"));
|
throw new RuntimeException("Aucun hippodrome assigné à cette réunion.");
|
||||||
return convertToDTO(reunion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReunionDTO createReunion(ReunionRequestDTO requestDTO) {
|
|
||||||
if (reunionRepository.existsByCode(requestDTO.getCode())) {
|
|
||||||
throw new RuntimeException("Code déjà existant");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reunion reunion = convertToEntity(requestDTO);
|
// Check if reunion code already exists
|
||||||
|
if (reunionRepository.existsByCode(reunion.getCode())) {
|
||||||
|
throw new RuntimeException("Code déjà existant: " + reunion.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
reunion.setCreatedAt(LocalDateTime.now());
|
reunion.setCreatedAt(LocalDateTime.now());
|
||||||
Reunion saved = reunionRepository.save(reunion);
|
reunion.setUpdatedAt(LocalDateTime.now());
|
||||||
return convertToDTO(saved);
|
|
||||||
|
return reunionRepository.save(reunion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get all
|
||||||
|
public List<Reunion> getAllReunions() {
|
||||||
|
return reunionRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReunionDTO updateReunion(Long id, ReunionRequestDTO requestDTO) {
|
// Get by ID
|
||||||
Reunion existing = reunionRepository.findById(id)
|
public Reunion getReunionById(Long id) {
|
||||||
.orElseThrow(() -> new RuntimeException("Reunion non trouvée"));
|
return reunionRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Réunion non trouvée avec l'id: " + id));
|
||||||
|
}
|
||||||
|
|
||||||
modelMapper.map(requestDTO, existing);
|
// 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());
|
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);
|
reunionRepository.deleteById(id);
|
||||||
|
return "Réunion avec l'ID " + id + " supprimée avec succès.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReunionDTO convertToDTO(Reunion reunion) {
|
// Find by code
|
||||||
return modelMapper.map(reunion, ReunionDTO.class);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
43
src/main/java/com/pmu/betengine/service/RoleService.java
Normal file
43
src/main/java/com/pmu/betengine/service/RoleService.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Role;
|
||||||
|
import com.pmu.betengine.repository.RoleRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RoleService {
|
||||||
|
|
||||||
|
private final RoleRepository roleRepository;
|
||||||
|
|
||||||
|
public RoleService(RoleRepository roleRepository) {
|
||||||
|
this.roleRepository = roleRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role create(Role role) {
|
||||||
|
return roleRepository.save(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role update(Long id, Role updatedRole) {
|
||||||
|
return roleRepository.findById(id).map(role -> {
|
||||||
|
role.setName(updatedRole.getName());
|
||||||
|
role.setDescription(updatedRole.getDescription());
|
||||||
|
role.setPermissions(updatedRole.getPermissions());
|
||||||
|
return roleRepository.save(role);
|
||||||
|
}).orElseThrow(() -> new RuntimeException("Role not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role getById(Long id) {
|
||||||
|
return roleRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Role not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Role> getAll() {
|
||||||
|
return roleRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Long id) {
|
||||||
|
roleRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,79 +1,69 @@
|
|||||||
package com.pmu.betengine.service;
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.Agent;
|
||||||
import com.pmu.betengine.model.TPE;
|
import com.pmu.betengine.model.TPE;
|
||||||
import com.pmu.betengine.model.dto.TPEDTO;
|
|
||||||
import com.pmu.betengine.model.dto.TPERequestDTO;
|
|
||||||
import com.pmu.betengine.model.statut.StatutTPE;
|
import com.pmu.betengine.model.statut.StatutTPE;
|
||||||
|
import com.pmu.betengine.repository.AgentRepository;
|
||||||
import com.pmu.betengine.repository.TPERepository;
|
import com.pmu.betengine.repository.TPERepository;
|
||||||
import org.modelmapper.ModelMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class TPEService {
|
public class TPEService {
|
||||||
|
|
||||||
private final TPERepository tpeRepository;
|
private final TPERepository tpeRepository;
|
||||||
private final ModelMapper modelMapper;
|
private final AgentRepository agentRepository;
|
||||||
|
|
||||||
public TPEService(TPERepository tpeRepository, ModelMapper modelMapper) {
|
public TPEService(TPERepository tpeRepository, AgentRepository agentRepository) {
|
||||||
this.tpeRepository = tpeRepository;
|
this.tpeRepository = tpeRepository;
|
||||||
this.modelMapper = modelMapper;
|
this.agentRepository = agentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TPEDTO> getAllTPEs() {
|
public List<TPE> getAllTPEs() {
|
||||||
return tpeRepository.findAll()
|
return tpeRepository.findAll();
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO getTPEById(Long id) {
|
public TPE getTPEById(Long id) {
|
||||||
TPE tpe = tpeRepository.findById(id)
|
return tpeRepository.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
||||||
return convertToDTO(tpe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO createTPE(TPERequestDTO requestDTO) {
|
public TPE createTPE(TPE tpe) {
|
||||||
// Vérifier l'unicité de l'IMEI
|
if (tpeRepository.existsByImei(tpe.getImei())) {
|
||||||
if (tpeRepository.existsByImei(requestDTO.getImei())) {
|
throw new RuntimeException("Un TPE avec cet IMEI existe déjà: " + tpe.getImei());
|
||||||
throw new RuntimeException("Un TPE avec cet IMEI existe déjà: " + requestDTO.getImei());
|
|
||||||
}
|
}
|
||||||
|
if (tpeRepository.existsBySerial(tpe.getSerial())) {
|
||||||
// Vérifier l'unicité du numéro de série
|
throw new RuntimeException("Un TPE avec ce numéro de série existe déjà: " + tpe.getSerial());
|
||||||
if (tpeRepository.existsBySerial(requestDTO.getSerial())) {
|
|
||||||
throw new RuntimeException("Un TPE avec ce numéro de série existe déjà: " + requestDTO.getSerial());
|
|
||||||
}
|
}
|
||||||
|
return tpeRepository.save(tpe);
|
||||||
TPE tpe = convertToEntity(requestDTO);
|
|
||||||
TPE saved = tpeRepository.save(tpe);
|
|
||||||
return convertToDTO(saved);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO updateTPE(Long id, TPERequestDTO requestDTO) {
|
public TPE updateTPE(Long id, TPE tpeDetails) {
|
||||||
TPE existing = tpeRepository.findById(id)
|
TPE existing = tpeRepository.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
||||||
|
|
||||||
// Vérifier l'unicité de l'IMEI si modifié
|
if (!existing.getImei().equals(tpeDetails.getImei()) &&
|
||||||
if (!existing.getImei().equals(requestDTO.getImei()) &&
|
tpeRepository.existsByImei(tpeDetails.getImei())) {
|
||||||
tpeRepository.existsByImei(requestDTO.getImei())) {
|
throw new RuntimeException("Un TPE avec cet IMEI existe déjà: " + tpeDetails.getImei());
|
||||||
throw new RuntimeException("Un TPE avec cet IMEI existe déjà: " + requestDTO.getImei());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vérifier l'unicité du numéro de série si modifié
|
if (!existing.getSerial().equals(tpeDetails.getSerial()) &&
|
||||||
if (!existing.getSerial().equals(requestDTO.getSerial()) &&
|
tpeRepository.existsBySerial(tpeDetails.getSerial())) {
|
||||||
tpeRepository.existsBySerial(requestDTO.getSerial())) {
|
throw new RuntimeException("Un TPE avec ce numéro de série existe déjà: " + tpeDetails.getSerial());
|
||||||
throw new RuntimeException("Un TPE avec ce numéro de série existe déjà: " + requestDTO.getSerial());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise à jour des champs
|
// Update fields
|
||||||
modelMapper.map(requestDTO, existing);
|
existing.setImei(tpeDetails.getImei());
|
||||||
|
existing.setSerial(tpeDetails.getSerial());
|
||||||
|
existing.setType(tpeDetails.getType());
|
||||||
|
existing.setMarque(tpeDetails.getMarque());
|
||||||
|
existing.setModele(tpeDetails.getModele());
|
||||||
|
existing.setStatut(tpeDetails.getStatut());
|
||||||
|
|
||||||
return convertToDTO(tpeRepository.save(existing));
|
return tpeRepository.save(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTPE(Long id) {
|
public void deleteTPE(Long id) {
|
||||||
@@ -83,69 +73,44 @@ public class TPEService {
|
|||||||
tpeRepository.deleteById(id);
|
tpeRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO updateStatut(Long id, StatutTPE statut) {
|
public TPE updateStatut(Long id, StatutTPE statut) {
|
||||||
TPE tpe = tpeRepository.findById(id)
|
TPE tpe = getTPEById(id);
|
||||||
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
|
||||||
|
|
||||||
tpe.setStatut(statut);
|
tpe.setStatut(statut);
|
||||||
|
tpe.setAssigne(statut == StatutTPE.AFFECTE);
|
||||||
// Si le statut est AFFECTE, mettre à jour le champ assigne
|
if (statut == StatutTPE.DISPONIBLE) tpe.setAssigne(false);
|
||||||
if (statut == StatutTPE.AFFECTE) {
|
return tpeRepository.save(tpe);
|
||||||
tpe.setAssigne(true);
|
|
||||||
} else if (statut == StatutTPE.DISPONIBLE) {
|
|
||||||
tpe.setAssigne(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertToDTO(tpeRepository.save(tpe));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO assignerTPE(Long id) {
|
public TPE assignerTPE(Long tpeId, Long agentId) {
|
||||||
TPE tpe = tpeRepository.findById(id)
|
TPE tpe = getTPEById(tpeId);
|
||||||
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
Agent agent = agentRepository.findById(agentId)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Agent not found"));
|
||||||
if (tpe.isAssigne()) {
|
tpe.setAgent(agent);
|
||||||
throw new RuntimeException("Le TPE est déjà assigné");
|
|
||||||
}
|
|
||||||
|
|
||||||
tpe.setAssigne(true);
|
tpe.setAssigne(true);
|
||||||
tpe.setStatut(StatutTPE.AFFECTE);
|
return tpeRepository.save(tpe);
|
||||||
|
|
||||||
return convertToDTO(tpeRepository.save(tpe));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPEDTO libererTPE(Long id) {
|
public TPE libererTPE(Long id) {
|
||||||
TPE tpe = tpeRepository.findById(id)
|
TPE tpe = getTPEById(id);
|
||||||
.orElseThrow(() -> new RuntimeException("TPE non trouvé avec l'id: " + id));
|
|
||||||
|
|
||||||
if (!tpe.isAssigne()) {
|
if (!tpe.isAssigne()) {
|
||||||
throw new RuntimeException("Le TPE n'est pas assigné");
|
throw new RuntimeException("Le TPE n'est pas assigné");
|
||||||
}
|
}
|
||||||
|
|
||||||
tpe.setAssigne(false);
|
tpe.setAssigne(false);
|
||||||
tpe.setStatut(StatutTPE.DISPONIBLE);
|
tpe.setStatut(StatutTPE.DISPONIBLE);
|
||||||
|
tpe.setAgent(null);
|
||||||
return convertToDTO(tpeRepository.save(tpe));
|
return tpeRepository.save(tpe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TPEDTO> getTPEsByStatut(StatutTPE statut) {
|
public List<TPE> getTPEsByStatut(StatutTPE statut) {
|
||||||
return tpeRepository.findByStatut(statut)
|
return tpeRepository.findByStatut(statut);
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TPEDTO> getTPEsDisponibles() {
|
public List<TPE> getTPEsDisponibles() {
|
||||||
return tpeRepository.findAvailableTPE()
|
return tpeRepository.findAvailableTPE();
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TPEDTO> searchTPEs(String searchTerm) {
|
public List<TPE> searchTPEs(String searchTerm) {
|
||||||
return tpeRepository.searchByTerm(searchTerm)
|
return tpeRepository.searchByTerm(searchTerm);
|
||||||
.stream()
|
|
||||||
.map(this::convertToDTO)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long countTPEsByStatut(StatutTPE statut) {
|
public long countTPEsByStatut(StatutTPE statut) {
|
||||||
@@ -156,22 +121,4 @@ public class TPEService {
|
|||||||
return tpeRepository.countByAssigne(true);
|
return tpeRepository.countByAssigne(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TPEDTO convertToDTO(TPE tpe) {
|
|
||||||
TPEDTO dto = modelMapper.map(tpe, TPEDTO.class);
|
|
||||||
|
|
||||||
// Formatage des dates
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
|
||||||
if (tpe.getCreatedAt() != null) {
|
|
||||||
dto.setCreatedAt(tpe.getCreatedAt().format(formatter));
|
|
||||||
}
|
|
||||||
if (tpe.getUpdatedAt() != null) {
|
|
||||||
dto.setUpdatedAt(tpe.getUpdatedAt().format(formatter));
|
|
||||||
}
|
|
||||||
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TPE convertToEntity(TPERequestDTO dto) {
|
|
||||||
return modelMapper.map(dto, TPE.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
102
src/main/java/com/pmu/betengine/service/UserService.java
Normal file
102
src/main/java/com/pmu/betengine/service/UserService.java
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
package com.pmu.betengine.service;
|
||||||
|
|
||||||
|
import com.pmu.betengine.model.User;
|
||||||
|
import com.pmu.betengine.model.statut.StatutUser;
|
||||||
|
import com.pmu.betengine.repository.UserRepository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
|
public UserService(UserRepository userRepository) {
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CREATE
|
||||||
|
public User create(User user) {
|
||||||
|
// 1. Vérification des champs obligatoires
|
||||||
|
if (!StringUtils.hasText(user.getNom())) {throw new RuntimeException("Le nom est obligatoire");}
|
||||||
|
if (!StringUtils.hasText(user.getPrenom())) {throw new RuntimeException("Le prénom est obligatoire");}
|
||||||
|
if (!StringUtils.hasText(user.getIdentifiant())) {throw new RuntimeException("L'identifiant est obligatoire");}
|
||||||
|
if (!StringUtils.hasText(user.getPassword())) {throw new RuntimeException("Le mot de passe est obligatoire");}
|
||||||
|
if (user.getRoleId() == null) {throw new RuntimeException("L'ID du rôle est obligatoire");}
|
||||||
|
// 2. Vérification de l'unicité
|
||||||
|
if (userRepository.existsByIdentifiant(user.getIdentifiant())) {throw new RuntimeException("Cet identifiant existe déjà");}
|
||||||
|
if (user.getMatriculeAgent() != null &&
|
||||||
|
userRepository.existsByMatriculeAgent(user.getMatriculeAgent())) {throw new RuntimeException("Ce matricule agent existe déjà");}
|
||||||
|
// 3. Validation du mot de passe
|
||||||
|
if (!user.getPassword().matches("^(?=.*[0-9])(?=.*[a-zA-Z]).{8,}$")) {throw new RuntimeException("Le mot de passe doit contenir au moins 8 caractères, incluant lettres et chiffres");}
|
||||||
|
// 4. Définition des valeurs par défaut et encodage du mot de passe
|
||||||
|
user.setId(null);
|
||||||
|
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||||
|
user.setStatut(StatutUser.ACTIF.name());
|
||||||
|
user.setCreatedAt(LocalDateTime.now());
|
||||||
|
user.setUpdatedAt(LocalDateTime.now());
|
||||||
|
user.setDerniereConnexion(null);
|
||||||
|
// 5. Vérification des champs numériques
|
||||||
|
if (user.getNombreIpAutorise() == null || user.getNombreIpAutorise() < 0) {
|
||||||
|
user.setNombreIpAutorise(0);
|
||||||
|
}
|
||||||
|
if (user.getNombreIpAutoAutorise() == null || user.getNombreIpAutoAutorise() < 0) {
|
||||||
|
user.setNombreIpAutoAutorise(0);
|
||||||
|
}
|
||||||
|
// 6. Nettoyage des chaînes
|
||||||
|
user.setIdentifiant(user.getIdentifiant().trim().toLowerCase());
|
||||||
|
if (user.getMatriculeAgent() != null) {
|
||||||
|
user.setMatriculeAgent(user.getMatriculeAgent().trim().toUpperCase());
|
||||||
|
}
|
||||||
|
// 7. Enregistrement
|
||||||
|
return userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UPDATE
|
||||||
|
public User update(Long id, User updatedUser) {
|
||||||
|
return userRepository.findById(id).map(user -> {
|
||||||
|
|
||||||
|
user.setNom(updatedUser.getNom());
|
||||||
|
user.setPrenom(updatedUser.getPrenom());
|
||||||
|
user.setIdentifiant(updatedUser.getIdentifiant());
|
||||||
|
user.setMatriculeAgent(updatedUser.getMatriculeAgent());
|
||||||
|
user.setRoleId(updatedUser.getRoleId());
|
||||||
|
user.setRestrictionConnexion(updatedUser.getRestrictionConnexion());
|
||||||
|
user.setRestrictionAutomatique(updatedUser.getRestrictionAutomatique());
|
||||||
|
user.setNombreIpAutorise(updatedUser.getNombreIpAutorise());
|
||||||
|
user.setNombreIpAutoAutorise(updatedUser.getNombreIpAutoAutorise());
|
||||||
|
user.setStatut(updatedUser.getStatut());
|
||||||
|
user.setDerniereConnexion(updatedUser.getDerniereConnexion());
|
||||||
|
|
||||||
|
user.setUpdatedAt(LocalDateTime.now());
|
||||||
|
|
||||||
|
return userRepository.save(user);
|
||||||
|
|
||||||
|
}).orElseThrow(() -> new RuntimeException("Utilisateur introuvable"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// READ by ID
|
||||||
|
public User getById(Long id) {
|
||||||
|
return userRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Utilisateur introuvable"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// READ all
|
||||||
|
public List<User> getAll() {
|
||||||
|
return userRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE
|
||||||
|
public void delete(Long id) {
|
||||||
|
userRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user