Kaynağa Gözat

dev en cours

rajah 7 ay önce
ebeveyn
işleme
dc794eecbd

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

@@ -8,7 +8,7 @@ import org.springframework.data.repository.query.Param;
 
 import fr.triplea.demovote.dto.ParticipantList;
 import fr.triplea.demovote.dto.ParticipantOptionList;
-import fr.triplea.demovote.dto.ParticipantTransfer;
+import fr.triplea.demovote.dto.ParticipantRecord;
 import fr.triplea.demovote.model.Participant;
 import fr.triplea.demovote.model.Role;
 
@@ -22,6 +22,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "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, "
+      + "'' AS role, "
       + "p.nom, "
       + "p.prenom, "
       + "p.pseudonyme, "
@@ -48,7 +49,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "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);
+  ParticipantRecord searchById(@Param("id") int id);
 
   @NativeQuery("SELECT DISTINCT "
       + "p.numero_participant, "
@@ -102,6 +103,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "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, "
+      + "'' AS role, "
       + "p.nom, "
       + "p.prenom, "
       + "p.pseudonyme, "
@@ -128,7 +130,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "p.flag_arrive "
       + "FROM vote.participants AS p "
       + "WHERE p.pseudonyme = :pseudo AND p.flag_actif IS TRUE ")
-  ParticipantTransfer searchByPseudonyme(@Param("pseudo") String pseudonyme);
+  ParticipantRecord searchByPseudonyme(@Param("pseudo") String pseudonyme);
 
   @NativeQuery("SELECT DISTINCT p.* FROM vote.participants AS p WHERE p.flag_actif IS TRUE AND p.pseudonyme = :pseudo ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
   Participant findByPseudonyme(@Param("pseudo") String pseudonyme);

+ 36 - 0
src/main/java/fr/triplea/demovote/dto/ParticipantRecord.java

@@ -0,0 +1,36 @@
+package fr.triplea.demovote.dto;
+
+public record ParticipantRecord
+(
+  String dateCreation,
+  String dateModification,
+  int numeroParticipant,
+  String role,
+  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
+) 
+{
+ 
+}

+ 114 - 80
src/main/java/fr/triplea/demovote/dto/ParticipantTransfer.java

@@ -1,85 +1,119 @@
 package fr.triplea.demovote.dto;
 
-import java.math.BigDecimal;
-
-import fr.triplea.demovote.model.Participant;
-import fr.triplea.demovote.model.ParticipantModePaiement;
-import fr.triplea.demovote.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 class ParticipantTransfer
 {
-  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;
-  }  
+  String dateCreation;
+  String dateModification;
+  int numeroParticipant;
+  String role;
+  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 String getDateCreation() { return dateCreation; }
+  public void setDateCreation(String dateCreation) { this.dateCreation = dateCreation; }
+  
+  public String getDateModification() { return dateModification; }
+  public void setDateModification(String dateModification) { this.dateModification = dateModification; }
+  
+  public int getNumeroParticipant() { return numeroParticipant; }
+  public void setNumeroParticipant(int numeroParticipant) { this.numeroParticipant = numeroParticipant; }
+  
+  public String getRole() { return role; }
+  public void setRole(String role) { this.role = role; }
+  public boolean hasRole() { if (this.role != null) { if (!(this.role.isBlank())) { return true; }} return false; }
 
+  public String getNom() { return nom; }
+  public void setNom(String nom) { this.nom = nom; }
+  
+  public String getPrenom() { return prenom; }
+  public void setPrenom(String prenom) { this.prenom = prenom; }
+  
+  public String getPseudonyme() { return pseudonyme; }
+  public void setPseudonyme(String pseudonyme) { this.pseudonyme = pseudonyme; }
+  
+  public String getMotDePasse() { return motDePasse; }
+  public void setMotDePasse(String motDePasse) { this.motDePasse = motDePasse; }
+  
+  public String getGroupe() { return groupe; }
+  public void setGroupe(String groupe) { this.groupe = groupe; }
+  
+  public int getDelaiDeconnexion() { return delaiDeconnexion; }
+  public void setDelaiDeconnexion(int delaiDeconnexion) { this.delaiDeconnexion = delaiDeconnexion; }
+  
+  public String getAdresse() { return adresse; }
+  public void setAdresse(String adresse) { this.adresse = adresse; }
+  
+  public String getCodePostal() { return codePostal; }
+  public void setCodePostal(String codePostal) { this.codePostal = codePostal; }
+  
+  public String getVille() { return ville; }
+  public void setVille(String ville) { this.ville = ville; }
+  
+  public String getPays() { return pays; }
+  public void setPays(String pays) { this.pays = pays; }
+  
+  public String getNumeroTelephone() { return numeroTelephone; }
+  public void setNumeroTelephone(String numeroTelephone) { this.numeroTelephone = numeroTelephone; }
+  
+  public String getEmail() { return email; }
+  public void setEmail(String email) { this.email = email; }
+  
+  public String getStatut() { return statut; }
+  public void setStatut(String statut) { this.statut = statut; }
+  
+  public boolean isWithMachine() { return withMachine; }
+  public void setWithMachine(boolean withMachine) { this.withMachine = withMachine; }
+  
+  public String getCommentaire() { return commentaire; }
+  public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
+  
+  public boolean isHereDay1() { return hereDay1; }
+  public void setHereDay1(boolean hereDay1) { this.hereDay1 = hereDay1; }
+  
+  public boolean isHereDay2() { return hereDay2; }
+  public void setHereDay2(boolean hereDay2) { this.hereDay2 = hereDay2; }
+  
+  public boolean isHereDay3() { return hereDay3; }
+  public void setHereDay3(boolean hereDay3) { this.hereDay3 = hereDay3; }
+  
+  public boolean isSleepingOnSite() { return sleepingOnSite; }
+  public void setSleepingOnSite(boolean sleepingOnSite) { this.sleepingOnSite = sleepingOnSite; }
+  
+  public boolean isUseAmigabus() { return useAmigabus; }
+  public void setUseAmigabus(boolean useAmigabus) { this.useAmigabus = useAmigabus; }
+  
+  public String getModePaiement() { return modePaiement; }
+  public void setModePaiement(String modePaiement) { this.modePaiement = modePaiement; }
+  
+  public String getDateInscription() { return dateInscription; }
+  public void setDateInscription(String dateInscription) { this.dateInscription = dateInscription; }
+  
+  public String getSommeRecue() { return sommeRecue; }
+  public void setSommeRecue(String sommeRecue) { this.sommeRecue = sommeRecue; }
+  
+  public boolean isArrived() { return arrived; }
+  public void setArrived(boolean arrived) { this.arrived = arrived; }
+ 
 }

