Browse Source

dev en cours

rajah 11 months ago
parent
commit
a1597e56ac

+ 2 - 0
bin/main/application.properties

@@ -21,6 +21,8 @@ server.servlet.context-path=/demovote-api/v1
 #logging.logback.rollingpolicy.total-size-cap=10MB
 #logging.logback.rollingpolicy.max-history=5
 
+admin.email.address=xxx.xxx@free.fr
+
 jwttoken.secret=ee3c5233e2fde173cf7f401e5fb45aa47937a76f45e5fdcff29bedba6e6ea61c695ac0058ead08561261445b6f547aced2e335c2cc210fab42bc4b5317f987e9297b5c0e19eb21f38d0fd5cf69ba4cfa7ed0fa02d299a34ed6fdf22b508997a573075c4c375e6f3e45c7cb82c78958b2f3d47a87145eb74334023429401f584928a224796093afad62696dc9bab1cfdf4368a2263a13480b80faf873ca1f1cb067da4db75ec53379e0da1d3a61572dbeebfc3484f6f2ed333c96154036d0c22a5a2a59895ee6711e77e604e8b8c5b0a45fb2cce05298d12c25e1f9a6ba4d030ce2e480c1e3ad3fe0551c2a136bd18635c829f7eb4f92f4e34ec67e95bb966dac
 jwttoken.expiration=3600000 
 

+ 9 - 4
src/main/java/fr/triplea/demovote/CreateDefaultValues.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Locale;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.stereotype.Component;
@@ -21,7 +22,8 @@ import fr.triplea.demovote.model.Variable;
 public class CreateDefaultValues implements ApplicationListener<ContextRefreshedEvent>
 {
 
-  private final static String EMAIL_ADMIN = "pierre.tonthat@free.fr";
+  @Value("${admin.email.address}")
+  private String adminEmailAddress;
   
   boolean initialise = false;
 
@@ -69,10 +71,13 @@ public class CreateDefaultValues implements ApplicationListener<ContextRefreshed
         }
       }
       
-      if (participant.getEmail().equalsIgnoreCase(CreateDefaultValues.EMAIL_ADMIN))
+      if (adminEmailAddress != null)
       {
-        if (!roles.contains(adminRole)) { roles.add(adminRole); changed = true; }
-        if (!roles.contains(orgaRole)) { roles.add(orgaRole); changed = true; }
+        if (participant.getEmail().equalsIgnoreCase(adminEmailAddress))
+        {
+          if (!roles.contains(adminRole)) { roles.add(adminRole); changed = true; }
+          if (!roles.contains(orgaRole)) { roles.add(orgaRole); changed = true; }
+        }
       }
       
       if (changed)

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

@@ -65,7 +65,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "p.flag_arrive "
       + "FROM vote.participants AS p "
       + "WHERE p.flag_actif IS TRUE "
-      + "AND ((:nom is null) OR (UPPER(p.nom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.prenom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.pseudonyme) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.groupe) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.email) LIKE CONCAT('%', :nom, '%'))) "
+      + "AND ((:nom IS NULL) OR (UPPER(p.nom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.prenom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.pseudonyme) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.groupe) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.email) LIKE CONCAT('%', :nom, '%'))) "
       + "AND ((:statut = 0) OR (:statut = 1 AND p.statut = 'EN_ATTENTE'::vote.statut_participant)) "
       + "AND ((:arrive = 0) OR (:arrive = 1 AND p.flag_arrive = FALSE) OR (:arrive = 2 AND p.flag_arrive = TRUE)) "
       + "ORDER BY p.nom ASC, p.prenom ASC, p.pseudonyme ASC ")
@@ -86,7 +86,7 @@ public interface ParticipantRepository extends JpaRepository<Participant, Intege
       + "p.flag_arrive "
       + "FROM vote.participants AS p "
       + "WHERE p.flag_actif IS TRUE "
-      + "AND ((:nom is null) OR (UPPER(p.nom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.prenom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.pseudonyme) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.groupe) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.email) LIKE CONCAT('%', :nom, '%'))) "
+      + "AND ((:nom IS NULL) OR (UPPER(p.nom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.prenom) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.pseudonyme) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.groupe) LIKE CONCAT('%', :nom, '%')) OR (UPPER(p.email) LIKE CONCAT('%', :nom, '%'))) "
       + "AND ((:statut = 0) OR (:statut = 1 AND p.statut = 'EN_ATTENTE'::vote.statut_participant)) "
       + "AND ((:arrive = 0) OR (:arrive = 1 AND p.flag_arrive = FALSE) OR (:arrive = 2 AND p.flag_arrive = TRUE)) "
       + "ORDER BY p.numero_participant ASC ")

+ 1 - 1
src/main/java/fr/triplea/demovote/dao/VariableRepository.java

@@ -19,7 +19,7 @@ public interface VariableRepository extends JpaRepository<Variable, Integer>
   @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.numero_variable = :id ")
   Variable findById(@Param("id") int id);
 
