Skip to content

Commit

Permalink
Ajout check demande en attente
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Jan 2, 2025
1 parent 443ca42 commit 2544073
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ public interface IDemandeExempDao extends JpaRepository<DemandeExemp, Integer> {

@Query("select d from DemandeExemp d where d.etatDemande.numEtat = 10 and (day(current_date) - day(d.dateModification)) > 210 order by d.dateModification asc")
List<DemandeExemp> getNextDemandeToDelete();

boolean existsDemandeExempByEtatDemande_Id(Integer etatDemande);

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ public interface IDemandeModifDao extends JpaRepository<DemandeModif, Integer> {

@Query("select d from DemandeModif d where d.etatDemande.numEtat = 10 and (day(current_date) - day(d.dateModification)) > 210 order by d.dateModification asc")
List<DemandeModif> getNextDemandeToDelete();

boolean existsDemandeModifByEtatDemande_Id(Integer etatDemande);

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IDemandeRecouvDao extends JpaRepository<DemandeRecouv, Integer>

@Query("select d from DemandeRecouv d where d.iln = :iln and d.etatDemande.numEtat not in (9, 10)")
List<DemandeRecouv> getAllActiveDemandesRecouvForAdmin(@Param("iln") String iln);

@Query("select d from DemandeRecouv d where d.etatDemande.numEtat not in (9, 10)")
List<DemandeRecouv> getAllActiveDemandesRecouvForAdminExtended();

Expand All @@ -49,4 +49,6 @@ public interface IDemandeRecouvDao extends JpaRepository<DemandeRecouv, Integer>

@Query("select d from DemandeRecouv d where d.etatDemande.numEtat = 10 and (day(current_date) - day(d.dateModification)) > 210 order by d.dateModification asc")
List<DemandeRecouv> getNextDemandeToDelete();

boolean existsDemandeRecouvByEtatDemande_Id(Integer etatDemande);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import fr.abes.item.core.configuration.ItemConfiguration;
import fr.abes.item.core.dto.DemandeDto;
import fr.abes.item.core.entities.item.DemandeSupp;
import fr.abes.item.core.entities.item.EtatDemande;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.validation.constraints.NotNull;
import java.util.List;

@Repository
Expand Down Expand Up @@ -49,4 +51,6 @@ public interface IDemandeSuppDao extends JpaRepository<DemandeSupp, Integer> {
@Query("select count(lf) from LigneFichierSupp lf where lf.demandeSupp.numDemande = :numDemande and lf.traitee=1 and lf.retourSudoc = 'exemplaire supprimé'")
int getNbLigneFichierSuccessByDemande(@Param("numDemande") Integer numDemande);

boolean existsDemandeSuppByEtatDemande_Id(Integer etatDemande);

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ public interface IDemandeService {

void refreshEntity(Demande demande);

Boolean checkDemandesEnAttente();
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,8 @@ public void cleanLignesFichierDemande(Demande demande) {
DemandeExemp demandeExemp = (DemandeExemp) demande;
ligneFichierService.deleteByDemande(demandeExemp);
}

public Boolean checkDemandesEnAttente(){
return demandeExempDao.existsDemandeExempByEtatDemande_Id(Constant.ETATDEM_ATTENTE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,8 @@ public void cleanLignesFichierDemande(Demande demande) {
public void refreshEntity(Demande demande) {
entityManager.refresh(demande);
}

public Boolean checkDemandesEnAttente(){
return demandeModifDao.existsDemandeModifByEtatDemande_Id(Constant.ETATDEM_ATTENTE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,8 @@ public void cleanLignesFichierDemande(Demande demande) {
public void refreshEntity(Demande demande) {
entityManager.refresh(demande);
}

public Boolean checkDemandesEnAttente(){
return demandeRecouvDao.existsDemandeRecouvByEtatDemande_Id(Constant.ETATDEM_ATTENTE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,4 @@ public void setIlnShortNameOnDemandesDto(List<DemandeDto> demandeDtoList) {
demandeDto.feedIlnAndShortname(listLibProfile);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,8 @@ public void cleanLignesFichierDemande(Demande demande) {
DemandeSupp demandeSupp = (DemandeSupp) demande;
ligneFichierService.deleteByDemande(demandeSupp);
}

public Boolean checkDemandesEnAttente(){
return demandeSuppDao.existsDemandeSuppByEtatDemande_Id(Constant.ETATDEM_ATTENTE);
}
}
7 changes: 7 additions & 0 deletions web/src/main/java/fr/abes/item/web/DemandeRestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,11 @@ public DemandeWebDto restaurerDemande(@PathVariable("type") TYPE_DEMANDE type, @
IDemandeService service = strategy.getStrategy(IDemandeService.class, type);
return builder.buildDemandeDto(service.restaurerDemande(service.findById(id)), type);
}

@GetMapping("/demandes/en-attente/{type}")
@PreAuthorize("permitAll()") // Permet l'accès à tous, authentifiés ou non
public Boolean checkDemandesEnAttente(@PathVariable("type") TYPE_DEMANDE type){
IDemandeService service = strategy.getStrategy(IDemandeService.class, type);
return service.checkDemandesEnAttente();
}
}

0 comments on commit 2544073

Please sign in to comment.