+ 4 - 0
src/main/java/fr/triplea/demovote/dto/UserCredentials.java

@@ -25,6 +25,10 @@ public class UserCredentials
   public String getRole() { return this.role; }
   public boolean hasRole() { if (this.role != null) { if (!(this.role.isBlank())) { return true; }} return false; }
   
+  private int delaiAvantDeconnexion;
+  public void setDelaiAvantDeconnexion(int i) { this.delaiAvantDeconnexion = i; }
+  public int getDelaiAvantDeconnexion() { return this.delaiAvantDeconnexion; }
+  
   private String accessToken;
   public void setAccessToken(String s) { this.accessToken = new String(s); }
   public String getAccessToken() { return this.accessToken; }

+ 3 - 0
src/main/java/fr/triplea/demovote/model/Participant.java

@@ -169,10 +169,12 @@ public class Participant
   public void setDateCreation(LocalDateTime d) { this.dateCreation = d; }
   public void setDateCreation(String s) { this.dateCreation = LocalDateTime.parse(s, df); }
   public LocalDateTime getDateCreation() { return this.dateCreation; }
+  public boolean hasDateCreation() { return (this.dateCreation != null); }
   
   public void setDateModification(LocalDateTime d) { this.dateModification = d; }
   public void setDateModification(String s) { this.dateModification = LocalDateTime.parse(s, df); }
   public LocalDateTime getDateModification() { return this.dateModification; }
+  public boolean hasDateModification() { return (this.dateModification != null); }
   
   public List<Role> getRoles() { return roles; }
   public void setRoles(final List<Role> roles) { this.roles = roles; }
@@ -272,6 +274,7 @@ public class Participant
   
   public void setDateInscription(LocalDateTime d) { this.dateInscription = d; }
   public LocalDateTime getDateInscription() { return this.dateInscription; }
+  public boolean hasDateInscription() { return (this.dateInscription != null); }
   
   public void setSommeRecue(BigDecimal d) { this.sommeRecue = d; }
   public BigDecimal getSommeRecue() { return this.sommeRecue; }

+ 0 - 2
src/main/java/fr/triplea/demovote/security/SecurityConfig.java

