Prechádzať zdrojové kódy

tri des prods (par titre ou par plus récent)

rajah 5 mesiacov pred
rodič
commit
3dfe3b9f7b

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

@@ -53,8 +53,37 @@ public interface ProductionRepository extends JpaRepository<Production, Integer>
               + "  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, @Param("solo") int solo);
+              + "ORDER BY p.titre, p.auteurs, p.groupes  ASC ")
+  List<ProductionShort> findAllWithoutArchiveOrderedByTitle(@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, "
+              + "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,"
+              + "0 AS numero_categorie, "
+              + "0 AS ordre_presentation, "
+              + "0 AS etat_media "
+              + "FROM vote.productions AS p "
+              + "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.numero_production DESC ")
+  List<ProductionShort> findAllWithoutArchiveOrderedByInvertedId(@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, "

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

@@ -86,13 +86,26 @@ public class ProductionController
  
   @GetMapping(value = "/list")
   @PreAuthorize("hasRole('USER')")
-  public List<Production> getList(@RequestParam(required = false) String type, @RequestParam(required = false) Integer solo, final Authentication authentication) 
+  public List<Production> getList(
+      @RequestParam(defaultValue="0") int tri, 
+      @RequestParam(required = false) String type, 
+      @RequestParam(required = false) Integer solo, 
+      final Authentication authentication) 
   { 
     if (type != null) { if (type.isBlank()) { type = null; } }
     
     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<ProductionShort> prods = null;
+    
+    if (tri == 1) 
+    {
+      prods = productionRepository.findAllWithoutArchiveOrderedByInvertedId(this.getNumeroUser(authentication), type, solo);
+    }
+    else 
+    {
+      prods = productionRepository.findAllWithoutArchiveOrderedByTitle(this.getNumeroUser(authentication), type, solo);
+    }
      
     List<Production> ret = new ArrayList<Production>();