rajah 1 год назад
Родитель
Сommit
dfce47b4ea

BIN
.gradle/8.11.1/checksums/checksums.lock


BIN
.gradle/8.11.1/executionHistory/executionHistory.bin


BIN
.gradle/8.11.1/executionHistory/executionHistory.lock


BIN
.gradle/8.11.1/fileHashes/fileHashes.bin


BIN
.gradle/8.11.1/fileHashes/fileHashes.lock


BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock


BIN
.gradle/file-system.probe


+ 69 - 3
src/main/java/fr/triplea/demovote/persistence/dao/ParticipantRepository.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.NativeQuery;
 import org.springframework.data.repository.query.Param;
 
 import fr.triplea.demovote.persistence.dto.ParticipantOptionList;
+import fr.triplea.demovote.persistence.dto.ParticipantTransfer;
 import fr.triplea.demovote.persistence.model.Participant;
 import fr.triplea.demovote.persistence.model.Role;
 
@@ -15,7 +16,72 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
   
   @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.numero_participant = :id AND p.flag_actif IS TRUE ")
   Participant findById(@Param("id") int id);
+
+  @NativeQuery("SELECT DISTINCT "
+      + "TO_CHAR(p.date_creation, 'DD/MM/YYYY HH24:MI:SS') as date_creation, "
+      + "TO_CHAR(p.date_modification, 'DD/MM/YYYY HH24:MI:SS') as date_modification, "
+      + "p.numero_participant, "
+      + "p.nom, "
+      + "p.prenom, "
+      + "p.pseudonyme, "
+      + "'' AS mot_de_passe, "
+      + "p.groupe, "
+      + "p.delai_deconnexion, "
+      + "p.adresse, "
+      + "p.code_postal, "
+      + "p.ville, "
+      + "p.pays, "
+      + "p.numero_telephone, "
+      + "p.email, "
+      + "p.statut, "
+      + "p.flag_machine, "
+      + "p.commentaire, "
+      + "p.flag_jour1, "
+      + "p.flag_jour2, "
+      + "p.flag_jour3, "
+      + "p.flag_dodo_sur_place, "
+      + "p.flag_amigabus, "
+      + "p.mode_paiement, "
+      + "TO_CHAR(p.date_inscription, 'DD/MM/YYYY HH24:MI:SS') as date_inscription, "
+      + "CAST(p.somme_recue AS VARCHAR) AS somme_recue, "
+      + "p.flag_arrive "
+      + "FROM vote.participants AS p "
+      + "WHERE p.numero_participant = :id AND p.flag_actif IS TRUE ")
+  ParticipantTransfer searchById(@Param("id") int id);
   
+  @NativeQuery("SELECT DISTINCT "
+      + "TO_CHAR(p.date_creation, 'DD/MM/YYYY HH24:MI:SS') as date_creation, "
+      + "TO_CHAR(p.date_modification, 'DD/MM/YYYY HH24:MI:SS') as date_modification, "
+      + "p.numero_participant, "
+      + "p.nom, "
+      + "p.prenom, "
+      + "p.pseudonyme, "
+      + "'' AS mot_de_passe, "
+      + "p.groupe, "
+      + "p.delai_deconnexion, "
+      + "p.adresse, "
+      + "p.code_postal, "
+      + "p.ville, "
+      + "p.pays, "
+      + "p.numero_telephone, "
+      + "p.email, "
+      + "p.statut, "
+      + "p.flag_machine, "
+      + "p.commentaire, "
+      + "p.flag_jour1, "
+      + "p.flag_jour2, "
+      + "p.flag_jour3, "
+      + "p.flag_dodo_sur_place, "
+      + "p.flag_amigabus, "
+      + "p.mode_paiement, "
+      + "TO_CHAR(p.date_inscription, 'DD/MM/YYYY HH24:MI:SS') as date_inscription, "
+      + "CAST(p.somme_recue AS VARCHAR) AS somme_recue, "
+      + "p.flag_arrive "
+      + "FROM vote.participants AS p "
+      + "WHERE p.flag_actif IS TRUE "
+      + "ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
+  List<ParticipantTransfer> getList();
+
   @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.flag_actif IS TRUE ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
   List<Participant> findAll();
   
@@ -26,18 +92,18 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
   Participant findByPseudonyme(@Param("pseudo") String pseudonyme);
   
   @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.status = :status AND p.flag_actif IS TRUE ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
-  List<Participant> findByStatus(@Param("status") String status);
+  List<Participant> findByStatut(@Param("status") String status);
 
   @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.flag_arrive = :arrive AND p.flag_actif IS TRUE ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
   List<Participant> findByArrived(@Param("arrive") boolean flag_arrive);
 
-  @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.flag_dodo_sur_place = :dodo AND p.flag_actif IS TRUE ORDER BYp.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
+  @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.flag_dodo_sur_place = :dodo AND p.flag_actif IS TRUE ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
   List<Participant> findBySleepingOnSite(@Param("dodo") boolean flag_dodo_sur_place);
   
   @Override
   void delete(Participant participant);
 
-  @NativeQuery("SELECT DISTINCT p.numero_participant, p.nom, p.prenom, p.pseudonyme FROM vote.participants AS p WHERE p.flag_actif IS TRUE ORDER BY p.pseudonyme ASC, p.nom ASC, p.prenom ASC ")
+  @NativeQuery("SELECT DISTINCT p.numero_participant, p.pseudonyme, p.nom, p.prenom FROM vote.participants AS p WHERE p.flag_actif IS TRUE ORDER BY p.pseudonyme ASC, p.nom ASC, p.prenom ASC ")
   List<ParticipantOptionList> getOptionList();
 
 }