@@ -38,8 +38,6 @@ import org.springframework.security.web.context.RequestAttributeSecurityContextR
 public class SecurityConfig
 {
  
-  // TODO: déconnexion automatique après timeout
-
   @Bean
   public ResourceBundleMessageSource messageSource() 
   {

+ 34 - 17
src/main/java/fr/triplea/demovote/web/controller/AccountController.java

@@ -1,8 +1,11 @@
 package fr.triplea.demovote.web.controller;
 
+import java.util.Locale;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.crypto.password.PasswordEncoder;
@@ -11,10 +14,14 @@ import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.ParticipantRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
+import fr.triplea.demovote.dto.ParticipantRecord;
 import fr.triplea.demovote.dto.ParticipantTransfer;
 import fr.triplea.demovote.model.Participant;
+import jakarta.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping("/account")
@@ -29,13 +36,19 @@ public class AccountController
   @Autowired
   private PasswordEncoder passwordEncoder;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+ 
+  @Autowired
+  private MessageSource messageSource;
+
   
   @GetMapping(value = "/form")
-  public ResponseEntity<ParticipantTransfer> getForm(final Authentication authentication) 
+  public ResponseEntity<ParticipantRecord> getForm(final Authentication authentication) 
   {         
     if (authentication != null)
     {
-      ParticipantTransfer found = participantRepository.searchByPseudonyme(authentication.getName());
+      ParticipantRecord found = participantRepository.searchByPseudonyme(authentication.getName());
       
       if (found != null) { return ResponseEntity.ok(found); }
     }
@@ -44,8 +57,10 @@ public class AccountController
   }
  
   @PutMapping(value = "/update")
-  public ResponseEntity<Object> update(@RequestBody(required = true) ParticipantTransfer participant, final Authentication authentication) 
+  public ResponseEntity<Object> update(@RequestBody(required = true) ParticipantTransfer participant, final Authentication authentication, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     if (authentication != null)
     {
       Participant found = participantRepository.findByPseudonyme(authentication.getName());
@@ -54,28 +69,30 @@ public class AccountController
       {
         found.setEnabled(true);
 
-        found.setNom(participant.nom());
-        found.setPrenom(participant.prenom());
+        found.setNom(participant.getNom());
+        found.setPrenom(participant.getPrenom());
         
-        final String mdp = participant.motDePasse();
+        final String mdp = participant.getMotDePasse();
         if (mdp != null) { if (!(mdp.isBlank())) { found.setMotDePasse(passwordEncoder.encode(mdp.trim())); } } 
         
-        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());
+        found.setGroupe(participant.getGroupe()); 
+        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.setCommentaire(participant.commentaire());
+        found.setCommentaire(participant.getCommentaire());
        
         // TODO: modify password in session
         
         participantRepository.save(found);
-      
-        return ResponseEntity.ok(participant);
+       
+        MessagesTransfer mt = new MessagesTransfer();
+        mt.setInformation(messageSource.getMessage("participant.updated", null, locale));
+        
+        return ResponseEntity.ok(mt);
       }
     } 
     

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

@@ -22,7 +22,7 @@ import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.ParticipantRepository;
 import fr.triplea.demovote.dto.JourneesTransfer;
-import fr.triplea.demovote.dto.ParticipantTransfer;
+import fr.triplea.demovote.dto.ParticipantRecord;
 import fr.triplea.demovote.dto.RefreshTokenTransfer;
 import fr.triplea.demovote.dto.UserCredentials;
 import fr.triplea.demovote.model.Participant;
@@ -33,7 +33,6 @@ import fr.triplea.demovote.security.jwt.JwtTokenUtil;
 import fr.triplea.demovote.security.jwt.RefreshTokenException;
 import fr.triplea.demovote.security.jwt.RefreshTokenService;
 import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 
 @RestController
@@ -76,17 +75,17 @@ public class AuthController
   }
 
   @PostMapping(value = "/in")
-  public ResponseEntity<UserCredentials> signIn(@RequestBody UserCredentials uc, HttpServletRequest request, HttpServletResponse response)
+  public ResponseEntity<UserCredentials> signIn(@RequestBody UserCredentials uc, HttpServletRequest request)
   {
+    Locale locale = localeResolver.resolveLocale(request);
+
     String usrn = uc.getUsername(); if (usrn == null) { usrn = ""; } else { usrn = usrn.trim(); }
     String pass = uc.getPassword(); if (pass == null) { pass = ""; } else { pass = pass.trim(); }
     
     if (usrn.isEmpty() || pass.isEmpty()) { return ResponseEntity.notFound().build(); }
     
     Participant found = participantRepository.findByPseudonyme(usrn);
-    
-    Locale locale = localeResolver.resolveLocale(request);
-    
+        
     if (found != null)
     { 
       UserDetails userDetails = myUserDetailsService.loadUserByUsername(usrn);
@@ -109,6 +108,7 @@ public class AuthController
         uc.setPassword("<success@auth>");
         uc.setNom(found.getNom());
         uc.setPrenom(found.getPrenom());
+        uc.setDelaiAvantDeconnexion(found.getDelaiDeconnexion());
         uc.setAccessToken(token);
         uc.setRefreshToken(refreshToken.getToken());
         uc.setErreur("");
@@ -129,6 +129,7 @@ public class AuthController
         uc.setPassword("");
         uc.setNom("");
         uc.setPrenom("");
+        uc.setDelaiAvantDeconnexion(15);
         uc.setAccessToken("");
         uc.setRefreshToken("");
         uc.setRole("");
@@ -144,6 +145,7 @@ public class AuthController
     uc.setPassword("");
     uc.setNom("");
     uc.setPrenom("");
+    uc.setDelaiAvantDeconnexion(15);
     uc.setAccessToken("");
     uc.setRefreshToken("");
     uc.setRole("");
@@ -179,7 +181,7 @@ public class AuthController
   {
     if (authentication != null)
     {
-      ParticipantTransfer found = participantRepository.searchByPseudonyme(authentication.getName());
+      ParticipantRecord found = participantRepository.searchByPseudonyme(authentication.getName());
       
       if (found != null) { refreshTokenService.deleteByNumeroParticipant(found.numeroParticipant()); }
     }
@@ -192,6 +194,7 @@ public class AuthController
     uc.setPassword("");
     uc.setNom("");
     uc.setPrenom("");
+    uc.setDelaiAvantDeconnexion(15);
     uc.setAccessToken("");
     uc.setRefreshToken("");
     uc.setRole("");

+ 27 - 12
src/main/java/fr/triplea/demovote/web/controller/BulletinController.java

@@ -1,10 +1,9 @@
 package fr.triplea.demovote.web.controller;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Locale;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
+import org.springframework.context.MessageSource;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -13,15 +12,18 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.BulletinRepository;
 import fr.triplea.demovote.dao.CategorieRepository;
 import fr.triplea.demovote.dao.ParticipantRepository;
 import fr.triplea.demovote.dao.ProductionRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.model.Bulletin;
 import fr.triplea.demovote.model.Categorie;
 import fr.triplea.demovote.model.Participant;
 import fr.triplea.demovote.model.Production;
+import jakarta.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping("/urne")
@@ -40,10 +42,18 @@ public class BulletinController
   @Autowired
   private ProductionRepository productionRepository;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+  
+  @Autowired
+  private MessageSource messageSource;
+
   @PostMapping(value = "/create")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Object> add(@RequestParam(required = true) int cat_id, @RequestParam(required = true) int part_id, @RequestParam(required = true) int prod_id) 
+  public ResponseEntity<Object> add(@RequestParam(required = true) int cat_id, @RequestParam(required = true) int part_id, @RequestParam(required = true) int prod_id, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Bulletin bul = bulletinRepository.findByCategorieAndParticipant(cat_id, part_id);
     
     Categorie cat = categorieRepository.findById(cat_id);
@@ -120,20 +130,25 @@ public class BulletinController
       
       bulletinRepository.saveAndFlush(bul); 
     }
-    
-    return ResponseEntity.status(HttpStatus.CREATED).body(bul);
+   
+    MessagesTransfer mt = new MessagesTransfer();
+    mt.setInformation(messageSource.getMessage("bulletin.inserted", null, locale));
+
+    return ResponseEntity.ok(mt);
   }
 
   @DeleteMapping(value = "/delete/{id}")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Map<String, Boolean>> remove(@PathVariable int id) 
+  public ResponseEntity<Object> remove(@PathVariable int id, HttpServletRequest request) 
   { 
-    if (id > 0) { bulletinRepository.deleteById(id); }
-    
-    Map<String, Boolean> response = new HashMap<>();
-    response.put("deleted", Boolean.TRUE);
+    Locale locale = localeResolver.resolveLocale(request);
+
+    if (id > 0) { bulletinRepository.deleteById(id); } 
     
-    return ResponseEntity.ok(response); 
+    MessagesTransfer mt = new MessagesTransfer();
+    mt.setInformation(messageSource.getMessage("bulletin.deleted", null, locale));
+
+    return ResponseEntity.ok(mt);
   }
 
 }

+ 39 - 13
src/main/java/fr/triplea/demovote/web/controller/CategorieController.java

@@ -1,10 +1,10 @@
 package fr.triplea.demovote.web.controller;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Locale;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -15,9 +15,12 @@ import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.CategorieRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.model.Categorie;
+import jakarta.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping("/categorie")
@@ -27,6 +30,12 @@ public class CategorieController
   @Autowired
   private CategorieRepository categorieRepository;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+  
+  @Autowired
+  private MessageSource messageSource;
+
 
   @GetMapping(value = "/list")
   @PreAuthorize("hasRole('ADMIN')")
@@ -48,21 +57,33 @@ public class CategorieController
 
   @PostMapping(value = "/create")
   @PreAuthorize("hasRole('ADMIN')")
-  public Categorie create(@RequestBody(required = true) Categorie categorie) 
+  public ResponseEntity<Object> create(@RequestBody(required = true) Categorie categorie, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Categorie found = categorieRepository.findById(0);
     
     if (found == null) { categorie.setNumeroCategorie(null); }
     
-    if (categorie.hasLibelle()) { return categorieRepository.save(categorie); }
+    if (categorie.hasLibelle()) 
+    { 
+      categorieRepository.save(categorie); 
+     
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("categorie.created", null, locale));
+
+      return ResponseEntity.ok(mt);
+    }
 
     return null;
   }
 
   @PutMapping(value = "/update/{id}")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) Categorie categorie) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) Categorie categorie, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Categorie found = categorieRepository.findById(id);
     
     if (found != null)
