Skip to content
Commits on Source (19)
......@@ -76,7 +76,7 @@ public class BootstrapData implements CommandLineRunner {
pilote4.setAge_inscription(29);
pilote4.setRace(RacePilote.MIRALUKAS);
pilote4.setType_pilote(TypePilote.COMBATTANT);
pilote4.setGrade(GradePilote.LIUTENANT);
pilote4.setGrade(GradePilote.LIEUTENANT);
pilote4.setEtat_pilote(EtatPilote.TUE);
Pilote pilote5 = new Pilote();
......@@ -119,13 +119,13 @@ public class BootstrapData implements CommandLineRunner {
mission1.setTitre_mission("Mission 1");
mission1.setType_mission(TypeMission.COMBAT);
mission1.setNbHeure(70);
mission1.setResultat(ResultatMission.ECHEC);
mission1.setResultat(ResultatMission.DEFAITE);
Mission mission2 = new Mission();
mission2.setTitre_mission("Mission 2");
mission2.setType_mission(TypeMission.ENTRAINEMENT);
mission2.setNbHeure(66);
mission2.setResultat(ResultatMission.SUCCESS);
mission2.setResultat(ResultatMission.VICTOIRE);
Mission mission3 = new Mission();
mission3.setTitre_mission("Mission 3");
......
......@@ -4,10 +4,12 @@
*/
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.domains.Pilote;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -24,7 +26,12 @@ public class FichePiloteController {
@GetMapping("/fichePilote")
public String fichePilote(Model model, @RequestParam(value = "id_pilote") String id_pilote) {
Pilote pilote = new Pilote();
pilote = piloteService.findById(Integer.valueOf(id_pilote));
model.addAttribute("pilote", pilote);
return "fichePilote";
}
}
......@@ -4,10 +4,32 @@
*/
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.services.ChasseurService;
import fr.ldnr.starWars.services.MissionService;
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 FinMissionController {
private final MissionService missionService;
public FinMissionController(MissionService missionService) {
this.missionService = missionService;
}
@GetMapping("/clotureMission")
public String clotureMission(Model model) {
model.addAttribute("resultatMission", missionService.resultatMission());
return "clotureMission";
}
}
......@@ -12,6 +12,7 @@ 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
......
/*
* 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 org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author Fabien
*/
@Controller
public class MenuController {
@GetMapping("/menu")
public String Menu() {
return "menu";
}
}
......@@ -69,7 +69,6 @@ public class Pilote {
this.age_inscription = age_inscription;
}
public Set<Affectation> getAffectation() {
return affectation;
}
......@@ -137,6 +136,4 @@ public class Pilote {
return "Pilote{" + "id_pilote=" + id_pilote + ", nom=" + nom + ", prenom=" + prenom + ", age_inscription=" + age_inscription + ", race=" + race + ", etat_pilote=" + etat_pilote + ", grade=" + grade + ", affectation=" + affectation + '}';
}
}
......@@ -5,13 +5,13 @@
package fr.ldnr.starWars.enumerations;
/**
* Apprenti : moins de 100 heures de vol
* Officier : moins de 500 heures de vol
* Apprenti : moins de 100 heures de vol Officier : moins de 500 heures de vol
* Lieutenant : moins de 1500 heures de vol et au moins une mission de combat
* Capitaine : moins de 4000 heures de vol et au moins 3 missions
* Commandant : 4000 heures de vol et au moins 10 missions
* Capitaine : moins de 4000 heures de vol et au moins 3 missions Commandant :
* 4000 heures de vol et au moins 10 missions
*
* @author stag
*/
public enum GradePilote {
OFFICIER, LIUTENANT, CAPITAINE, COMMANDANT
OFFICIER, LIEUTENANT, CAPITAINE, COMMANDANT
}
......@@ -9,5 +9,5 @@ package fr.ldnr.starWars.enumerations;
* @author stag
*/
public enum ResultatMission {
SUCCESS, ECHEC, NA
VICTOIRE, NA, DEFAITE
}
......@@ -58,22 +58,24 @@ public class ChasseurServiceImpl implements ChasseurService {
}
@Override
public Iterable<Chasseur> trouverParType(TypeChasseur type) {
public Iterable<Chasseur> trouverParId(Long id_chasseur) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.type = :type")
.setParameter("type", type)
list = em.createQuery("FROM Chasseur c WHERE c.id = :id")
.setParameter("id", id_chasseur)
.getResultList();
return list;
}
@Override
public Iterable<Chasseur> trouverParId(Long id_chasseur) {
public Iterable<Chasseur> trouverParType(TypeChasseur type) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.id = :id")
.setParameter("id", id_chasseur)
list = em.createQuery("FROM Chasseur c WHERE c.type = :type")
.setParameter("type", type)
.getResultList();
return list;
}
}
......@@ -5,6 +5,7 @@
package fr.ldnr.starWars.services;
import fr.ldnr.starWars.domains.Mission;
import fr.ldnr.starWars.enumerations.ResultatMission;
import fr.ldnr.starWars.enumerations.TypeMission;
/**
......@@ -16,5 +17,7 @@ public interface MissionService {
public Iterable<TypeMission> listMission();
public Iterable<ResultatMission> resultatMission();
}
......@@ -5,6 +5,7 @@
package fr.ldnr.starWars.services;
import fr.ldnr.starWars.domains.Mission;
import fr.ldnr.starWars.enumerations.ResultatMission;
import fr.ldnr.starWars.enumerations.TypeMission;
import fr.ldnr.starWars.repositories.MissionRepository;
import jakarta.persistence.EntityManager;
......@@ -38,6 +39,10 @@ public class MissionServiceImpl implements MissionService {
List<TypeMission> list = Arrays.asList(TypeMission.values());
return list;
}
@Override
public Iterable<ResultatMission>resultatMission(){
List<ResultatMission>resultat = Arrays.asList(ResultatMission.values());
return resultat;
}
}
......@@ -9,6 +9,7 @@ import fr.ldnr.starWars.enumerations.EtatPilote;
import fr.ldnr.starWars.enumerations.GradePilote;
import fr.ldnr.starWars.enumerations.RacePilote;
import fr.ldnr.starWars.enumerations.TypePilote;
import java.util.Optional;
/**
*
......@@ -30,4 +31,6 @@ public interface PiloteService {
public Pilote save(Pilote pilote);
public Pilote findById (Integer id_pilote);
}
......@@ -14,7 +14,9 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.Arrays;
import static java.util.Collections.list;
import java.util.List;
import static org.springframework.data.util.TypeUtils.type;
import org.springframework.stereotype.Service;
/**
......@@ -39,7 +41,7 @@ public class PiloteServiceImpl implements PiloteService {
@Override
public Pilote trouverParNom(String nom) {
return (Pilote) entityManager.createQuery("FROM Pilote p WHERE u.nom = :nom")
return (Pilote) entityManager.createQuery("SELECT p FROM Pilote p WHERE p.nom = :nom")
.setParameter("nom", nom)
.getSingleResult();
}
......@@ -47,7 +49,7 @@ public class PiloteServiceImpl implements PiloteService {
@Override
public Iterable<Pilote> trouverParEtat(EtatPilote etat) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.etat_pilote = :etat")
list = entityManager.createQuery("SELECT p FROM Pilote p WHERE p.etat_pilote = :etat")
.setParameter("etat", etat)
.getResultList();
return list;
......@@ -56,7 +58,7 @@ public class PiloteServiceImpl implements PiloteService {
@Override
public Iterable<Pilote> trouverParGrade(GradePilote grade) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.grade = :grade")
list = entityManager.createQuery("SELECT p FROM Pilote p WHERE p.grade = :grade")
.setParameter("grade", grade)
.getResultList();
return list;
......@@ -65,7 +67,7 @@ public class PiloteServiceImpl implements PiloteService {
@Override
public Iterable<Pilote> trouverParType(TypePilote type) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.grade = :type")
list = entityManager.createQuery("SELECT p FROM Pilote p WHERE p.grade = :type")
.setParameter("type", type)
.getResultList();
return list;
......@@ -79,7 +81,16 @@ public class PiloteServiceImpl implements PiloteService {
@Override
public Pilote save(Pilote pilote) {
pilote.setType_pilote(TypePilote.APPRENTI);
return piloteRepository.save(pilote);
}
@Override
public Pilote findById(Integer id_pilote) {
Pilote pilote = new Pilote();
pilote = (Pilote) entityManager.createQuery("SELECT p FROM Pilote p WHERE p.id_pilote = :id")
.setParameter("id", id_pilote).getSingleResult();
return pilote;
}
}
body{
display: flex;
flex-direction: column;
align-items: center;
background-color: black;
color: yellow;
}
th{
color: yellow;
}
a{
color: yellow;
}
......@@ -23,16 +23,22 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<div>
<label for="resultat">Resultat Mission : </label>
<select id="resultat" name="resultats">
<option th:each="resultats : ${resultatMission}" th:value="${resultat}" th:text="${resultat}"></option>
<option th:each="resultat : ${resultatMission}" th:value="${resultat}" th:text="${resultat}"></option>
</select>
</div>
<div>
<label>Détail</label>
<div>
<label for="pilote">Pilote</label>
<select id=""
<select id="pilote" name="pilote">
<option th:each="pilote : ${etatPilote}" th:value="${etatPilote}" th:text="${etatPilote}"></option>
</select>
<label for="chasseur">Chasseur</label>
<select id="chasseur" name="chasseur">
<option th:each="chasseur : ${etatChasseur}" th:value="${etatChasseur}" th:text="${etatChasseur}"></option>
</select>
</div>
</div>
</form>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
......
......@@ -4,6 +4,7 @@
<title>Fiche Chasseur</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>Fiche Chasseur</h1>
......@@ -19,5 +20,6 @@
<td th:text="${chasseur.etat_chasseur}"></td>
</tr>
</table>
<a th:href="@{/listeChasseur}">Retour à la liste des chasseurs</a>
</body>
</html>
......@@ -8,19 +8,25 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<title>Fiche 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>Fiche Pilote</h1>
<p th:text="${pilote.prenom}">Prénom</p>
<p th:text="${pilote.nom}">Nom</p>
<p th:text="${pilote.race}">Race</p>
<p th:text="${pilote.age_inscription}">Age_inscription</p>
<p th:text="${pilote.etat_pilote}">État</p>
</header>
<p>Prénom : <span th:text="${pilote.prenom}"></span></p>
<p>Nom : <span th:text="${pilote.nom}"></span></p>
<p>Race : <span th:text="${pilote.race}"></span></p>
<p>Age_inscription : <span th:text="${pilote.age_inscription}"></span></p>
<p>État : <span th:text="${pilote.etat_pilote}"></span></p>
<!--besoin db des missions afin pouvoir afficher Missions-->
<p>Nombre d'heures de vol</p>
<p th:text="${pilote.grade}">Grade</p>
<p>Nombre d'heures de vol : </p>
<p>Grade : <span th:text="${pilote.grade}"></span></p>
<!--besoin db des missions afin pouvoir afficher Missions-->
<p>Missions</p>
<p th:text="${pilote.type_pilote}">Type pilote</p>
<p>Liste des Missions</p>
<p>Type pilote : <span th:text="${pilote.type_pilote}"></span></p>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>
\ No newline at end of file