reajustement workflow #294
@@ -212,7 +212,7 @@ public class CampagneController {
|
|||||||
|
|
||||||
@GetMapping("/by-exercice-id/{exerciceId}")
|
@GetMapping("/by-exercice-id/{exerciceId}")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
||||||
public ResponseEntity<?> getCampagneByType(@PathVariable Long exerciceId) {
|
public ResponseEntity<?> getCampagneByExercice(@PathVariable Long exerciceId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -238,7 +238,7 @@ public class CampagneController {
|
|||||||
|
|
||||||
@GetMapping("/page/by-exercice-id/{exerciceId}")
|
@GetMapping("/page/by-exercice-id/{exerciceId}")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
||||||
public ResponseEntity<?> getCampagneByType(@PathVariable Long exerciceId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getCampagneByExercice(@PathVariable Long exerciceId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -261,5 +261,58 @@ public class CampagneController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/by-structure-id/{structureId}")
|
||||||
|
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
||||||
|
public ResponseEntity<?> getCampagneByStructure(@PathVariable Long structureId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, campagneService.getCampagneByStructureId(structureId), "Liste des campagne par type chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
|
FileStorageException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/page/by-structure-id/{structureId}")
|
||||||
|
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
||||||
|
public ResponseEntity<?> getCampagneByStructure(@PathVariable Long structureId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, campagneService.getCampagneByStructureId(structureId,pageable), "Liste des campagne par type chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
|
FileStorageException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||||||
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
||||||
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
import io.gmss.fiscad.enums.TypeCampagne;
|
import io.gmss.fiscad.enums.TypeCampagne;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -42,6 +43,9 @@ public class Campagne extends BaseEntity implements Serializable {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Exercice exercice ;
|
private Exercice exercice ;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Structure structure ;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ public class CampagneServiceImpl implements CampagneService {
|
|||||||
if (campagnePayloadWeb.getId() != null) {
|
if (campagnePayloadWeb.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer une nouvelle campgne ayant un id non null.");
|
throw new BadRequestException("Impossible de créer une nouvelle campgne ayant un id non null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Campagne campagne= entityFromPayLoadService.getCampagneFromPayLoadWeb(campagnePayloadWeb);
|
Campagne campagne= entityFromPayLoadService.getCampagneFromPayLoadWeb(campagnePayloadWeb);
|
||||||
campagne= campagneRepository.save(campagne);
|
campagne= campagneRepository.save(campagne);
|
||||||
|
|
||||||
@@ -88,5 +91,15 @@ public class CampagneServiceImpl implements CampagneService {
|
|||||||
public Page<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId, Pageable pageable) {
|
public Page<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId, Pageable pageable) {
|
||||||
return campagneRepository.findAllPayloadByExerciceId(exerciceId,pageable);
|
return campagneRepository.findAllPayloadByExerciceId(exerciceId,pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CampagnePayloadWeb> getCampagneByStructureId(Long structureId) {
|
||||||
|
return campagneRepository.findAllPayloadByStructureId(structureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CampagnePayloadWeb> getCampagneByStructureId(Long structureId, Pageable pageable) {
|
||||||
|
return campagneRepository.findAllPayloadByStructureId(structureId,pageable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public interface CampagneService {
|
|||||||
Optional<CampagnePayloadWeb> getCampagneById(Long id);
|
Optional<CampagnePayloadWeb> getCampagneById(Long id);
|
||||||
List<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId);
|
List<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId);
|
||||||
Page<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId,Pageable pageable);
|
Page<CampagnePayloadWeb> getCampagneByExerciceId(Long exerciceId,Pageable pageable);
|
||||||
|
List<CampagnePayloadWeb> getCampagneByStructureId(Long structureId);
|
||||||
|
Page<CampagnePayloadWeb> getCampagneByStructureId(Long structureId, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ public class CampagnePayloadWeb {
|
|||||||
private Long exerciceId ;
|
private Long exerciceId ;
|
||||||
private Integer exerciceAnnee ;
|
private Integer exerciceAnnee ;
|
||||||
|
|
||||||
public CampagnePayloadWeb(Long id, String refAdministrative, String nom, LocalDate dateDebut, LocalDate dateFin, TypeCampagne typeCampagne, Long exerciceId, Integer exerciceAnnee) {
|
private Long structureId ;
|
||||||
|
private String structureCode ;
|
||||||
|
private String structureNom ;
|
||||||
|
|
||||||
|
public CampagnePayloadWeb(Long id, String refAdministrative, String nom, LocalDate dateDebut, LocalDate dateFin, TypeCampagne typeCampagne, Long exerciceId, Integer exerciceAnnee, Long structureId, String structureCode, String structureNom) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.refAdministrative = refAdministrative;
|
this.refAdministrative = refAdministrative;
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
@@ -38,5 +42,8 @@ public class CampagnePayloadWeb {
|
|||||||
this.typeCampagne = typeCampagne;
|
this.typeCampagne = typeCampagne;
|
||||||
this.exerciceId = exerciceId;
|
this.exerciceId = exerciceId;
|
||||||
this.exerciceAnnee = exerciceAnnee;
|
this.exerciceAnnee = exerciceAnnee;
|
||||||
|
this.structureId = structureId;
|
||||||
|
this.structureCode = structureCode;
|
||||||
|
this.structureNom = structureNom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
c.dateFin,
|
c.dateFin,
|
||||||
c.typeCampagne,
|
c.typeCampagne,
|
||||||
e.id,
|
e.id,
|
||||||
e.annee
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
)
|
)
|
||||||
FROM Campagne c
|
FROM Campagne c
|
||||||
LEFT JOIN c.exercice e
|
LEFT JOIN c.exercice e
|
||||||
@@ -41,7 +44,10 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
c.dateFin,
|
c.dateFin,
|
||||||
c.typeCampagne,
|
c.typeCampagne,
|
||||||
e.id,
|
e.id,
|
||||||
e.annee
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
)
|
)
|
||||||
FROM Campagne c
|
FROM Campagne c
|
||||||
LEFT JOIN c.exercice e
|
LEFT JOIN c.exercice e
|
||||||
@@ -58,7 +64,10 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
c.dateFin,
|
c.dateFin,
|
||||||
c.typeCampagne,
|
c.typeCampagne,
|
||||||
e.id,
|
e.id,
|
||||||
e.annee
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
)
|
)
|
||||||
FROM Campagne c
|
FROM Campagne c
|
||||||
LEFT JOIN c.exercice e
|
LEFT JOIN c.exercice e
|
||||||
@@ -78,7 +87,10 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
c.dateFin,
|
c.dateFin,
|
||||||
c.typeCampagne,
|
c.typeCampagne,
|
||||||
e.id,
|
e.id,
|
||||||
e.annee
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
)
|
)
|
||||||
FROM Campagne c
|
FROM Campagne c
|
||||||
LEFT JOIN c.exercice e
|
LEFT JOIN c.exercice e
|
||||||
@@ -97,7 +109,10 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
c.dateFin,
|
c.dateFin,
|
||||||
c.typeCampagne,
|
c.typeCampagne,
|
||||||
e.id,
|
e.id,
|
||||||
e.annee
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
)
|
)
|
||||||
FROM Campagne c
|
FROM Campagne c
|
||||||
LEFT JOIN c.exercice e
|
LEFT JOIN c.exercice e
|
||||||
@@ -111,5 +126,57 @@ public interface CampagneRepository extends JpaRepository<Campagne, Long> {
|
|||||||
Page<CampagnePayloadWeb> findAllPayloadByExerciceId(
|
Page<CampagnePayloadWeb> findAllPayloadByExerciceId(
|
||||||
@Param("exerciceId") Long exerciceId,
|
@Param("exerciceId") Long exerciceId,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CampagnePayloadWeb(
|
||||||
|
c.id,
|
||||||
|
c.refAdministrative,
|
||||||
|
c.nom,
|
||||||
|
c.dateDebut,
|
||||||
|
c.dateFin,
|
||||||
|
c.typeCampagne,
|
||||||
|
e.id,
|
||||||
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
|
)
|
||||||
|
FROM Campagne c
|
||||||
|
LEFT JOIN c.exercice e
|
||||||
|
LEFT JOIN c.structure s
|
||||||
|
WHERE s.id = :structureId
|
||||||
|
ORDER BY c.dateDebut DESC
|
||||||
|
""")
|
||||||
|
List<CampagnePayloadWeb> findAllPayloadByStructureId(@Param("structureId") Long structureId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CampagnePayloadWeb(
|
||||||
|
c.id,
|
||||||
|
c.refAdministrative,
|
||||||
|
c.nom,
|
||||||
|
c.dateDebut,
|
||||||
|
c.dateFin,
|
||||||
|
c.typeCampagne,
|
||||||
|
e.id,
|
||||||
|
e.annee,
|
||||||
|
c.structure.id,
|
||||||
|
c.structure.code,
|
||||||
|
c.structure.nom
|
||||||
|
)
|
||||||
|
FROM Campagne c
|
||||||
|
LEFT JOIN c.exercice e
|
||||||
|
LEFT JOIN c.structure s
|
||||||
|
WHERE s.id = :structureId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(c)
|
||||||
|
FROM Campagne c
|
||||||
|
WHERE c.structure.id = :structureId
|
||||||
|
""")
|
||||||
|
Page<CampagnePayloadWeb> findAllPayloadByStructureId(
|
||||||
|
@Param("exerciceId") Long structureId,
|
||||||
|
Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1243,6 +1243,12 @@ public class EntityFromPayLoadService {
|
|||||||
campagne.setExercice(exercice);
|
campagne.setExercice(exercice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (campagnePayloadWeb.getStructureId() != null) {
|
||||||
|
Structure structure = new Structure();
|
||||||
|
structure.setId(campagnePayloadWeb.getStructureId());
|
||||||
|
campagne.setStructure(structure);
|
||||||
|
}
|
||||||
|
|
||||||
campagne.setId(campagnePayloadWeb.getId());
|
campagne.setId(campagnePayloadWeb.getId());
|
||||||
campagne.setDateDebut(campagnePayloadWeb.getDateDebut());
|
campagne.setDateDebut(campagnePayloadWeb.getDateDebut());
|
||||||
campagne.setDateFin(campagnePayloadWeb.getDateFin());
|
campagne.setDateFin(campagnePayloadWeb.getDateFin());
|
||||||
|
|||||||
Reference in New Issue
Block a user