+ 2 - 3
src/main/java/fr/triplea/demovote/persistence/dao/VariableRepository.java

@@ -21,11 +21,10 @@ public interface VariableRepository extends JpaRepository<Variable, Integer>
   @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.type = :type ORDER BY v.type ASC, v.code ASC ")
   List<Variable> findByType(@Param("type") String type);
 
-  @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.type = :type AND v.code = :code ")
-  Variable findByTypeAndCode(@Param("type") String type, @Param("code") String code);
+  @NativeQuery("SELECT DISTINCT v.valeur FROM vote.variables AS v WHERE v.type = :type AND v.code = :code ")
+  String findByTypeAndCode(@Param("type") String type, @Param("code") String code);
 
   @NativeQuery("SELECT DISTINCT v.type FROM vote.variables AS v ORDER BY v.type ASC ")
   List<VariableTypeOptionList> getTypes();
-
   
 }

+ 28 - 0
src/main/java/fr/triplea/demovote/persistence/dto/MessagesTransfer.java

@@ -0,0 +1,28 @@
+package fr.triplea.demovote.persistence.dto;
+
+public class MessagesTransfer
+{
+
+  String erreur = null;
+
+  String alerte = null;
+
+  String information = null;
+  
+  String autre = null;
+  
+  public MessagesTransfer() {}
+
+  public String getErreur() { return erreur; }
+  public void setErreur(String erreur) { if (erreur != null) { if (!(erreur.isBlank())) { this.erreur = erreur; } } }
+
+  public String getAlerte() { return alerte; }
+  public void setAlerte(String alerte) { if (alerte != null) { if (!(alerte.isBlank())) { this.alerte = alerte; } } }
+
+  public String getInformation() { return information; }
+  public void setInformation(String information) { if (information != null) { if (!(information.isBlank())) { this.information = information; } } }
+
+  public String getAutre() { return autre; }
+  public void setAutre(String autre) { if (autre != null) { if (!(autre.isBlank())) { this.autre = autre; } } }
+
+}

+ 85 - 0
src/main/java/fr/triplea/demovote/persistence/dto/ParticipantTransfer.java

