Merge pull request 'develop' (#305) from develop into main
All checks were successful
CD - Deploy on main / deploy (push) Successful in 1m10s
All checks were successful
CD - Deploy on main / deploy (push) Successful in 1m10s
Reviewed-on: #305
This commit was merged in pull request #305.
This commit is contained in:
@@ -38,6 +38,8 @@ public class ExerciceController {
|
|||||||
@PreAuthorize("hasAuthority('CREATE_EXERCICE')")
|
@PreAuthorize("hasAuthority('CREATE_EXERCICE')")
|
||||||
public ResponseEntity<?> createExercice(@RequestBody @Valid @Validated Exercice exercice) {
|
public ResponseEntity<?> createExercice(@RequestBody @Valid @Validated Exercice exercice) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
exercice = exerciceService.createExercice(exercice);
|
exercice = exerciceService.createExercice(exercice);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, exercice, "Exercice créé avec succès."),
|
new ApiResponse<>(true, exercice, "Exercice créé avec succès."),
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ import java.time.LocalDate;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Where(clause = " deleted = false")
|
@Where(clause = " deleted = false")
|
||||||
|
@Table(
|
||||||
|
uniqueConstraints = {
|
||||||
|
@UniqueConstraint(name = "uk_exercice_annee", columnNames = "annee")
|
||||||
|
}
|
||||||
|
)
|
||||||
public class Exercice extends BaseEntity implements Serializable {
|
public class Exercice extends BaseEntity implements Serializable {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.gmss.fiscad.implementations.rfu.parametre;
|
package io.gmss.fiscad.implementations.rfu.parametre;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
||||||
|
import io.gmss.fiscad.exceptions.ApplicationException;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.rfu.parametre.ExerciceService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.ExerciceService;
|
||||||
@@ -22,8 +23,14 @@ public class ExerciceServiceImpl implements ExerciceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Exercice createExercice(Exercice exercice) throws BadRequestException {
|
public Exercice createExercice(Exercice exercice) throws BadRequestException {
|
||||||
if (exercice.getId() != null) {
|
if (exercice.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de créer une nouvelle campgne ayant un id non null.");
|
if (exerciceRepository.existsByAnnee(exercice.getAnnee())) {
|
||||||
|
throw new ApplicationException("Un exercice existe déjà pour l'année " + exercice.getAnnee() + ".");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (exerciceRepository.existsByAnneeAndIdNot(exercice.getAnnee(), exercice.getId())) {
|
||||||
|
throw new ApplicationException("Un exercice existe déjà pour l'année " + exercice.getAnnee() + ".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return exerciceRepository.save(exercice);
|
return exerciceRepository.save(exercice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ BEGIN
|
|||||||
AS
|
AS
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM dblink
|
FROM dblink
|
||||||
( 'host=193.181.208.4 port=5433 dbname=sigibe_test user=sigibe_test_user password=sigibe_test_pwd',
|
(
|
||||||
--v_conn,
|
v_conn,
|
||||||
format($SQL$
|
format($SQL$
|
||||||
SELECT
|
SELECT
|
||||||
exercice,
|
exercice,
|
||||||
@@ -55,7 +55,7 @@ BEGIN
|
|||||||
ilot,
|
ilot,
|
||||||
parcelle
|
parcelle
|
||||||
|
|
||||||
$SQL$, '08.1')--commune_id)
|
$SQL$, commune_id)
|
||||||
)
|
)
|
||||||
AS src
|
AS src
|
||||||
(
|
(
|
||||||
@@ -149,10 +149,9 @@ select left(code,4) as code_commune_fiscad, code as code_quartier_fiscad,nom as
|
|||||||
from quartier;
|
from quartier;
|
||||||
|
|
||||||
|
|
||||||
create or replace function get_dblink_connection_sigibe() returns text
|
create function get_dblink_connection_sigibe() returns text
|
||||||
language sql
|
language sql
|
||||||
as
|
as
|
||||||
$$
|
$$
|
||||||
SELECT 'host=193.181.208.4 port=5433 dbname=sigibe_test user=sigibe_test_user password=sigibe_test_pwd';
|
SELECT 'host=193.181.208.4 port=5433 dbname=sigibe_test user=sigibe_test_user password=sigibe_test_pwd';
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public interface ExerciceRepository extends JpaRepository<Exercice, Long> {
|
public interface ExerciceRepository extends JpaRepository<Exercice, Long> {
|
||||||
Optional<Exercice> findFirstByAnnee(int annee);
|
Optional<Exercice> findFirstByAnnee(int annee);
|
||||||
|
boolean existsByAnnee(Integer annee);
|
||||||
|
|
||||||
|
boolean existsByAnneeAndIdNot(Integer annee, Long id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,25 +88,26 @@ public interface AvoirFonctionRepository extends JpaRepository<AvoirFonction, Lo
|
|||||||
Page<AvoirFonctionPaylaodWeb> findAllAvoirFonctionToDtoPageable(Pageable pageable);
|
Page<AvoirFonctionPaylaodWeb> findAllAvoirFonctionToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
af.id,
|
af.id,
|
||||||
af.dateDebut,
|
af.dateDebut,
|
||||||
af.dateFin,
|
af.dateFin,
|
||||||
f.id,
|
f.id,
|
||||||
f.code,
|
f.code,
|
||||||
f.nom,
|
f.nom,
|
||||||
u.id,
|
u.id,
|
||||||
u.username,
|
u.username,
|
||||||
u.nom,
|
u.nom,
|
||||||
u.prenom,
|
u.prenom,
|
||||||
u.email,
|
u.email,
|
||||||
af.titre
|
af.titre
|
||||||
)
|
)
|
||||||
FROM AvoirFonction af
|
FROM AvoirFonction af
|
||||||
LEFT JOIN af.user u
|
LEFT JOIN af.user u
|
||||||
LEFT JOIN af.fonction f
|
LEFT JOIN af.fonction f
|
||||||
WHERE u.id = :userId
|
WHERE u.id = :userId
|
||||||
""")
|
AND (af.dateFin IS NULL OR af.dateFin >= CURRENT_DATE)
|
||||||
|
""")
|
||||||
List<AvoirFonctionPaylaodWeb> findAllAvoirFonctionByUserToDto(@Param("userId") Long userId);
|
List<AvoirFonctionPaylaodWeb> findAllAvoirFonctionByUserToDto(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user