@@ -77,9 +98,12 @@ public class CategorieController
       found.setPollable(categorie.isPollable());
       found.setComputed(categorie.isComputed());
 
-      Categorie updated = categorieRepository.save(found); 
-    
-      return ResponseEntity.ok(updated);
+      categorieRepository.save(found); 
+      
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("categorie.updated", null, locale));
+
+      return ResponseEntity.ok(mt);
     }
     
     return ResponseEntity.notFound().build(); 
@@ -87,8 +111,10 @@ public class CategorieController
 
   @DeleteMapping(value = "/delete/{id}")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Map<String, Boolean>> disableCategorie(@PathVariable int id) 
+  public ResponseEntity<Object> disableCategorie(@PathVariable int id, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Categorie c = categorieRepository.getReferenceById(id);
     
     if (c != null)
@@ -96,11 +122,11 @@ public class CategorieController
       c.setEnabled(false); 
       
       categorieRepository.saveAndFlush(c);
-
-      Map<String, Boolean> response = new HashMap<>();
-      response.put("deleted", Boolean.TRUE);
       
-      return ResponseEntity.ok(response); 
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setAlerte(messageSource.getMessage("categorie.deleted", null, locale));
+
+      return ResponseEntity.ok(mt);
     }      
     
     return ResponseEntity.notFound().build(); 

+ 166 - 75
src/main/java/fr/triplea/demovote/web/controller/ParticipantController.java

@@ -1,13 +1,16 @@
 package fr.triplea.demovote.web.controller;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.UUID;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.crypto.password.PasswordEncoder;
@@ -20,14 +23,18 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.ParticipantRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.dto.ParticipantList;
 import fr.triplea.demovote.dto.ParticipantOptionList;
 import fr.triplea.demovote.dto.ParticipantTransfer;
 import fr.triplea.demovote.model.Participant;
 import fr.triplea.demovote.model.ParticipantModePaiement;
 import fr.triplea.demovote.model.ParticipantStatut;
+import fr.triplea.demovote.model.Role;
+import jakarta.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping("/participant")
@@ -40,6 +47,14 @@ public class ParticipantController
   @Autowired
   private PasswordEncoder passwordEncoder;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+  
+  @Autowired
+  private MessageSource messageSource;
+
+  private final SimpleDateFormat sdt_fr = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); 
+  private final SimpleDateFormat sdt_en = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); 
   
 
   @GetMapping(value = "/list")
@@ -63,80 +78,146 @@ public class ParticipantController
 
   @GetMapping(value = "/form/{id}")
   @PreAuthorize("hasRole('ORGA')")
