Skip to content
Commits on Source (6)
...@@ -48,8 +48,8 @@ public class BootstrapData implements CommandLineRunner { ...@@ -48,8 +48,8 @@ public class BootstrapData implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
Pilote pilote1 = new Pilote(); Pilote pilote1 = new Pilote();
pilote1.setNom("MAMA"); pilote1.setNom("GONÇALVES");
pilote1.setPrenom("Apprenti1"); pilote1.setPrenom("Yoda");
pilote1.setAge(100); pilote1.setAge(100);
pilote1.setRace(RacePilote.CHALACTEENS); pilote1.setRace(RacePilote.CHALACTEENS);
pilote1.setEtat(EtatPilote.DISPONIBLE); pilote1.setEtat(EtatPilote.DISPONIBLE);
...@@ -58,8 +58,8 @@ public class BootstrapData implements CommandLineRunner { ...@@ -58,8 +58,8 @@ public class BootstrapData implements CommandLineRunner {
pilote1.setEtat(EtatPilote.DISPONIBLE); pilote1.setEtat(EtatPilote.DISPONIBLE);
Pilote pilote2 = new Pilote(); Pilote pilote2 = new Pilote();
pilote2.setNom("WOW"); pilote2.setNom("SKYWALKER");
pilote2.setPrenom("Combattant1"); pilote2.setPrenom("Luke");
pilote2.setAge(17); pilote2.setAge(17);
pilote2.setRace(RacePilote.CHISS); pilote2.setRace(RacePilote.CHISS);
pilote2.setType(TypePilote.APPRENTI); pilote2.setType(TypePilote.APPRENTI);
...@@ -67,17 +67,17 @@ public class BootstrapData implements CommandLineRunner { ...@@ -67,17 +67,17 @@ public class BootstrapData implements CommandLineRunner {
pilote2.setEtat(EtatPilote.DISPONIBLE); pilote2.setEtat(EtatPilote.DISPONIBLE);
Pilote pilote3 = new Pilote(); Pilote pilote3 = new Pilote();
pilote3.setNom("WIW"); pilote3.setNom("DUREL");
pilote3.setPrenom("Combattant2"); pilote3.setPrenom("Obi-Wan");
pilote3.setAge(29); pilote3.setAge(777);
pilote3.setRace(RacePilote.ITHORIENS); pilote3.setRace(RacePilote.ITHORIENS);
pilote3.setType(TypePilote.COMBATTANT); pilote3.setType(TypePilote.COMBATTANT);
pilote3.setGrade(GradePilote.CAPITAINE); pilote3.setGrade(GradePilote.CAPITAINE);
pilote3.setEtat(EtatPilote.BLESSE); pilote3.setEtat(EtatPilote.BLESSE);
Pilote pilote4 = new Pilote(); Pilote pilote4 = new Pilote();
pilote4.setNom("WEW"); pilote4.setNom("FIAH");
pilote4.setPrenom("Combattant3"); pilote4.setPrenom("Princesse");
pilote4.setAge(29); pilote4.setAge(29);
pilote4.setRace(RacePilote.MIRALUKAS); pilote4.setRace(RacePilote.MIRALUKAS);
pilote4.setType(TypePilote.APPRENTI); pilote4.setType(TypePilote.APPRENTI);
...@@ -85,8 +85,8 @@ public class BootstrapData implements CommandLineRunner { ...@@ -85,8 +85,8 @@ public class BootstrapData implements CommandLineRunner {
pilote4.setEtat(EtatPilote.MORT_AU_COMBAT); pilote4.setEtat(EtatPilote.MORT_AU_COMBAT);
Pilote pilote5 = new Pilote(); Pilote pilote5 = new Pilote();
pilote5.setNom("WUW"); pilote5.setNom("BOUILLON-RENAUD");
pilote5.setPrenom("Combattant4"); pilote5.setPrenom("Han");
pilote5.setAge(77); pilote5.setAge(77);
pilote5.setRace(RacePilote.NAGAIS); pilote5.setRace(RacePilote.NAGAIS);
pilote5.setType(TypePilote.COMBATTANT); pilote5.setType(TypePilote.COMBATTANT);
...@@ -94,8 +94,8 @@ public class BootstrapData implements CommandLineRunner { ...@@ -94,8 +94,8 @@ public class BootstrapData implements CommandLineRunner {
pilote5.setEtat(EtatPilote.DISPONIBLE); pilote5.setEtat(EtatPilote.DISPONIBLE);
Pilote pilote6 = new Pilote(); Pilote pilote6 = new Pilote();
pilote6.setNom("DUREL"); pilote6.setNom("ROOROO");
pilote6.setPrenom("Johad"); pilote6.setPrenom("C-3PO");
pilote6.setAge(22); pilote6.setAge(22);
pilote6.setRace(RacePilote.HUMAINS); pilote6.setRace(RacePilote.HUMAINS);
pilote6.setType(TypePilote.COMBATTANT); pilote6.setType(TypePilote.COMBATTANT);
...@@ -103,10 +103,10 @@ public class BootstrapData implements CommandLineRunner { ...@@ -103,10 +103,10 @@ public class BootstrapData implements CommandLineRunner {
pilote6.setEtat(EtatPilote.BLESSE); pilote6.setEtat(EtatPilote.BLESSE);
Pilote pilote7 = new Pilote(); Pilote pilote7 = new Pilote();
pilote7.setNom("DUREL"); pilote7.setNom("NGUKNGUK");
pilote7.setPrenom("Johad2"); pilote7.setPrenom("Chewbacca");
pilote7.setAge(22); pilote7.setAge(17);
pilote7.setRace(RacePilote.HUMAINS); pilote7.setRace(RacePilote.QUERMIENS);
pilote7.setType(TypePilote.APPRENTI); pilote7.setType(TypePilote.APPRENTI);
pilote7.setGrade(GradePilote.OFFICIER); pilote7.setGrade(GradePilote.OFFICIER);
pilote7.setEtat(EtatPilote.DISPONIBLE); pilote7.setEtat(EtatPilote.DISPONIBLE);
......
/*
* 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.PiloteService;
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 stag
*/
@Controller
public class CherchePiloteController {
PiloteService piloteService;
public CherchePiloteController(PiloteService piloteService) {
this.piloteService = piloteService;
}
@GetMapping("/cherchePilote")
public String cherchePilote(Model model) {
return "cherchePilote";
}
@PostMapping("/cherchePilote")
public String cherchePilote(Model model,
@RequestParam(value = "nom") String nom) {
model.addAttribute("pilotes", piloteService.findByNom(nom));
return "cherchePilote";
}
}
...@@ -46,6 +46,11 @@ public class InscriptionPiloteController { ...@@ -46,6 +46,11 @@ public class InscriptionPiloteController {
RacePilote race2 = RacePilote.valueOf(race); RacePilote race2 = RacePilote.valueOf(race);
Integer age2 = Integer.valueOf(age); Integer age2 = Integer.valueOf(age);
if (age2 < 10 || age2 > 800) {
model.addAttribute("messageError", "Vous êtes trop jeune ou vieux. Nous n'acceptions que les rebelles entre 10 et 800 ans.");
return "inscriptionPilote";
}
if (!nom.isEmpty()) { if (!nom.isEmpty()) {
Pilote pilote = new Pilote(); Pilote pilote = new Pilote();
pilote.setNom(nom); pilote.setNom(nom);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
package fr.ldnr.starWars.controllers; package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.enumerations.StatutMission;
import fr.ldnr.starWars.services.MissionService; import fr.ldnr.starWars.services.MissionService;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
...@@ -23,7 +24,7 @@ public class ListeMissionController { ...@@ -23,7 +24,7 @@ public class ListeMissionController {
@GetMapping("/listeMission") @GetMapping("/listeMission")
public String listeMission(Model model) { public String listeMission(Model model) {
model.addAttribute("missions", missionService.findAll()); model.addAttribute("missions", missionService.findByStatut(StatutMission.TERMINE));
return "listeMission"; return "listeMission";
} }
......
...@@ -65,6 +65,8 @@ public class NouvelleMissionController { ...@@ -65,6 +65,8 @@ public class NouvelleMissionController {
model.addAttribute("chasseursDispo", listChasseurs); model.addAttribute("chasseursDispo", listChasseurs);
model.addAttribute("pilotesDispo", listPilotes); model.addAttribute("pilotesDispo", listPilotes);
model.addAttribute("chasseursDispo", listChasseurs); model.addAttribute("chasseursDispo", listChasseurs);
listPiloteTemp.clear();
listChasseurTemp.clear();
return "nouvelleMission"; return "nouvelleMission";
} }
...@@ -91,7 +93,7 @@ public class NouvelleMissionController { ...@@ -91,7 +93,7 @@ public class NouvelleMissionController {
return "nouvelleMission"; return "nouvelleMission";
} }
@PostMapping("/affectation") @PostMapping("/affectation/{idMission}")
// Handle Affectation form submission // Handle Affectation form submission
//@PostMapping("/affectation/{idMission}") //@PostMapping("/affectation/{idMission}")
// public String affectationSubmit(@PathVariable Long missionId, @ModelAttribute Affectation affectation, Model model) { // public String affectationSubmit(@PathVariable Long missionId, @ModelAttribute Affectation affectation, Model model) {
......
...@@ -20,7 +20,9 @@ import org.springframework.stereotype.Repository; ...@@ -20,7 +20,9 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface PiloteRepository extends CrudRepository<Pilote, Long> { public interface PiloteRepository extends CrudRepository<Pilote, Long> {
Pilote findByNom(String nom); List<Pilote> findByNom(String nom);
List<Pilote> findByNomAndPrenom(String nom, String prenom);
List<Pilote> findByEtat(EtatPilote etat); List<Pilote> findByEtat(EtatPilote etat);
......
...@@ -19,7 +19,9 @@ public interface PiloteService { ...@@ -19,7 +19,9 @@ public interface PiloteService {
public Iterable<Pilote> findAll(); public Iterable<Pilote> findAll();
public Pilote findByNom(String nom); public List<Pilote> findByNom(String nom);
public List<Pilote> findByNomAndPrenom(String nom, String prenom);
public List<Pilote> findByEtat(EtatPilote etat); public List<Pilote> findByEtat(EtatPilote etat);
......
...@@ -79,9 +79,13 @@ public class PiloteServiceImpl implements PiloteService { ...@@ -79,9 +79,13 @@ public class PiloteServiceImpl implements PiloteService {
} }
@Override @Override
public Pilote findByNom(String nom) { public List<Pilote> findByNom(String nom) {
return piloteRepository.findByNom(nom); return piloteRepository.findByNom(nom);
} }
@Override
public List<Pilote> findByNomAndPrenom(String nom, String prenom) {
return piloteRepository.findByNomAndPrenom(nom, prenom);
}
@Override @Override
public List<Pilote> findByGrade(GradePilote grade) { public List<Pilote> findByGrade(GradePilote grade) {
......
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Cherche pilote</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css"/>
</head>
<body>
<header>
<h1><span class='faulty-letter'>{</span> Cherche pilote par nom</h1>
</header>
<form th:action="@{/cherchePilote}" method="post">
<div>
<label for="nom">Saisir nom de pilote : </label>
<input type="text" id="nom" name="nom"/>
</div>
<div>
<input type="submit" value="Submit"/>
</div>
</form>
</br>
</br>
<table>
<tr>
<th>Id pilote</th>
<th>Nom</th>
<th>Prenom</th>
<th>Age</th>
<th>Race</th>
<th>Grade</th>
<th>Type</th>
<th>Etat</th>
</tr>
<tr th:each="pilote : ${pilotes}">
<td>
<a th:href="'/fichePilote?id_pilote=' + ${pilote.idPilote}" th:text="${pilote.idPilote}">
</a>
</td>
<td th:text="${pilote.nom}"></td>
<td th:text="${pilote.prenom}"></td>
<td th:text="${pilote.age}"></td>
<td th:text="${pilote.race}"></td>
<td th:text="${pilote.grade}"></td>
<td th:text="${pilote.type}"></td>
<td th:text="${pilote.etat}"></td>
</tr>
</table>
</br>
</br>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>
...@@ -32,6 +32,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -32,6 +32,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<option th:each="resultat : ${resultatMission}" th:value="${resultat}" th:text="${resultat}"></option> <option th:each="resultat : ${resultatMission}" th:value="${resultat}" th:text="${resultat}"></option>
</select> </select>
</div> </div>
<!--
<div> <div>
<p> List pilote(s) dans la mission: </p> <p> List pilote(s) dans la mission: </p>
<div th:each="pilote : ${pilotes}"> <div th:each="pilote : ${pilotes}">
...@@ -42,9 +43,15 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -42,9 +43,15 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<p th:text="${chasseur.type}"></p> <p th:text="${chasseur.type}"></p>
</div> </div>
</div> </div>
-->
</br>
<div>
<input type="submit" value="Submit"/> <input type="submit" value="Submit"/>
<input type="reset" value="Annuler"/> <input type="reset" value="Annuler"/>
</div>
</form> </form>
</br>
</br>
<footer> <footer>
<a href="/menu" class="menu">Retour au Menu</a> <a href="/menu" class="menu">Retour au Menu</a>
</footer> </footer>
......
...@@ -42,6 +42,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -42,6 +42,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<div class="box"> <div class="box">
<label class="label" for="age">Age</label> <label class="label" for="age">Age</label>
<input type="text" id="age" name="age"/> <input type="text" id="age" name="age"/>
<span th:text="${messageError}"></span>
</div> </div>
<div class="button"> <div class="button">
<input type="submit" value="Valider"/> <input type="submit" value="Valider"/>
......
...@@ -22,6 +22,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -22,6 +22,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<ul> <ul>
<li><a href="/inscriptionPilote" class="menu">Inscription d'un nouveau pilote</a></li> <li><a href="/inscriptionPilote" class="menu">Inscription d'un nouveau pilote</a></li>
<li><a href="/listePilote" class="menu">Liste des pilotes actifs</a></li> <li><a href="/listePilote" class="menu">Liste des pilotes actifs</a></li>
<li><a href="/cherchePilote" class="menu">Cherche pilote par nom</a></li>
</ul> </ul>
<h2>Chasseur</h2> <h2>Chasseur</h2>
...@@ -32,7 +33,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -32,7 +33,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<h2>Mission</h2> <h2>Mission</h2>
<ul> <ul>
<li><a href="/nouvelleMission" class="menu">Nouvelle mission</a></li> <li><a href="/nouvelleMission" class="menu">Nouvelle mission</a></li>
<li><a href="/listeMission" class="menu">Liste des missions</a></li> <li><a href="/listeMission" class="menu">Liste des missions terminées</a></li>
<li><a href="/clotureMission" class="menu">Cloturer une mission</a></li> <li><a href="/clotureMission" class="menu">Cloturer une mission</a></li>
</ul> </ul>
</main> </main>
......
...@@ -33,7 +33,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp ...@@ -33,7 +33,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
</div> </div>
</form> </form>
<form class='mission' th:object="${affectation}" th:action="@{/affectation}" method="post"> <form class='mission' th:object="${affectation}" th:action="@{/affectation/{idMission}}" method="post">
<h2>Affectation</h2> <h2>Affectation</h2>
<div class="box"> <div class="box">
<label for="piloteSelect">Choisir Pilote:</label> <label for="piloteSelect">Choisir Pilote:</label>
......