@@ -0,0 +1,85 @@
+package fr.triplea.demovote.persistence.dto;
+
+import java.math.BigDecimal;
+
+import fr.triplea.demovote.persistence.model.Participant;
+import fr.triplea.demovote.persistence.model.ParticipantModePaiement;
+import fr.triplea.demovote.persistence.model.ParticipantStatut;
+
+public record ParticipantTransfer
+(
+  String dateCreation,
+  String dateModification,
+  int numeroParticipant,
+  String nom,
+  String prenom,
+  String pseudonyme,
+  String motDePasse,
+  String groupe,
+  int delaiDeconnexion,
+  String adresse,
+  String codePostal,
+  String ville,
+  String pays,
+  String numeroTelephone,
+  String email,
+  String statut,
+  boolean withMachine,
+  String commentaire,
+  boolean hereDay1,
+  boolean hereDay2,
+  boolean hereDay3,
+  boolean sleepingOnSite,
+  boolean useAmigabus,
+  String modePaiement,
+  String dateInscription,
+  String sommeRecue,
+  boolean arrived
+) 
+{
+  public Participant toParticipant() 
+  {
+    Participant p = new Participant();
+    
+    p.setNom(nom);
+    p.setPrenom(prenom);
+    p.setPseudonyme(pseudonyme);
+    p.setGroupe(groupe); 
+    p.setMotDePasse(motDePasse);
+    p.setDelaiDeconnexion(delaiDeconnexion);
+    p.setAdresse(adresse);
+    p.setCodePostal(codePostal);
+    p.setVille(ville);
+    p.setPays(pays);
+    p.setNumeroTelephone(numeroTelephone);
+    p.setEmail(email);
+   
+    if (statut.equals("PAYE_CHEQUE")) { p.setStatut(ParticipantStatut.PAYE_CHEQUE); }
+    else if(statut.equals("PAYE_ESPECES")) { p.setStatut(ParticipantStatut.PAYE_ESPECES); }
+    else if(statut.equals("VIREMENT_BANCAIRE")) { p.setStatut(ParticipantStatut.VIREMENT_BANCAIRE); }
+    else if(statut.equals("VIREMENT_PAYPAL")) { p.setStatut(ParticipantStatut.VIREMENT_PAYPAL); }
+    else if(statut.equals("ORGA")) { p.setStatut(ParticipantStatut.ORGA); }
+    else if(statut.equals("GUEST")) { p.setStatut(ParticipantStatut.GUEST); }
+    else { p.setStatut(ParticipantStatut.EN_ATTENTE); }
+    
+    p.setWithMachine(withMachine);
+    p.setCommentaire(commentaire);
+    p.setHereDay1(hereDay1);
+    p.setHereDay2(hereDay2);
+    p.setHereDay3(hereDay3);
+    p.setSleepingOnSite(sleepingOnSite);
+    p.setUseAmigabus(useAmigabus);
+     
+    if (modePaiement.equals("CHEQUE")) { p.setModePaiement(ParticipantModePaiement.CHEQUE); }
+    else if(modePaiement.equals("VIREMENT")) { p.setModePaiement(ParticipantModePaiement.VIREMENT); }
+    else if(modePaiement.equals("PAYPAL")) { p.setModePaiement(ParticipantModePaiement.PAYPAL); }
+    else if(modePaiement.equals("ESPECES")) { p.setModePaiement(ParticipantModePaiement.ESPECES); }
+    else { p.setModePaiement(ParticipantModePaiement.AUTRE); }
+    
+    try { p.setSommeRecue(new BigDecimal(sommeRecue)); } catch (Exception e) {}
+    p.setArrived(arrived);
+    
+    return p;
+  }  
+
+}

+ 5 - 5
src/main/java/fr/triplea/demovote/persistence/model/Participant.java

@@ -105,7 +105,7 @@ public class Participant
   private String email;
 
   @Enumerated(EnumType.STRING) 
-  private ParticipantStatus status;
+  private ParticipantStatut statut;
 
   @Column(name = "flag_machine")
   private Boolean withMachine = true;
@@ -227,8 +227,8 @@ public class Participant
   public void setEmail(String str) { if (str != null) { this.email = StringUtils.truncate(str, 128); } }
   public String getEmail() { return this.email; }
   
-  public void setStatus(ParticipantStatus enu) { this.status = enu; }
-  public ParticipantStatus getStatus() { return this.status; }
+  public void setStatut(ParticipantStatut enu) { this.statut = enu; }
+  public ParticipantStatut getStatut() { return this.statut; }
   
   public void setWithMachine(boolean b) { this.withMachine = Boolean.valueOf(b); }
   public Boolean getWithMachine() { return this.withMachine; }
@@ -344,7 +344,7 @@ public class Participant
     result = (prime * result) + ((getPays() == null) ? 0 : getPays().hashCode());
     result = (prime * result) + ((getNumeroTelephone() == null) ? 0 : getNumeroTelephone().hashCode());
     result = (prime * result) + ((getEmail() == null) ? 0 : getEmail().hashCode());
-    result = (prime * result) + ((getStatus() == null) ? 0 : getStatus().hashCode());
+    result = (prime * result) + ((getStatut() == null) ? 0 : getStatut().hashCode());
     return result;
   }
 
@@ -387,7 +387,7 @@ public class Participant
            .append(sleepingOnSite ? ", dodo in situ" : "")
            .append(useAmigabus ? ", amigabus" : "")
            .append(", paiement=").append(modePaiement)