-  public ResponseEntity<ParticipantTransfer> getForm(@PathVariable int id) 
+  public ResponseEntity<ParticipantTransfer> getForm(@PathVariable int id, HttpServletRequest request) 
   { 
-    ParticipantTransfer p = participantRepository.searchById(id);
+    Locale locale = localeResolver.resolveLocale(request);
+
+    SimpleDateFormat sdt = this.sdt_fr; if (locale == Locale.ENGLISH) { sdt = this.sdt_en; }
+    
+    Participant found = participantRepository.findById(id);
+    
+    
+    if (found != null)
+    {
+      ParticipantTransfer p = new ParticipantTransfer();
+      
+      // TODO: dates
+      
+      //p.setDateCreation(found.hasDateCreation() ? sdt.format(found.getDateCreation()) : "");
+      //p.setDateModification(found.hasDateCreation() ? sdt.format(found.getDateModification()) : ""); 
+      p.setNumeroParticipant(found.getNumeroParticipant());
+      
+      p.setNom(found.getNom());
+      p.setPrenom(found.getPrenom());
+      p.setPseudonyme(found.getPseudonyme());
+      
+      p.setGroupe(found.getGroupe()); 
+      p.setDelaiDeconnexion(found.getDelaiDeconnexion());
+      p.setAdresse(found.getAdresse());
+      p.setCodePostal(found.getCodePostal());
+      p.setVille(found.getVille());
+      p.setPays(found.getPays());
+      p.setNumeroTelephone(found.getNumeroTelephone());
+      p.setEmail(found.getEmail());
+               
+      if (found.getStatut().equals(ParticipantStatut.PAYE_CHEQUE)) { p.setStatut("PAYE_CHEQUE"); }
+      else if(found.getStatut().equals(ParticipantStatut.PAYE_ESPECES)) { p.setStatut("PAYE_ESPECES"); }
+      else if(found.getStatut().equals(ParticipantStatut.VIREMENT_BANCAIRE)) { p.setStatut("VIREMENT_BANCAIRE"); }
+      else if(found.getStatut().equals(ParticipantStatut.VIREMENT_PAYPAL)) { p.setStatut("VIREMENT_PAYPAL"); }
+      else if(found.getStatut().equals(ParticipantStatut.ORGA)) { p.setStatut("ORGA"); }
+      else if(found.getStatut().equals(ParticipantStatut.GUEST)) { p.setStatut("GUEST"); }
+      else { p.setStatut("EN_ATTENTE"); }
+      
+      p.setWithMachine(found.isWithMachine());
+      p.setCommentaire(found.getCommentaire());
+      p.setHereDay1(found.isHereDay1());
+      p.setHereDay2(found.isHereDay2());
+      p.setHereDay3(found.isHereDay3());
+      p.setSleepingOnSite(found.isSleepingOnSite());
+      p.setUseAmigabus(found.isUseAmigabus());
+       
+      if (found.getModePaiement().equals(ParticipantModePaiement.CHEQUE)) { p.setModePaiement("CHEQUE"); }
+      else if(found.getModePaiement().equals(ParticipantModePaiement.VIREMENT)) { p.setModePaiement("VIREMENT"); }
+      else if(found.getModePaiement().equals(ParticipantModePaiement.PAYPAL)) { p.setModePaiement("PAYPAL"); }
+      else if(found.getModePaiement().equals(ParticipantModePaiement.ESPECES)) { p.setModePaiement("ESPECES"); }
+      else { p.setModePaiement("AUTRE"); }
+      
+      try { p.setSommeRecue(found.getSommeRecue().toString()); } catch (Exception e) { p.setSommeRecue("0.00"); }
+      //p.setDateInscription(found.hasDateInscription() ? sdt.format(found.getDateInscription()) : "");
+      p.setArrived(found.isArrived());
+     
+      List<Role> roles = found.getRoles();       
+      
+      if (!(p.hasRole())) { for (Role role : roles) { if (role.isRole("ADMIN")) { p.setRole("ADMIN"); } } }
+      if (!(p.hasRole())) { for (Role role : roles) { if (role.isRole("ORGA")) { p.setRole("ORGA"); } } }
+      if (!(p.hasRole())) { p.setRole("USER"); } 
 
-    if (p != null) { return ResponseEntity.ok(p); }
+     return ResponseEntity.ok(p); 
+    }
     
     return ResponseEntity.notFound().build();
   }
 
   @PostMapping(value = "/create")
   @PreAuthorize("hasRole('ORGA')")
