Skip to content
Commits on Source (28)
...@@ -2,6 +2,9 @@ package fr.ldnr.starWars; ...@@ -2,6 +2,9 @@ package fr.ldnr.starWars;
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.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication @SpringBootApplication
public class StarWarsApplication { public class StarWarsApplication {
...@@ -10,4 +13,14 @@ public class StarWarsApplication { ...@@ -10,4 +13,14 @@ public class StarWarsApplication {
SpringApplication.run(StarWarsApplication.class, args); SpringApplication.run(StarWarsApplication.class, args);
} }
@Configuration
public static class WebConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// Définir la page menu.html comme page d'accueil
registry.addViewController("/").setViewName("menu");
}
}
} }
...@@ -52,6 +52,7 @@ public class BootstrapData implements CommandLineRunner { ...@@ -52,6 +52,7 @@ public class BootstrapData implements CommandLineRunner {
pilote1.setPrenom("Apprenti1"); pilote1.setPrenom("Apprenti1");
pilote1.setAge(100); pilote1.setAge(100);
pilote1.setRace(RacePilote.CHALACTEENS); pilote1.setRace(RacePilote.CHALACTEENS);
pilote1.setEtat(EtatPilote.DISPONIBLE);
pilote1.setType(TypePilote.APPRENTI); pilote1.setType(TypePilote.APPRENTI);
pilote1.setGrade(GradePilote.OFFICIER); pilote1.setGrade(GradePilote.OFFICIER);
pilote1.setEtat(EtatPilote.DISPONIBLE); pilote1.setEtat(EtatPilote.DISPONIBLE);
...@@ -81,7 +82,7 @@ public class BootstrapData implements CommandLineRunner { ...@@ -81,7 +82,7 @@ public class BootstrapData implements CommandLineRunner {
pilote4.setRace(RacePilote.MIRALUKAS); pilote4.setRace(RacePilote.MIRALUKAS);
pilote4.setType(TypePilote.APPRENTI); pilote4.setType(TypePilote.APPRENTI);
pilote4.setGrade(GradePilote.OFFICIER); pilote4.setGrade(GradePilote.OFFICIER);
pilote4.setEtat(EtatPilote.TUE); pilote4.setEtat(EtatPilote.MORT_AU_COMBAT);
Pilote pilote5 = new Pilote(); Pilote pilote5 = new Pilote();
pilote5.setNom("WUW"); pilote5.setNom("WUW");
......
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package fr.ldnr.starWars.controllers;
/**
*
* @author stag
*/
public class AffectationPiloteChasseur {
}
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.services.ChasseurService;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author stag
*/
@Controller
public class AffectationPiloteChasseurController {
private final PiloteService piloteService;
private final ChasseurService chasseurService;
public AffectationPiloteChasseurController(
PiloteService piloteService,
ChasseurService chasseurService) {
this.piloteService = piloteService;
this.chasseurService = chasseurService;
}
@GetMapping("/affectation")
public String AffecterPiloteChasseur(Model model) {
model.addAttribute("listePilotes", piloteService.findAll());
model.addAttribute("listeChasseurs", chasseurService.findAll());
return "affectation";
}
}
...@@ -6,6 +6,7 @@ package fr.ldnr.starWars.controllers; ...@@ -6,6 +6,7 @@ package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.calculs.Calculs; import fr.ldnr.starWars.calculs.Calculs;
import fr.ldnr.starWars.domains.Affectation; import fr.ldnr.starWars.domains.Affectation;
import fr.ldnr.starWars.domains.Chasseur;
import fr.ldnr.starWars.domains.Mission; import fr.ldnr.starWars.domains.Mission;
import fr.ldnr.starWars.domains.Pilote; import fr.ldnr.starWars.domains.Pilote;
import fr.ldnr.starWars.enumerations.GradePilote; import fr.ldnr.starWars.enumerations.GradePilote;
...@@ -74,6 +75,20 @@ public class ClotureMission { ...@@ -74,6 +75,20 @@ public class ClotureMission {
} }
} }
model.addAttribute("pilotes", pilotes);
// boucle tous les chasseurs dans la Mission
Set<Chasseur> chasseurs = new HashSet<>(); // Create a set to store pilotes in the Mission
for (Affectation affectation : missionRecupere.getAffectation()) {
Chasseur chasseur = affectation.getChasseur();
if (chasseur != null) {
chasseurs.add(chasseur);
}
}
model.addAttribute("chasseurs", chasseurs);
for (Pilote pilote : pilotes) { for (Pilote pilote : pilotes) {
// ---------- DÉBUT CALCUL NB HEURE ET PUIS UPDATE GRADE OU TYPE // ---------- DÉBUT CALCUL NB HEURE ET PUIS UPDATE GRADE OU TYPE
//calculNbHeure //calculNbHeure
......
...@@ -64,16 +64,3 @@ public class InscriptionPiloteController { ...@@ -64,16 +64,3 @@ public class InscriptionPiloteController {
} }
} }
} }
// String prenom = request.getParameter("prenom");
// String nom = request.getParameter("nom");
// RacePilote race = RacePilote.class.cast(request.getParameter("races"));
// Integer age = Integer.parseInt(request.getParameter("age"));
//
// Pilote pilote = new Pilote();
// pilote.setNom(nom);
// pilote.setPrenom(prenom);
// pilote.setRace(race);
// pilote.setAge_inscription(age);
// System.out.println("Check pilote : " + pilote);
// return piloteService.save(pilote);
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.enumerations.EtatChasseur;
import fr.ldnr.starWars.services.ChasseurService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
* @author Johad
*/
@Controller
public class ModifierEtatChasseurController {
private final ChasseurService chasseurService;
public ModifierEtatChasseurController(ChasseurService chasseurService) {
this.chasseurService = chasseurService;
}
@GetMapping("/modifierEtatChasseur")
public String modifierEtatPilote(Model model) {
model.addAttribute("etatChasseur", chasseurService.listeTypeChasseur());
return "modifierEtatChasseur";
}
@PostMapping("/modifierEtatChasseur")
public String modifierEtatChasseur(@RequestParam Long id_chasseur, Model model,
@RequestParam(value="etat") String etat) {
model.addAttribute("etatChasseur", chasseurService.modifierEtat(id_chasseur, EtatChasseur.valueOf(etat)));
return "modifierEtatChasseur";
}
}
...@@ -12,7 +12,6 @@ import jakarta.persistence.GeneratedValue; ...@@ -12,7 +12,6 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
......
...@@ -9,5 +9,5 @@ package fr.ldnr.starWars.enumerations; ...@@ -9,5 +9,5 @@ package fr.ldnr.starWars.enumerations;
* @author stag * @author stag
*/ */
public enum EtatPilote { public enum EtatPilote {
DISPONIBLE, EN_MISSION, BLESSE, TUE; DISPONIBLE, EN_MISSION, BLESSE, MORT_AU_COMBAT;
} }
...@@ -14,4 +14,8 @@ public interface AffectationService { ...@@ -14,4 +14,8 @@ public interface AffectationService {
public Affectation save(Affectation affectation); public Affectation save(Affectation affectation);
} }
...@@ -27,6 +27,8 @@ public interface ChasseurService { ...@@ -27,6 +27,8 @@ public interface ChasseurService {
public Iterable<Chasseur> trouverParType(TypeChasseur type); public Iterable<Chasseur> trouverParType(TypeChasseur type);
public Iterable<Chasseur> modifierEtat(Long id_chasseur, EtatChasseur nouvelEtat);
public Iterable<TypeChasseur> listeTypeChasseur(); public Iterable<TypeChasseur> listeTypeChasseur();
public Chasseur findById(Integer idChasseur); public Chasseur findById(Integer idChasseur);
......
...@@ -42,7 +42,7 @@ public class ChasseurServiceImpl implements ChasseurService { ...@@ -42,7 +42,7 @@ public class ChasseurServiceImpl implements ChasseurService {
public Iterable<Chasseur> trouverParEtat(EtatChasseur etat) { public Iterable<Chasseur> trouverParEtat(EtatChasseur etat) {
List<Chasseur> list = new ArrayList<>(); List<Chasseur> list = new ArrayList<>();
list = em.createQuery("FROM Chasseur c WHERE u.chasseur.etat = :etat") list = em.createQuery("FROM Chasseur c WHERE c.chasseur.etat = :etat")
.setParameter("etat", etat) .setParameter("etat", etat)
.getResultList(); .getResultList();
return list; return list;
...@@ -75,6 +75,15 @@ public class ChasseurServiceImpl implements ChasseurService { ...@@ -75,6 +75,15 @@ public class ChasseurServiceImpl implements ChasseurService {
return list; return list;
} }
@Override
public Iterable<Chasseur> modifierEtat(Long id_chasseur, EtatChasseur nouvelEtat) {
Chasseur chasseurModif = em.find(Chasseur.class, id_chasseur);
chasseurModif.setEtat(nouvelEtat);
em.merge(chasseurModif);
return (Iterable<Chasseur>) chasseurModif;
}
@Override @Override
public List<Chasseur> findByEtat(EtatChasseur etat) { public List<Chasseur> findByEtat(EtatChasseur etat) {
return chasseurRepository.findByEtat(etat); return chasseurRepository.findByEtat(etat);
...@@ -86,6 +95,7 @@ public class ChasseurServiceImpl implements ChasseurService { ...@@ -86,6 +95,7 @@ public class ChasseurServiceImpl implements ChasseurService {
chasseur = (Chasseur) em.createQuery("SELECT c FROM Chasseur c WHERE c.idChasseur= :id") chasseur = (Chasseur) em.createQuery("SELECT c FROM Chasseur c WHERE c.idChasseur= :id")
.setParameter("id", idChasseur).getSingleResult(); .setParameter("id", idChasseur).getSingleResult();
return chasseur; return chasseur;
} }
} }
license: Freeware, Non-Commercial
link: https://www.fontspace.com/starkiller-font-f35874
\ No newline at end of file
The FontStruction “AnakinMono”
(http://fontstruct.com/fontstructions/show/773756) by “opipik” is licensed
under a Creative Commons Attribution Share Alike license
(http://creativecommons.org/licenses/by-sa/3.0/).