-  @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE v.type = :type ORDER BY v.type ASC, v.code ASC ")
+  @NativeQuery("SELECT DISTINCT v.* FROM vote.variables AS v WHERE ((:type IS NULL) OR (v.type = :type)) ORDER BY v.type ASC, v.code ASC ")
   List<Variable> findByType(@Param("type") String type);
 
   @NativeQuery("SELECT DISTINCT v.valeur FROM vote.variables AS v WHERE v.type = :type AND v.code = :code ")

+ 35 - 0
src/main/java/fr/triplea/demovote/dto/JourneesTransfer.java

@@ -0,0 +1,35 @@
+package fr.triplea.demovote.dto;
+
+public class JourneesTransfer
+{
+
+  String jour1_court = null;
+  String jour1_long = null;
+
+  String jour2_court = null;
+  String jour2_long = null;
+  
+  String jour3_court = null;
+  String jour3_long = null;
+  
+  public JourneesTransfer() {}
+
+  public String getJour1Court() { return jour1_court; }
+  public void setJour1Court(String str) { if (str != null) { if (!(str.isBlank())) { this.jour1_court = str; } } }
+
+  public String getJour1Long() { return jour1_long; }
+  public void setJour1Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour1_long = str; } } }
+
+  public String getJour2Court() { return jour2_court; }
+  public void setJour2Court(String str) { if (str != null) { if (!(str.isBlank())) { this.jour2_court = str; } } }
+
+  public String getJour2Long() { return jour2_long; }
+  public void setJour2Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour2_long = str; } } }
+
+  public String getJour3Court() { return jour3_court; }
+  public void setJour3Court(String str) { if (str != null) { if (!(str.isBlank())) { this.jour3_court = str; } } }
+
+  public String getJour3Long() { return jour3_long; }
+  public void setJour3Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour3_long = str; } } }
+ 
+}

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

@@ -31,6 +31,7 @@ public class SecurityConfig
  
   // TODO: CSRF-TOKEN
   // TODO: gérer le 403 au niveau du frontend (en cas d'expiration du JWT -> refreshToken)
+  // TODO: déconnexion automatique après timeout
 
   @Bean
   public ResourceBundleMessageSource messageSource() 

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

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import fr.triplea.demovote.dao.VariableRepository;
+import fr.triplea.demovote.dto.JourneesTransfer;
 import fr.triplea.demovote.dto.MessagesTransfer;
 
 @CrossOrigin(origins = "http://localhost:4200")
@@ -33,5 +34,19 @@ public class DiversController
     return ResponseEntity.ok(mt); 
   }
 
+  @GetMapping(value = "/days")
+  public ResponseEntity<JourneesTransfer> getDaysLabels() 
+  { 
+    JourneesTransfer jt = new JourneesTransfer();
+
+    jt.setJour1Court(variableRepository.findByTypeAndCode("Application", "LIBELLE_COURT_JOUR1"));
+    jt.setJour1Long(variableRepository.findByTypeAndCode("Application", "LIBELLE_LONG_JOUR1"));
+    jt.setJour2Court(variableRepository.findByTypeAndCode("Application", "LIBELLE_COURT_JOUR2"));
+    jt.setJour2Long(variableRepository.findByTypeAndCode("Application", "LIBELLE_LONG_JOUR2"));
+    jt.setJour3Court(variableRepository.findByTypeAndCode("Application", "LIBELLE_COURT_JOUR3"));
+    jt.setJour3Long(variableRepository.findByTypeAndCode("Application", "LIBELLE_LONG_JOUR3"));
+    
+    return ResponseEntity.ok(jt); 
+  }
 
 }

+ 1 - 3
src/main/java/fr/triplea/demovote/web/controller/VariableController.java

@@ -37,9 +37,7 @@ public class VariableController
   @PreAuthorize("hasRole('ADMIN')")
   public List<Variable> getList(@RequestParam(required = false) String type) 
   { 
-    if (type == null) { return variableRepository.findAll(); }
-    else 
-    if (type.isBlank()) { return variableRepository.findAll(); }
+    if (type != null) { if (type.isBlank()) { type = null; } }
  
     return variableRepository.findByType(type); 
   }

+ 2 - 0
src/main/resources/application.properties

@@ -21,6 +21,8 @@ server.servlet.context-path=/demovote-api/v1
 #logging.logback.rollingpolicy.total-size-cap=10MB
 #logging.logback.rollingpolicy.max-history=5
 
+admin.email.address=xxx.xxx@free.fr
+
 jwttoken.secret=ee3c5233e2fde173cf7f401e5fb45aa47937a76f45e5fdcff29bedba6e6ea61c695ac0058ead08561261445b6f547aced2e335c2cc210fab42bc4b5317f987e9297b5c0e19eb21f38d0fd5cf69ba4cfa7ed0fa02d299a34ed6fdf22b508997a573075c4c375e6f3e45c7cb82c78958b2f3d47a87145eb74334023429401f584928a224796093afad62696dc9bab1cfdf4368a2263a13480b80faf873ca1f1cb067da4db75ec53379e0da1d3a61572dbeebfc3484f6f2ed333c96154036d0c22a5a2a59895ee6711e77e604e8b8c5b0a45fb2cce05298d12c25e1f9a6ba4d030ce2e480c1e3ad3fe0551c2a136bd18635c829f7eb4f92f4e34ec67e95bb966dac
 jwttoken.expiration=3600000