-  public ResponseEntity<Object> create(@RequestBody(required = true) ParticipantTransfer participant) 
+  public ResponseEntity<Object> create(@RequestBody(required = true) ParticipantTransfer participant, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Participant found = participantRepository.findById(0);
     
     if (found == null) 
     {
-      if (!(participant.nom().isBlank()))
+      if (!(participant.getNom().isBlank()))
       {
-        if (!(participant.pseudonyme().isBlank()))
+        if (!(participant.getPseudonyme().isBlank()))
         {
           found = new Participant();
           
           found.setRoles(found.getRoles());
           found.setEnabled(true);
 
-          found.setNom(participant.nom());
-          found.setPrenom(participant.prenom());
+          found.setNom(participant.getNom());
+          found.setPrenom(participant.getPrenom());
           
-          found.setPseudonyme(participant.pseudonyme());
+          found.setPseudonyme(participant.getPseudonyme());
  
-          final String mdp = participant.motDePasse();
+          final String mdp = participant.getMotDePasse();
           if (mdp != null) { if (!(mdp.isBlank())) { found.setMotDePasse(passwordEncoder.encode(mdp.trim())); } } 
           
-          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());
+          found.setGroupe(participant.getGroupe()); 
+          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());
                    
-          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); }
+          if (participant.getStatut().equals("PAYE_CHEQUE")) { found.setStatut(ParticipantStatut.PAYE_CHEQUE); }
+          else if(participant.getStatut().equals("PAYE_ESPECES")) { found.setStatut(ParticipantStatut.PAYE_ESPECES); }
+          else if(participant.getStatut().equals("VIREMENT_BANCAIRE")) { found.setStatut(ParticipantStatut.VIREMENT_BANCAIRE); }
+          else if(participant.getStatut().equals("VIREMENT_PAYPAL")) { found.setStatut(ParticipantStatut.VIREMENT_PAYPAL); }
+          else if(participant.getStatut().equals("ORGA")) { found.setStatut(ParticipantStatut.ORGA); }
+          else if(participant.getStatut().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());
+          found.setWithMachine(participant.isWithMachine());
+          found.setCommentaire(participant.getCommentaire());
+          found.setHereDay1(participant.isHereDay1());
+          found.setHereDay2(participant.isHereDay2());
+          found.setHereDay3(participant.isHereDay3());
+          found.setSleepingOnSite(participant.isSleepingOnSite());
+          found.setUseAmigabus(participant.isUseAmigabus());
            
-          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); }
+          if (participant.getModePaiement().equals("CHEQUE")) { found.setModePaiement(ParticipantModePaiement.CHEQUE); }
+          else if(participant.getModePaiement().equals("VIREMENT")) { found.setModePaiement(ParticipantModePaiement.VIREMENT); }
+          else if(participant.getModePaiement().equals("PAYPAL")) { found.setModePaiement(ParticipantModePaiement.PAYPAL); }
+          else if(participant.getModePaiement().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")); }
+          try { found.setSommeRecue(new BigDecimal(participant.getSommeRecue())); } catch (Exception e) { found.setSommeRecue(new BigDecimal("0.00")); }
           found.setDateInscription(LocalDateTime.now());
-          found.setArrived(participant.arrived());
+          found.setArrived(participant.isArrived());
           
           // TODO: set roles
           
-          Participant created = participantRepository.save(found);
-        
-          return ResponseEntity.ok(created); // TODO: retourner ici et ailleurs un message court au lieu de la totalité
+          participantRepository.save(found);
+          
+          MessagesTransfer mt = new MessagesTransfer();
+          mt.setInformation(messageSource.getMessage("participant.created", null, locale));
+
+          return ResponseEntity.ok(mt);
         }
       }
     }
@@ -146,8 +227,10 @@ public class ParticipantController
 
   @PutMapping(value = "/update/{id}")
   @PreAuthorize("hasRole('ORGA')")
-  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) ParticipantTransfer participant) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) ParticipantTransfer participant, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Participant found = participantRepository.findById(id);
     
     if (found != null)
@@ -155,54 +238,57 @@ public class ParticipantController
       found.setRoles(found.getRoles());
       found.setEnabled(true);
 
-      found.setNom(participant.nom());
-      found.setPrenom(participant.prenom());
+      found.setNom(participant.getNom());
+      found.setPrenom(participant.getPrenom());
       
-      found.setPseudonyme(participant.pseudonyme());
+      found.setPseudonyme(participant.getPseudonyme());
 
-      final String mdp = participant.motDePasse();
+      final String mdp = participant.getMotDePasse();
       if (mdp != null) { if (!(mdp.isBlank())) { found.setMotDePasse(passwordEncoder.encode(mdp.trim())); } } 
 
-      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());
+      found.setGroupe(participant.getGroupe()); 
+      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());
      
-      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); }
+      if (participant.getStatut().equals("PAYE_CHEQUE")) { found.setStatut(ParticipantStatut.PAYE_CHEQUE); }
+      else if(participant.getStatut().equals("PAYE_ESPECES")) { found.setStatut(ParticipantStatut.PAYE_ESPECES); }
+      else if(participant.getStatut().equals("VIREMENT_BANCAIRE")) { found.setStatut(ParticipantStatut.VIREMENT_BANCAIRE); }
+      else if(participant.getStatut().equals("VIREMENT_PAYPAL")) { found.setStatut(ParticipantStatut.VIREMENT_PAYPAL); }
+      else if(participant.getStatut().equals("ORGA")) { found.setStatut(ParticipantStatut.ORGA); }
+      else if(participant.getStatut().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());
+      found.setWithMachine(participant.isWithMachine());
+      found.setCommentaire(participant.getCommentaire());
+      found.setHereDay1(participant.isHereDay1());
+      found.setHereDay2(participant.isHereDay2());
+      found.setHereDay3(participant.isHereDay3());
+      found.setSleepingOnSite(participant.isSleepingOnSite());
+      found.setUseAmigabus(participant.isUseAmigabus());
        
-      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); }
+      if (participant.getModePaiement().equals("CHEQUE")) { found.setModePaiement(ParticipantModePaiement.CHEQUE); }
+      else if(participant.getModePaiement().equals("VIREMENT")) { found.setModePaiement(ParticipantModePaiement.VIREMENT); }
+      else if(participant.getModePaiement().equals("PAYPAL")) { found.setModePaiement(ParticipantModePaiement.PAYPAL); }
+      else if(participant.getModePaiement().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());
+      try { found.setSommeRecue(new BigDecimal(participant.getSommeRecue())); } catch (Exception e) { found.setSommeRecue(new BigDecimal("0.00")); }
+      found.setArrived(participant.isArrived());
       
       // TODO: modify password in session
       // TODO: modify roles
 