-           .append(", status=").append(status)
+           .append(", status=").append(statut)
            .append(", montant=").append(sommeRecue)
            .append(", créé=").append(dateCreation)
            .append(", modifié=").append(dateModification)

+ 0 - 19
src/main/java/fr/triplea/demovote/persistence/model/ParticipantStatus.java

@@ -1,19 +0,0 @@
-package fr.triplea.demovote.persistence.model;
-
-public enum ParticipantStatus 
-{
-  
-  EN_ATTENTE("En attente"), PAYE_CHEQUE("Payé chèque"), PAYE_ESPECES("Payé espèces"), VIREMENT_BANCAIRE("Virement bancaire"), VIREMENT_PAYPAL("Virement Paypal"), ORGA("Orga"), GUEST("Guest");
-
-  private String status;
-
-  private ParticipantStatus(String status) { this.status = status; }
-
-  public String getStatus() { return this.status; }
-
-  public static ParticipantStatus getByStatus(String str) { for (ParticipantStatus enu : ParticipantStatus.values()) { if (enu.getStatus().equals(str)) { return enu; } } return null; }
-  
-  @Override
-  public String toString() { return status; }
-
-}

+ 19 - 0
src/main/java/fr/triplea/demovote/persistence/model/ParticipantStatut.java

@@ -0,0 +1,19 @@
+package fr.triplea.demovote.persistence.model;
+
+public enum ParticipantStatut 
+{
+  
+  EN_ATTENTE("En attente"), PAYE_CHEQUE("Payé chèque"), PAYE_ESPECES("Payé espèces"), VIREMENT_BANCAIRE("Virement bancaire"), VIREMENT_PAYPAL("Virement Paypal"), ORGA("Orga"), GUEST("Guest");
+
+  private String statut;
+
+  private ParticipantStatut(String status) { this.statut = status; }
+
+  public String getStatus() { return this.statut; }
+
+  public static ParticipantStatut getByStatut(String str) { for (ParticipantStatut enu : ParticipantStatut.values()) { if (enu.getStatus().equals(str)) { return enu; } } return null; }
+  
+  @Override
+  public String toString() { return statut; }
+
+}

+ 21 - 17
src/main/java/fr/triplea/demovote/spring/CreateDefaultValues.java

@@ -46,8 +46,6 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
     
     Privilege listeVariablesPrivilege = addPrivilegeIfMissing("LISTE_VARIABLES");
 
-    Privilege pageAccueilPrivilege = addPrivilegeIfMissing("PAGE_ACCUEIL");
-
     Privilege donneesPersonnellesPrivilege = addPrivilegeIfMissing("PAGE_DONNEES_PERSONNELLES");
 
     Privilege listeParticipantsPrivilege = addPrivilegeIfMissing("LISTE_PARTICIPANTS");
@@ -66,13 +64,10 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
 
     Privilege pageMessageriePrivilege = addPrivilegeIfMissing("PAGE_MESSAGERIE");
 
-    Privilege pagePlanningPrivilege = addPrivilegeIfMissing("PAGE_PLANNING");
-
-    Privilege pageCamerasPrivilege = addPrivilegeIfMissing("PAGE_CAMERAS");    
-    
+   
     List<Privilege> adminPrivileges = Arrays.asList(listeVariablesPrivilege, modificationMotsDePasses, listeCategoriesPrivilege, listePresentationsPrivilege, listeProductionsPrivilegeAdmin);
     List<Privilege> orgaPrivileges = Arrays.asList(listeParticipantsPrivilege);
-    List<Privilege> userPrivileges = Arrays.asList(pageAccueilPrivilege, donneesPersonnellesPrivilege, pageMessageriePrivilege, pagePlanningPrivilege, pageCamerasPrivilege, listeProductionsPrivilegeUser, pageVoterPrivilege, pageResultatsPrivilege);
+    List<Privilege> userPrivileges = Arrays.asList(donneesPersonnellesPrivilege, pageMessageriePrivilege, listeProductionsPrivilegeUser, pageVoterPrivilege, pageResultatsPrivilege);
    
     Role adminRole = addRoleIfMissing("Administrateur", adminPrivileges);
     Role orgaRole = addRoleIfMissing("Organisateur", orgaPrivileges);
@@ -151,8 +146,10 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
     addVariableIfMissing("Résultats", "POINTS_POSITION_09", "0");
     addVariableIfMissing("Résultats", "POINTS_POSITION_10", "0");
     
