Browse Source

dev en cours

rajah 11 months ago
parent
commit
8dbfa0e209

+ 0 - 1
bin/main/application.properties

@@ -4,7 +4,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/vote
 spring.datasource.username=vote
 spring.datasource.password=Atari$Impact2024
 spring.jpa.hibernate.ddl-auto=validate
-spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
 spring.jpa.open-in-view=false
 
 spring.messages.basename=messages,langs.messages

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

@@ -10,6 +10,7 @@ import fr.triplea.demovote.dto.ProductionFile;
 import fr.triplea.demovote.dto.ProductionShort;
 import fr.triplea.demovote.model.Participant;
 import fr.triplea.demovote.model.Production;
+import fr.triplea.demovote.model.ProductionType;
 
 
 public interface ProductionRepository extends JpaRepository<Production, Integer> 
@@ -39,8 +40,9 @@ public interface ProductionRepository extends JpaRepository<Production, Integer>
               + "INNER JOIN vote.participants AS g ON p.numero_participant = g.numero_participant "
               + "WHERE p.flag_actif IS TRUE "
               + "AND ((:numero = 0) OR (:numero = p.numero_participant)) "
+              + "AND ((:type IS NULL) OR (p.type = (:type)::vote.type_production)) "
               + "ORDER BY p.titre ASC ")
-  List<ProductionShort> findAllWithoutArchive(@Param("numero") int numeroGestionnaire);
+  List<ProductionShort> findAllWithoutArchive(@Param("numero") int numeroGestionnaire, @Param("type") String type);
   
   @NativeQuery("SELECT DISTINCT " 
               + "TO_CHAR(p.date_creation, 'DD/MM/YYYY HH24:MI:SS') as date_creation, "

+ 17 - 9
src/main/java/fr/triplea/demovote/dto/JourneesTransfer.java

@@ -12,24 +12,32 @@ public class JourneesTransfer
   String jour3_court = null;
   String jour3_long = null;
   
+  boolean amigabus = false;
+  boolean dodosurplace = false;
+  
   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 String getJour1Court() { return jour1_court; }
   public void setJour1Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour1_long = str; } } }
+  public String getJour1Long() { return jour1_long; }
 
-  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 String getJour2Court() { return jour2_court; }
   public void setJour2Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour2_long = str; } } }
+  public String getJour2Long() { return jour2_long; }
 
-  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 String getJour3Court() { return jour3_court; }
   public void setJour3Long(String str) { if (str != null) { if (!(str.isBlank())) { this.jour3_long = str; } } }
+  public String getJour3Long() { return jour3_long; }
+
+  public void setAmigabus(boolean amigabus) { this.amigabus = amigabus; }
+  public boolean isAmigabus() { return amigabus; }
+
+  public void setDodosurplace(boolean dodosurplace) { this.dodosurplace = dodosurplace; }
+  public boolean isDodosurplace() { return dodosurplace; }
  
+  
+  
 }

+ 23 - 0
src/main/java/fr/triplea/demovote/model/Webcam.java

@@ -4,14 +4,22 @@ package fr.triplea.demovote.model;
 import jakarta.persistence.Id;
 import jakarta.persistence.Lob;
 import jakarta.persistence.Table;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
 import jakarta.persistence.Transient;
 
 import java.sql.Types;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
 import java.util.Base64;
+import java.util.Locale;
 import java.util.Objects;
 
 import org.hibernate.annotations.JdbcTypeCode;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 
 import jakarta.persistence.Column;
 import jakarta.persistence.Entity;
@@ -21,6 +29,11 @@ import jakarta.persistence.Entity;
 public class Webcam 
 {
 
+  @Temporal(TemporalType.TIMESTAMP)
+  @UpdateTimestamp
+  @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="dd/MM/yyyy HH:mm:ss", timezone="Europe/Paris")
+  private LocalDateTime dateModification;
+
   @Id
   @Column(name = "id", nullable = false)
   private Integer id;
@@ -31,6 +44,16 @@ public class Webcam
   @Lob @JdbcTypeCode(Types.BINARY)
   @Column(name="vue")
   private byte[] vue;
+  
+  
+  public Webcam() { }
+
+  @Transient
+  DateTimeFormatter df = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss", Locale.FRANCE);
+  
+  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 void setId(Integer id) { this.id = id; }
   public Integer getId() { return id; }

