rajah 11 месяцев назад
Родитель
Сommit
36e458bc14

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

@@ -11,7 +11,7 @@ import fr.triplea.demovote.model.Presentation;
 public interface PresentationRepository extends JpaRepository<Presentation, Integer> 
 {
   
-  @NativeQuery("SELECT DISTINCT MAX(p.numero_ordre) FROM vote.presentations AS p WHERE p.numero_categorie = :numero ")
+  @NativeQuery("SELECT DISTINCT CASE WHEN MAX(p.numero_ordre) IS NULL THEN 0 ELSE MAX(p.numero_ordre) END AS numero_ordre FROM vote.presentations AS p WHERE p.numero_categorie = :numero ")
   Integer countByCategorie(@Param("numero") int numeroCategorie);
   
   @NativeQuery("SELECT DISTINCT p.* FROM vote.presentations AS p WHERE p.numero_categorie = :numero_cat AND p.numero_production = :numero_prod ")

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

@@ -40,9 +40,10 @@ 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 ((:solo = 0) OR ((:solo = 1) AND p.numero_production NOT IN (SELECT DISTINCT s.numero_production FROM vote.presentations AS s))) "
               + "  AND ((:type IS NULL) OR (p.type = (:type)::vote.type_production)) "
               + "ORDER BY p.titre ASC ")
-  List<ProductionShort> findAllWithoutArchive(@Param("numero") int numeroGestionnaire, @Param("type") String type);
+  List<ProductionShort> findAllWithoutArchive(@Param("numero") int numeroGestionnaire, @Param("type") String type, @Param("solo") int solo);
   
   @NativeQuery("SELECT DISTINCT " 
               + "TO_CHAR(p.date_creation, 'DD/MM/YYYY HH24:MI:SS') as date_creation, "
@@ -67,6 +68,31 @@ public interface ProductionRepository extends JpaRepository<Production, Integer>
               + "WHERE p.numero_production = :numeroProduction "
               + "  AND p.flag_actif IS TRUE ")
   ProductionShort findByIdWithoutArchive(@Param("numeroProduction") Integer numeroProduction);