-    addVariableIfMissing("Messages", "PAGE_ACCUEIL", "<span class=\"texte\">Bienvenue dans l''intranet alchimique : <ul><li>messagerie locale</li><li>uploads et vote pour la démoparty</li><li>planning</li><li>webcams</li><li>etc</li></ul></span>");
-    addVariableIfMissing("Messages", "PAGE_MENU", "<span style=\"color:red;display:none;visibility:hidden;\">La deadline est décrétée !</span>");
+    addVariableIfMissing("Messages", "ACCUEIL_ERREUR", "message d'erreur paramétrable côté backend.");
+    addVariableIfMissing("Messages", "ACCUEIL_ALERTE", "message d'alerte paramétrable côté backend.  ");
+    addVariableIfMissing("Messages", "ACCUEIL_INFORMATION", "message d'information paramétrable côté backend.  ");
+    addVariableIfMissing("Messages", "ACCUEIL_AUTRE", "message neutre paramétrable côté backend.  ");
 
     addVariableIfMissing("Caméras", "RECUPERATION_ACTIVE", "TRUE");
     addVariableIfMissing("Caméras", "RECUPERATION_IMAGE_1", "https://www.triplea.fr/alchimie/images/webcams/hirezcam.jpg");
@@ -172,7 +169,9 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
     if (privilege == null) 
     {
       privilege = new Privilege();
+      
       privilege.setLibelle(libelle);
+      
       privilege = privilegeRepository.save(privilege);
     }
     