-      Participant updated = participantRepository.save(found);
+      participantRepository.save(found);
+      
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("participant.updated", null, locale));
     
-      return ResponseEntity.ok(updated);
+      return ResponseEntity.ok(mt);
     }
     
     return ResponseEntity.notFound().build();
@@ -210,8 +296,10 @@ public class ParticipantController
 
   @DeleteMapping(value = "/delete/{id}")
   @PreAuthorize("hasRole('ORGA')")
-  public ResponseEntity<Map<String, Boolean>> disableParticipant(@PathVariable int id) 
+  public ResponseEntity<Map<String, Boolean>> disableParticipant(@PathVariable int id, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Participant found = participantRepository.getReferenceById(id);
     
     if (found != null)
@@ -224,6 +312,9 @@ public class ParticipantController
       Map<String, Boolean> response = new HashMap<>();
       response.put("deleted", Boolean.TRUE);
       
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setAlerte(messageSource.getMessage("participant.deleted", null, locale));
+
       return ResponseEntity.ok(response); 
     }      
     

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

@@ -2,11 +2,11 @@ package fr.triplea.demovote.web.controller;
 
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Locale;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.core.io.ByteArrayResource;
 import org.springframework.core.io.Resource;
 import org.springframework.http.HttpHeaders;
@@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.ParticipantRepository;
 import fr.triplea.demovote.dao.ProductionRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.dto.ProductionFile;
 import fr.triplea.demovote.dto.ProductionShort;
 import fr.triplea.demovote.dto.ProductionTransfer;
@@ -46,6 +48,13 @@ public class ProductionController
   @Autowired
   private ParticipantRepository participantRepository;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+  
+  @Autowired
+  private MessageSource messageSource;
+
+  // TODO : externaliser le stockage des fichiers
  
   @GetMapping(value = "/list")
   @PreAuthorize("hasRole('USER')")
@@ -105,8 +114,10 @@ public class ProductionController
 
   @PostMapping(value = "/create")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Map<String, Boolean>> create(@RequestBody(required = true) ProductionTransfer production, HttpServletRequest request) 
+  public ResponseEntity<Object> create(@RequestBody(required = true) ProductionTransfer production, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Participant participant = participantRepository.findById(production.numeroParticipant());
 
     if (participant != null) 
@@ -137,11 +148,11 @@ public class ProductionController
       fresh.setNumeroVersion(production.numeroVersion());
       
       productionRepository.save(fresh);
-
-      Map<String, Boolean> response = new HashMap<>();
-      response.put("created", Boolean.TRUE);
       
-      return ResponseEntity.ok(response); 
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("production.created", null, locale));
+
+      return ResponseEntity.ok(mt);
     }
 
     return ResponseEntity.notFound().build(); 
@@ -149,8 +160,10 @@ public class ProductionController
  
   @PutMapping(value = "/update/{id}")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Map<String, Boolean>> update(HttpServletRequest request, @PathVariable int id, @RequestBody(required = true) ProductionUpdate production) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) ProductionUpdate production, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Production found = productionRepository.findById(id);
     
     if (found != null)
@@ -181,11 +194,11 @@ public class ProductionController
         if (production.vignette() != null) { if (!(production.vignette().isBlank())) { found.setVignette(production.vignette()); } }
         
         productionRepository.save(found);
-
-        Map<String, Boolean> response = new HashMap<>();
-        response.put("updated", Boolean.TRUE);
         
-        return ResponseEntity.ok(response); 
+        MessagesTransfer mt = new MessagesTransfer();
+        mt.setInformation(messageSource.getMessage("production.updated", null, locale));
+
+        return ResponseEntity.ok(mt);
       }
     }
     
@@ -194,8 +207,10 @@ public class ProductionController
   
   @PutMapping(value = "/upload/{id}")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Map<String, Boolean>> update(@PathVariable int id, @RequestBody(required = true) ProductionFile production) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) ProductionFile production, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Production found = productionRepository.findById(id);
     
     if (found != null)
@@ -215,11 +230,11 @@ public class ProductionController
               found.setNumeroVersion(found.getNumeroVersion() + 1);
               
               productionRepository.save(found);
+         
+              MessagesTransfer mt = new MessagesTransfer();
+              mt.setInformation(messageSource.getMessage("production.file.updated", null, locale));
 
-              Map<String, Boolean> response = new HashMap<>();
-              response.put("updated", Boolean.TRUE);
-              
-              return ResponseEntity.ok(response); 
+              return ResponseEntity.ok(mt);
             }
           }
         }
@@ -231,8 +246,10 @@ public class ProductionController
 
   @DeleteMapping(value = "/delete/{id}")
   @PreAuthorize("hasRole('USER')")
-  public ResponseEntity<Map<String, Boolean>> disableProduction(@PathVariable int id) 
+  public ResponseEntity<Object> disableProduction(@PathVariable int id, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Production found = productionRepository.getReferenceById(id);
     
     if (found != null)
@@ -240,11 +257,11 @@ public class ProductionController
       found.setEnabled(false); 
       
       productionRepository.saveAndFlush(found);
-      
-      Map<String, Boolean> response = new HashMap<>();
-      response.put("deleted", Boolean.TRUE);
-      
-      return ResponseEntity.ok(response); 
+           
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("production.deleted", null, locale));
+
+      return ResponseEntity.ok(mt);
     }      
     
     return ResponseEntity.notFound().build(); 