+  
+  @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_production, "
+              + "CAST(p.adresse_ip AS VARCHAR) AS adresse_ip, "
+              + "p.type, "
+              + "p.titre, "
+              + "p.auteurs, "
+              + "p.groupes, "
+              + "p.plateforme, "
+              + "p.commentaire, "
+              + "p.informations_privees, "
+              + "p.numero_participant AS numero_gestionnaire, "
+              + "CONCAT(g.pseudonyme, ' = ', g.nom, ' ', g.prenom) AS nom_gestionnaire, "
+              + "p.nom_archive, "
+              + "p.vignette, "
+              + "p.numero_version,"
+              + "s.numero_categorie "
+              + "FROM vote.productions AS p "
+              + "INNER JOIN vote.participants AS g ON p.numero_participant = g.numero_participant "
+              + "INNER JOIN vote.presentations AS s ON p.numero_production = s.numero_production "
+              + "WHERE p.flag_actif IS TRUE "
+              + "ORDER BY p.titre ASC ")
+  List<ProductionShort> findLinkedWithoutArchive();
 
   @NativeQuery("SELECT DISTINCT " 
       + "p.numero_production, "

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

@@ -4,6 +4,8 @@ package fr.triplea.demovote.dto;
 public class UserCredentials
 {
   
+  private int numeroParticipant;
+
   private String username;
   
   private String password;
@@ -24,6 +26,9 @@ public class UserCredentials
 
   public UserCredentials() {}
    
+  public void setNumeroParticipant(int n) { this.numeroParticipant = n; }
+  public int getNumeroParticipant() { return this.numeroParticipant; }
+
   public void setUsername(String s) { this.username = new String(s); }
   public String getUsername() { return this.username; }
 

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

@@ -105,6 +105,7 @@ public class AuthController
                 
         uc = new UserCredentials();
         
+        uc.setNumeroParticipant(found.getNumeroParticipant());
         uc.setUsername(usrn);
         uc.setPassword("<success@auth>");
         uc.setNom(found.getNom());
@@ -126,6 +127,7 @@ public class AuthController
       {
         uc = new UserCredentials();
         
+        uc.setNumeroParticipant(0);
         uc.setUsername("");
         uc.setPassword("");
         uc.setNom("");
@@ -142,6 +144,7 @@ public class AuthController
     
     uc = new UserCredentials();
     
+    uc.setNumeroParticipant(0);
     uc.setUsername("");
     uc.setPassword("");
     uc.setNom("");
@@ -191,6 +194,7 @@ public class AuthController
         
     UserCredentials uc = new UserCredentials();
     
+    uc.setNumeroParticipant(0);
     uc.setUsername("");
     uc.setPassword("");
     uc.setNom("");

+ 29 - 14
src/main/java/fr/triplea/demovote/web/controller/PresentationController.java

@@ -11,7 +11,6 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -22,6 +21,7 @@ import fr.triplea.demovote.dao.PresentationRepository;
 import fr.triplea.demovote.dao.ProductionRepository;
 import fr.triplea.demovote.dto.MessagesTransfer;
 import fr.triplea.demovote.dto.ProductionItem;
+import fr.triplea.demovote.dto.ProductionShort;
 import fr.triplea.demovote.model.Categorie;
 import fr.triplea.demovote.model.Presentation;
 import fr.triplea.demovote.model.Production;
@@ -32,8 +32,10 @@ import jakarta.servlet.http.HttpServletRequest;
 public class PresentationController 
 {
 
-  // TODO
-
+  // TODO version PDF imprimable pour MrBio (pour la répartition à la remise des lots pendant l'affichage des résultats)
+  // TODO version diaporama pour affichage sur écran de régie
+  // TODO raccourci 'ouvrir / fermer / calculer' les votes
+  
   @Autowired
   private PresentationRepository presentationRepository;
 
@@ -49,10 +51,23 @@ public class PresentationController
   @Autowired
   private MessageSource messageSource;
 
+  @GetMapping(value = "/list-all")
+  @PreAuthorize("hasRole('ADMIN')")
+  public List<Production> getProductionList() 
+  { 
+    List<ProductionShort> prods = productionRepository.findLinkedWithoutArchive();
+     
+    List<Production> ret = new ArrayList<Production>();
+    
+    if (prods != null) { if (prods.size() > 0) { for (ProductionShort prod: prods) { ret.add(prod.toProduction()); } } }
+    
+    return ret;  
+  }
+
   
   @GetMapping(value = "/list-linked/{id}")
   @PreAuthorize("hasRole('ADMIN')")
-  public List<ProductionItem> getProductionList(@PathVariable int id) 
+  public List<ProductionItem> getProductionListLinked(@PathVariable int id) 
   {
     List<ProductionItem> prods = productionRepository.findLinked(id); 
     
@@ -63,7 +78,7 @@ public class PresentationController
 
   @GetMapping(value = "/list-unlinked")
   @PreAuthorize("hasRole('ADMIN')")
-  public List<ProductionItem> getProductionList() 
+  public List<ProductionItem> getProductionListUnlinked() 
   {
     List<ProductionItem> prods = productionRepository.findUnlinked();
     
@@ -72,9 +87,9 @@ public class PresentationController
     return prods;
   }
 
-  @PutMapping(value = "/add")
+  @GetMapping(value = "/add")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Object> addProduction(@RequestParam(required = true) int numeroCategorie, @RequestParam(required = true) int numeroProduction, HttpServletRequest request) 
+  public ResponseEntity<Object> addProduction(@RequestParam("id_cat") int numeroCategorie, @RequestParam("id_prod") int numeroProduction, HttpServletRequest request) 
   {
     Locale locale = localeResolver.resolveLocale(request);
 
@@ -113,9 +128,9 @@ public class PresentationController
     return ResponseEntity.notFound().build(); 
   }
 
-  @PutMapping(value = "/remove")
+  @GetMapping(value = "/remove")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Object> removeProduction(@RequestParam(required = true) int numeroCategorie, @RequestParam(required = true) int numeroProduction, HttpServletRequest request) 
+  public ResponseEntity<Object> removeProduction(@RequestParam("id_cat") int numeroCategorie, @RequestParam("id_prod") int numeroProduction, HttpServletRequest request) 
   {
     Locale locale = localeResolver.resolveLocale(request);
 
@@ -144,9 +159,9 @@ public class PresentationController
     return ResponseEntity.notFound().build(); 
   }
 
-  @PutMapping(value = "/forward")
+  @GetMapping(value = "/up")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Object> avancerProduction(@RequestParam(required = true) int numeroCategorie, @RequestParam(required = true) int numeroProduction, HttpServletRequest request) 
+  public ResponseEntity<Object> avancerProduction(@RequestParam("id_cat") int numeroCategorie, @RequestParam("id_prod") int numeroProduction, HttpServletRequest request) 
   {
     Locale locale = localeResolver.resolveLocale(request);
 
@@ -171,7 +186,7 @@ public class PresentationController
             {
               if (presentations.get(i).getProduction().getNumeroProduction().equals(Integer.valueOf(Math.abs(numeroProduction))))
               {
-                if (i > 1) 
+                if (i > 0) 
                 {  
                   numeroOrdrePrev = presentations.get(i - 1).getNumeroOrdre();
                   numeroOrdreNext = presentations.get(i).getNumeroOrdre();
@@ -199,9 +214,9 @@ public class PresentationController
     return ResponseEntity.notFound().build(); 
   }
 
-  @PutMapping(value = "/backward")
+  @GetMapping(value = "/down")
   @PreAuthorize("hasRole('ADMIN')")
-  public ResponseEntity<Object> reculerProduction(@RequestParam(required = true) int numeroCategorie, @RequestParam(required = true) int numeroProduction, HttpServletRequest request) 
+  public ResponseEntity<Object> reculerProduction(@RequestParam("id_cat") int numeroCategorie, @RequestParam("id_prod") int numeroProduction, HttpServletRequest request) 
   {
     Locale locale = localeResolver.resolveLocale(request);
 

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

@@ -60,18 +60,19 @@ public class ProductionController
  
   @GetMapping(value = "/list")
   @PreAuthorize("hasRole('USER')")
-  public List<Production> getList(@RequestParam(required = false) String type, final Authentication authentication) 
+  public List<Production> getList(@RequestParam(required = false) String type, @RequestParam(required = false) Integer solo, final Authentication authentication) 
   { 
     if (type != null) { if (type.isBlank()) { type = null; } }
-
-    List<ProductionShort> prods = productionRepository.findAllWithoutArchive(this.getNumeroUser(authentication), type);
+    
+    if (solo != null) { solo = Math.max(0, Math.min(solo, 1)); } else { solo = 0; }  
+    
+    List<ProductionShort> prods = productionRepository.findAllWithoutArchive(this.getNumeroUser(authentication), type, solo);
      
     List<Production> ret = new ArrayList<Production>();
     
     if (prods != null) { if (prods.size() > 0) { for (ProductionShort prod: prods) { ret.add(prod.toProduction()); } } }
     
-    return ret; 
-    
+    return ret;  
   }
 
   @GetMapping(value = "/file/{id}")