@@ -184,22 +183,27 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
   {
     Role role = roleRepository.findByLibelle(libelle);
     
-    if (role == null) { role = new Role(); role.setLibelle(libelle); }
-    
-    role.setPrivileges(privileges);
-    role = roleRepository.save(role);
-    
+    if (role == null) 
+    { 
+      role = new Role(); 
+      
+      role.setLibelle(libelle); 
+      role.setPrivileges(privileges);
+
+      role = roleRepository.save(role);
+    }
+     
     return role;
   }
 
   @Transactional
   public void addVariableIfMissing(final String type, final String code, final String valeur) 
   {
-    Variable variable = variableRepository.findByTypeAndCode(type, code);
+    String str = variableRepository.findByTypeAndCode(type, code);
     
-    if (variable == null) 
+    if (str == null) 
     { 
-      variable = new Variable(); 
+      Variable variable = new Variable(); 
 
       variable.setType(type);
       variable.setCode(code);

+ 39 - 0
src/main/java/fr/triplea/demovote/web/controller/DiversController.java

@@ -0,0 +1,39 @@
+package fr.triplea.demovote.web.controller;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+//import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import fr.triplea.demovote.persistence.dao.VariableRepository;
+import fr.triplea.demovote.persistence.dto.MessagesTransfer;
+
+@CrossOrigin(origins = "http://localhost:4200")
+@RestController
+@RequestMapping("/demovote-api/v1/divers")
+public class DiversController 
+{
+
+  @Autowired
+  private VariableRepository variableRepository;
+ 
+  @GetMapping(value = "/welcome")
+  //@PreAuthorize("hasRole('LISTE_VARIABLES')")
+  public ResponseEntity<MessagesTransfer> getWelcomeMessage() 
+  { 
+    MessagesTransfer mt = new MessagesTransfer();
+
+    mt.setErreur(variableRepository.findByTypeAndCode("Messages", "ACCUEIL_ERREUR"));
+    mt.setAlerte(variableRepository.findByTypeAndCode("Messages", "ACCUEIL_ALERTE"));
+    mt.setInformation(variableRepository.findByTypeAndCode("Messages", "ACCUEIL_INFORMATION"));
+    mt.setAutre(variableRepository.findByTypeAndCode("Messages", "ACCUEIL_AUTRE"));
+    
+    return ResponseEntity.ok(mt); 
+  }
+
+
+}

+ 106 - 43
src/main/java/fr/triplea/demovote/web/controller/ParticipantController.java

@@ -1,9 +1,11 @@
 package fr.triplea.demovote.web.controller;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -20,9 +22,11 @@ import org.springframework.web.bind.annotation.RestController;
 
 import fr.triplea.demovote.persistence.dao.ParticipantRepository;
 import fr.triplea.demovote.persistence.dto.ParticipantOptionList;
+import fr.triplea.demovote.persistence.dto.ParticipantTransfer;
 import fr.triplea.demovote.persistence.model.Participant;
 import fr.triplea.demovote.persistence.model.ParticipantModePaiement;
-import fr.triplea.demovote.persistence.model.ParticipantStatus;
+import fr.triplea.demovote.persistence.model.ParticipantStatut;
+
 
 @CrossOrigin(origins = "http://localhost:4200")
 @RestController
@@ -37,9 +41,9 @@ public class ParticipantController
 
   @GetMapping(value = "/list")
   //@PreAuthorize("hasRole('LISTE_PARTICIPANTS')")
-  public List<Participant> getList() 
+  public List<ParticipantTransfer> getList() 
   { 
-    return participantRepository.findAll(); 
+    return participantRepository.getList(); 
   }
 
   
@@ -52,9 +56,9 @@ public class ParticipantController
 
   @GetMapping(value = "/form/{id}")
   //@PreAuthorize("hasRole('LISTE_PARTICIPANTS')")
-  public ResponseEntity<Participant> getForm(@PathVariable int id) 
+  public ResponseEntity<ParticipantTransfer> getForm(@PathVariable int id) 
   { 
-    Participant p = participantRepository.findById(id);
+    ParticipantTransfer p = participantRepository.searchById(id);
 
     if (p != null) { return ResponseEntity.ok(p); }
     
@@ -63,59 +67,117 @@ public class ParticipantController
 
   @PostMapping(value = "/create")
   //@PreAuthorize("hasRole('LISTE_PARTICIPANTS')")
-  public Participant create(@RequestBody(required = true) Participant participant) 
+  public ResponseEntity<Object> create(@RequestBody(required = true) ParticipantTransfer participant) 
   { 
     Participant found = participantRepository.findById(0);
     
-    if (found == null) { participant.setNumeroParticipant(null); }
-
-    if (participant.getStatus() == null) { participant.setStatus(ParticipantStatus.EN_ATTENTE); }
-    if (participant.getModePaiement() == null) { participant.setModePaiement(ParticipantModePaiement.ESPECES); }
-    
-    participant.setDateInscription(LocalDateTime.now());
-    
-    if (participant.hasNom() && participant.hasPseudonyme()) { return participantRepository.save(participant); }
-    
+    if (found == null) 
+    {
+      if (!(participant.nom().isBlank()))
+      {
+        if (!(participant.pseudonyme().isBlank()))
+        {
+          found = new Participant();
+          
+          found.setRoles(found.getRoles());
+          found.setEnabled(true);
+
+          found.setNom(participant.nom());
+          found.setPrenom(participant.prenom());
+          found.setPseudonyme(participant.pseudonyme());
+          found.setMotDePasse(participant.motDePasse());
+          found.setGroupe(participant.groupe()); 
+          found.setDelaiDeconnexion(participant.delaiDeconnexion());
+          found.setAdresse(participant.adresse());
+          found.setCodePostal(participant.codePostal());
+          found.setVille(participant.ville());
+          found.setPays(participant.pays());
+          found.setNumeroTelephone(participant.numeroTelephone());
+          found.setEmail(participant.email());
+         
+          if (participant.statut().equals("PAYE_CHEQUE")) { found.setStatut(ParticipantStatut.PAYE_CHEQUE); }
+          else if(participant.statut().equals("PAYE_ESPECES")) { found.setStatut(ParticipantStatut.PAYE_ESPECES); }
+          else if(participant.statut().equals("VIREMENT_BANCAIRE")) { found.setStatut(ParticipantStatut.VIREMENT_BANCAIRE); }
+          else if(participant.statut().equals("VIREMENT_PAYPAL")) { found.setStatut(ParticipantStatut.VIREMENT_PAYPAL); }
+          else if(participant.statut().equals("ORGA")) { found.setStatut(ParticipantStatut.ORGA); }
+          else if(participant.statut().equals("GUEST")) { found.setStatut(ParticipantStatut.GUEST); }
+          else { found.setStatut(ParticipantStatut.EN_ATTENTE); }
+          
+          found.setWithMachine(participant.withMachine());
+          found.setCommentaire(participant.commentaire());
+          found.setHereDay1(participant.hereDay1());
+          found.setHereDay2(participant.hereDay2());
+          found.setHereDay3(participant.hereDay3());
+          found.setSleepingOnSite(participant.sleepingOnSite());
+          found.setUseAmigabus(participant.useAmigabus());
+           
+          if (participant.modePaiement().equals("CHEQUE")) { found.setModePaiement(ParticipantModePaiement.CHEQUE); }
+          else if(participant.modePaiement().equals("VIREMENT")) { found.setModePaiement(ParticipantModePaiement.VIREMENT); }
+          else if(participant.modePaiement().equals("PAYPAL")) { found.setModePaiement(ParticipantModePaiement.PAYPAL); }
+          else if(participant.modePaiement().equals("ESPECES")) { found.setModePaiement(ParticipantModePaiement.ESPECES); }
+          else { found.setModePaiement(ParticipantModePaiement.AUTRE); }
+          
+          try { found.setSommeRecue(new BigDecimal(participant.sommeRecue())); } catch (Exception e) { found.setSommeRecue(new BigDecimal("0.00")); }
+          found.setDateInscription(LocalDateTime.now());
+          found.setArrived(participant.arrived());
+          
+          Participant created = participantRepository.save(found);
+        
+          return ResponseEntity.ok(created);
+        }
+      }
+    }
+       
     return null;
   }
 
   @PutMapping(value = "/update/{id}")
   //@PreAuthorize("hasRole('LISTE_PARTICIPANTS')")
-  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) Participant participant) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) ParticipantTransfer participant) 
   { 
     Participant found = participantRepository.findById(id);
     
     if (found != null)
     {
-      found.setRoles(participant.getRoles());
+      found.setRoles(found.getRoles());
       found.setEnabled(true);
 
-      found.setNom(participant.getNom());
-      found.setPrenom(participant.getPrenom());
-      found.setPseudonyme(participant.getPseudonyme());
-      found.setGroupe(participant.getGroupe()); 
-      found.setMotDePasse(participant.getMotDePasse());
-      found.setPasswordExpired(participant.getPasswordExpired());
-      found.setDateExpiration(participant.getDateExpiration());
-      found.setDelaiDeconnexion(participant.getDelaiDeconnexion());
-      found.setAdresse(participant.getAdresse());
-      found.setCodePostal(participant.getCodePostal());
-      found.setVille(participant.getVille());
-      found.setPays(participant.getPays());
-      found.setNumeroTelephone(participant.getNumeroTelephone());
-      found.setEmail(participant.getEmail());
-      found.setStatus(participant.getStatus());
-      found.setWithMachine(participant.getWithMachine().booleanValue());
-      found.setCommentaire(participant.getCommentaire());
-      found.setHereDay1(participant.getHereDay1().booleanValue());
-      found.setHereDay2(participant.getHereDay2().booleanValue());
-      found.setHereDay3(participant.getHereDay3().booleanValue());
-      found.setSleepingOnSite(participant.getSleepingOnSite().booleanValue());
-      found.setUseAmigabus(participant.getUseAmigabus().booleanValue());
-      found.setModePaiement(participant.getModePaiement());
-      found.setDateInscription(participant.getDateInscription());
-      found.setSommeRecue(participant.getSommeRecue());
-      found.setArrived(participant.getArrived().booleanValue());
+      found.setNom(participant.nom());
+      found.setPrenom(participant.prenom());
+      found.setPseudonyme(participant.pseudonyme());
+      found.setGroupe(participant.groupe()); 
+      found.setDelaiDeconnexion(participant.delaiDeconnexion());
+      found.setAdresse(participant.adresse());
+      found.setCodePostal(participant.codePostal());
+      found.setVille(participant.ville());
+      found.setPays(participant.pays());
+      found.setNumeroTelephone(participant.numeroTelephone());
+      found.setEmail(participant.email());
+     
+      if (participant.statut().equals("PAYE_CHEQUE")) { found.setStatut(ParticipantStatut.PAYE_CHEQUE); }
+      else if(participant.statut().equals("PAYE_ESPECES")) { found.setStatut(ParticipantStatut.PAYE_ESPECES); }
+      else if(participant.statut().equals("VIREMENT_BANCAIRE")) { found.setStatut(ParticipantStatut.VIREMENT_BANCAIRE); }
+      else if(participant.statut().equals("VIREMENT_PAYPAL")) { found.setStatut(ParticipantStatut.VIREMENT_PAYPAL); }
+      else if(participant.statut().equals("ORGA")) { found.setStatut(ParticipantStatut.ORGA); }
+      else if(participant.statut().equals("GUEST")) { found.setStatut(ParticipantStatut.GUEST); }
+      else { found.setStatut(ParticipantStatut.EN_ATTENTE); }
+      
+      found.setWithMachine(participant.withMachine());
+      found.setCommentaire(participant.commentaire());
+      found.setHereDay1(participant.hereDay1());
+      found.setHereDay2(participant.hereDay2());
+      found.setHereDay3(participant.hereDay3());
+      found.setSleepingOnSite(participant.sleepingOnSite());
+      found.setUseAmigabus(participant.useAmigabus());
+       
+      if (participant.modePaiement().equals("CHEQUE")) { found.setModePaiement(ParticipantModePaiement.CHEQUE); }
+      else if(participant.modePaiement().equals("VIREMENT")) { found.setModePaiement(ParticipantModePaiement.VIREMENT); }
+      else if(participant.modePaiement().equals("PAYPAL")) { found.setModePaiement(ParticipantModePaiement.PAYPAL); }
+      else if(participant.modePaiement().equals("ESPECES")) { found.setModePaiement(ParticipantModePaiement.ESPECES); }
+      else { found.setModePaiement(ParticipantModePaiement.AUTRE); }
+      
+      try { found.setSommeRecue(new BigDecimal(participant.sommeRecue())); } catch (Exception e) { found.setSommeRecue(new BigDecimal("0.00")); }
+      found.setArrived(participant.arrived());
       
       Participant updated = participantRepository.save(found);
     
@@ -134,6 +196,7 @@ public class ParticipantController
     if (found != null)
     {
       found.setEnabled(false); 
+      found.setPseudonyme(found.getPseudonyme() + "_" + UUID.randomUUID().toString());
       
       participantRepository.saveAndFlush(found);
 

+ 10 - 10
src/main/java/fr/triplea/demovote/web/controller/ProductionController.java

@@ -120,11 +120,11 @@ public class ProductionController
       fresh.setNumeroProduction(null);
       fresh.setAdresseIP(new Inet(request.getRemoteAddr()));
       
-      if(production.type().equals("EXECUTABLE")) { fresh.setType(ProductionType.EXECUTABLE); }
-      else if(production.type().equals("GRAPHE")) { fresh.setType(ProductionType.GRAPHE); }
-      else if(production.type().equals("MUSIQUE")) { fresh.setType(ProductionType.MUSIQUE); }
-      else if(production.type().equals("VIDEO")) { fresh.setType(ProductionType.VIDEO); }
-      else if(production.type().equals("TOPIC")) { fresh.setType(ProductionType.TOPIC); }
+      if (production.type().equals("EXECUTABLE")) { fresh.setType(ProductionType.EXECUTABLE); }
+      else if (production.type().equals("GRAPHE")) { fresh.setType(ProductionType.GRAPHE); }
+      else if (production.type().equals("MUSIQUE")) { fresh.setType(ProductionType.MUSIQUE); }
+      else if (production.type().equals("VIDEO")) { fresh.setType(ProductionType.VIDEO); }
+      else if (production.type().equals("TOPIC")) { fresh.setType(ProductionType.TOPIC); }
       else { fresh.setType(ProductionType.AUTRE); }
         
       fresh.setTitre(production.titre());
@@ -168,11 +168,11 @@ public class ProductionController
         
         found.setAdresseIP(new Inet(request.getRemoteAddr()));
         
-        if(production.type().equals("EXECUTABLE")) { found.setType(ProductionType.EXECUTABLE); }
-        else if(production.type().equals("GRAPHE")) { found.setType(ProductionType.GRAPHE); }
-        else if(production.type().equals("MUSIQUE")) { found.setType(ProductionType.MUSIQUE); }
-        else if(production.type().equals("VIDEO")) { found.setType(ProductionType.VIDEO); }
-        else if(production.type().equals("TOPIC")) { found.setType(ProductionType.TOPIC); }
+        if (production.type().equals("EXECUTABLE")) { found.setType(ProductionType.EXECUTABLE); }
+        else if (production.type().equals("GRAPHE")) { found.setType(ProductionType.GRAPHE); }
+        else if (production.type().equals("MUSIQUE")) { found.setType(ProductionType.MUSIQUE); }
+        else if (production.type().equals("VIDEO")) { found.setType(ProductionType.VIDEO); }
+        else if (production.type().equals("TOPIC")) { found.setType(ProductionType.TOPIC); }
         else { found.setType(ProductionType.AUTRE); }
        
         found.setTitre(production.titre());