+ 7 - 10
src/main/java/fr/triplea/demovote/security/SecurityConfig.java

@@ -5,8 +5,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.support.ResourceBundleMessageSource;
 import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.ProviderManager;
 import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
-import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
 import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.core.session.SessionRegistry;
@@ -54,19 +54,16 @@ public class SecurityConfig
 
   @Bean
   public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(11); }
-
-  @Bean
-  public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception { return configuration.getAuthenticationManager(); }
-
+  
   @Bean
-  public DaoAuthenticationProvider authenticationProvider() 
+  public AuthenticationManager authenticationManager() throws Exception 
   {
     DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
-       
+    
     authProvider.setUserDetailsService(myUserDetailsService);
     authProvider.setPasswordEncoder(passwordEncoder());
-   
-    return authProvider;
+    
+    return new ProviderManager(authProvider);
   }
   
   @Bean
@@ -107,7 +104,7 @@ public class SecurityConfig
   {
     http.csrf(csrf -> csrf.csrfTokenRepository(csrfTokenRepository()))
         .requiresChannel(channel -> channel.anyRequest().requiresSecure())
-        .authenticationProvider(authenticationProvider())
+        .authenticationManager(authenticationManager())
         .authorizeHttpRequests((ahreq) -> ahreq
           .requestMatchers("/divers/**", "/sign/**", "/webcam/**").permitAll()
           .requestMatchers("/account/**", "/preference/**", "/message/**", "/urne/**", "/resultats/**").hasRole("USER")

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

@@ -75,7 +75,7 @@ public class CategorieController
       return ResponseEntity.ok(mt);
     }
 
-    return null;
+    return ResponseEntity.notFound().build();
   }
 
   @PutMapping(value = "/update/{id}")

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

@@ -44,6 +44,9 @@ public class DiversController
     jt.setJour3Court(variableRepository.findByTypeAndCode("Application", "LIBELLE_COURT_JOUR3"));
     jt.setJour3Long(variableRepository.findByTypeAndCode("Application", "LIBELLE_LONG_JOUR3"));
     
+    jt.setAmigabus(variableRepository.findByTypeAndCode("Application", "FLAG_AMIGABUS").equalsIgnoreCase("TRUE"));
+    jt.setDodosurplace(variableRepository.findByTypeAndCode("Application", "FLAG_DODOSURPLACE").equalsIgnoreCase("TRUE"));
+    
     return ResponseEntity.ok(jt); 
   }
 

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

@@ -255,7 +255,7 @@ public class ParticipantController
       }
     }
        
-    return null;
+    return ResponseEntity.notFound().build();
   }
 
   @PutMapping(value = "/update/{id}")

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

@@ -62,7 +62,9 @@ public class ProductionController
   @PreAuthorize("hasRole('USER')")
   public List<Production> getList(@RequestParam(required = false) String type, final Authentication authentication) 
   { 
-    List<ProductionShort> prods = productionRepository.findAllWithoutArchive(this.getNumeroUser(authentication));
+    if (type != null) { if (type.isBlank()) { type = null; } }
+
+    List<ProductionShort> prods = productionRepository.findAllWithoutArchive(this.getNumeroUser(authentication), type);
      
     List<Production> ret = new ArrayList<Production>();
     

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

@@ -86,7 +86,7 @@ public class VariableController
       return ResponseEntity.ok(mt);
     }
     
-    return null;
+    return ResponseEntity.notFound().build();
   }
  
   @PutMapping(value = "/update/{id}")

+ 0 - 4
src/main/java/fr/triplea/demovote/web/controller/WebcamController.java

@@ -63,14 +63,10 @@ public class WebcamController
   {
     if (webcam != null) 
     {
-      LOG.info(webcam.toString());
-      
       Webcam found = webcamRepository.find(webcam.getId()); 
 
       if (found != null)
       {
-        LOG.info(found.toString());
-        
         if (!(found.getCrc32()).equals(webcam.getCrc32()))
         {
           webcam.setCrc32(found.getCrc32());

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

@@ -4,7 +4,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/vote
 spring.datasource.username=vote
 spring.datasource.password=Atari$Impact2024
 spring.jpa.hibernate.ddl-auto=validate
-spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
 spring.jpa.open-in-view=false
 
 spring.messages.basename=messages,langs.messages