+ 38 - 13
src/main/java/fr/triplea/demovote/web/controller/VariableController.java

@@ -1,11 +1,11 @@
 package fr.triplea.demovote.web.controller;
 
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Locale;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -17,10 +17,13 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
 
 import fr.triplea.demovote.dao.VariableRepository;
+import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.dto.VariableTypeOptionList;
 import fr.triplea.demovote.model.Variable;
+import jakarta.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping("/variable")
@@ -30,6 +33,11 @@ public class VariableController
   @Autowired
   private VariableRepository variableRepository;
 
+  @Autowired
+  private LocaleResolver localeResolver;
+  
+  @Autowired
+  private MessageSource messageSource;
 
   @GetMapping(value = "/list")
   @PreAuthorize("hasRole('ADMIN')")
@@ -60,21 +68,33 @@ public class VariableController
 
   @PostMapping(value = "/create")
   @PreAuthorize("hasRole('ADMIN')")
-  public Variable create(@RequestBody(required = true) Variable variable) 
+  public ResponseEntity<Object> create(@RequestBody(required = true) Variable variable, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Variable found = variableRepository.findById(0);
     
     if (found == null) { variable.setNumeroVariable(null); }
     
-    if (variable.hasType() && variable.hasCode()) { return variableRepository.save(variable); }
+    if (variable.hasType() && variable.hasCode()) 
+    { 
+      variableRepository.save(variable); 
+      
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("variable.created", null, locale));
+
+      return ResponseEntity.ok(mt);
+    }
     
     return null;
   }
  
   @PutMapping(value = "/update/{id}")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Variable> update(@PathVariable int id, @RequestBody(required = true) Variable variable) 
+  public ResponseEntity<Object> update(@PathVariable int id, @RequestBody(required = true) Variable variable, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Variable found = variableRepository.findById(id);
     
     if (found != null)
@@ -84,9 +104,12 @@ public class VariableController
       found.setValeur(variable.getValeur());
       found.setNotes(variable.getNotes());
       
-      Variable updated = variableRepository.save(found);
-    
-      return ResponseEntity.ok(updated);
+      variableRepository.save(found);
+      
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("variable.updated", null, locale));
+
+      return ResponseEntity.ok(mt);
     }
     
     return ResponseEntity.notFound().build();
@@ -94,18 +117,20 @@ public class VariableController
 
   @DeleteMapping(value = "/delete/{id}")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Map<String, Boolean>> deleteVariable(@PathVariable int id) 
+  public ResponseEntity<Object> deleteVariable(@PathVariable int id, HttpServletRequest request) 
   { 
+    Locale locale = localeResolver.resolveLocale(request);
+
     Variable found = variableRepository.findById(id);
 
     if (found != null) 
     { 
       variableRepository.deleteById(id); 
       
-      Map<String, Boolean> response = new HashMap<>();
-      response.put("deleted", Boolean.TRUE);
-      
-      return ResponseEntity.ok(response); 
+      MessagesTransfer mt = new MessagesTransfer();
+      mt.setInformation(messageSource.getMessage("variable.deleted", null, locale));
+
+      return ResponseEntity.ok(mt);
     }
     
     return ResponseEntity.notFound().build(); 

+ 21 - 0
src/main/resources/langs/messages_en.properties

@@ -3,3 +3,24 @@ auth.user.notfound=The nickname does not seem to be used by any entrant.
 
 refreshtoken.notfound=the currrent RefreshToken is not present in the database.
 refreshtoken.expired=the current RefreshToken has expired. Please re-sign in.
+
+participant.created=The new entrant was correctly created.
+participant.updated=Entrant informations has been updated.
+participant.deleted=This entrant was removed from the list.
+
+categorie.created=The new compo was correctly created.
+categorie.updated=The compo informations were updated.
+categorie.deleted=This compo was removed.
+
+variable.created=The new environment variable was correctly created.
+variable.updated=The variable datas were updated.
+variable.deleted=This environment variable was deleted.
+
+production.created=The new production was correctly created.
+production.updated=The production informations were updated.
+production.file.updated=The production archive was updated.
+production.deleted=This production is removed from the list.
+
+bulletin.created=The vote was registered.
+bulletin.deleted=The vote was removed.
+

+ 21 - 0
src/main/resources/langs/messages_fr.properties

@@ -3,3 +3,24 @@ auth.user.notfound=Le pseudonyme ne semble pas 
 
 refreshtoken.notfound=ce RefreshToken introuvable dans la base de données.
 refreshtoken.expired=ce RefreshToken a expiré. Merci de vous reconnecter.
+
+participant.created=Le nouveau participant a bien été enregistré.
+participant.updated=Les informations du participant ont bien été mises à jour.
+participant.deleted=Le participant a été retiré des inscrits.
+
+categorie.created=La nouvelle catégorie a bien été enregistrée.
+categorie.updated=Les informations de cette catégorie ont bien été mises à jour.
+categorie.deleted=La catégorie a été retirée.
+
+variable.created=La nouvelle variable d'environnement a bien été enregistrée.
+variable.updated=Les données de cette variable ont bien été mises à jour.
+variable.deleted=La variable d'environnement a été supprimée.
+
+production.created=La nouvelle production a bien été enregistrée.
+production.updated=Les informations de cette production ont bien été mises à jour.
+production.file.updated=L'archive de cette production a bien été mise à jour.
+production.deleted=La production a été retirée des enregistrements.
+
+bulletin.created=Le bulletin a été inséré.
+bulletin.deleted=Le bulletin a été retiré.
+