gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s

This commit is contained in:
2026-02-03 20:31:38 +01:00
parent 2c0aad4d51
commit 743bb46b47
23 changed files with 585 additions and 82 deletions

View File

@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Arrondissement")
@CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
//@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class ArrondissementController {
private final ArrondissementService arrondissementService;
@@ -175,7 +175,7 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."),
new ApiResponse<>(true, arrondissementService.getArrondissementById(id).orElse(null), "Arrondissement trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -199,7 +199,31 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
new ApiResponse<>(true, arrondissementService.getArrondissementListByCommuneId(communeId), "Liste des arrondissements par commune 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/commune/{communeId}")
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementListByCommuneId(communeId,pageable), "Liste des arrondissements par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Commune")
@CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class CommuneController {
private final CommuneService communeService;
@@ -185,7 +185,31 @@ public class CommuneController {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
new ApiResponse<>(true, communeService.getCommunesByDepartementId(departementId), "Liste des communes par département 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-departement-id/{departementId}")
public ResponseEntity<?> getCommuneByDepartementIdPaged(@PathVariable Long departementId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartementId(departementId,pageable), "Liste des communes par département chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Département")
@CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class DepartementController {
private final DepartementService departementService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Nationalité")
@CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class NationaliteController {
private final NationaliteService nationaliteService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Quartier")
@CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class QuartierController {
private final QuartierService quartierService;
@@ -158,7 +158,7 @@ public class QuartierController {
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."),
new ApiResponse<>(true, quartierService.getQuartierById(id).orElse(null), "Quartier trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -182,7 +182,31 @@ public class QuartierController {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
new ApiResponse<>(true, quartierService.getQuartierListByArrondissementId(arrondissementId), "Liste des quartiers par commune 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/arrondissement/{arrondissementId}")
public ResponseEntity<?> getQuartierByArrondissementPaged(@PathVariable Long arrondissementId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierListByArrondissementId(arrondissementId,pageable), "Liste des quartiers par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -6,6 +6,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -55,27 +56,28 @@ public class ArrondissementServiceImpl implements ArrondissementService {
}
@Override
public Page<Arrondissement> getArrondissementList(Pageable pageable) {
return arrondissementRepository.findAll(pageable);
public Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable) {
return arrondissementRepository.findAllArrondissementToDtoPageable(pageable);
}
@Override
public List<Arrondissement> getArrondissementList() {
return arrondissementRepository.findAll();
public List<ArrondissementPaylaodWeb> getArrondissementList() {
return arrondissementRepository.findAllArrondissementToDto();
}
@Override
public Optional<Arrondissement> getArrondissementById(Long id) {
return arrondissementRepository.findById(id);
public List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId) {
return arrondissementRepository.findAllArrondissementByCommuneToDto(communeId);
}
@Override
public List<Arrondissement> getArrondissementByComune(Long communeId) {
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
if (communeOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
}
return arrondissementRepository.findAllByCommune(communeOptional.get());
public Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId, Pageable pageable) {
return arrondissementRepository.findAllArrondissementByCommuneToDtoPageable(communeId,pageable);
}
@Override
public Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id) {
return arrondissementRepository.findArrondissementToDtoById(id);
}

View File

@@ -6,6 +6,8 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -55,27 +57,28 @@ public class CommuneServiceImpl implements CommuneService {
}
@Override
public Page<Commune> getCommuneList(Pageable pageable) {
return communeRepository.findAll(pageable);
}
@Override
public List<Commune> getCommuneList() {
return communeRepository.findAll();
public Page<CommunePaylaodWeb> getCommuneList(Pageable pageable) {
return communeRepository.findAllCommuneToDtoPageable(pageable);
}
@Override
public List<Commune> getCommunesByDepartement(Long departementId) {
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
if (departementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver le département spécifié.");
}
return communeRepository.findAllByDepartement(departementOptional.get());
public List<CommunePaylaodWeb> getCommuneList() {
return communeRepository.findAllCommuneToDto();
}
@Override
public Optional<Commune> getCommuneById(Long id) {
return communeRepository.findById(id);
public List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId) {
return communeRepository.findAllCommuneByDepartementToDto(departementId);
}
@Override
public Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId, Pageable pageable) {
return communeRepository.findAllCommuneByDepartementToDtoPageable(departementId,pageable);
}
@Override
public Optional<CommunePaylaodWeb> getCommuneById(Long id) {
return communeRepository.findCommuneToDtoById(id);
}
}

View File

@@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.DepartementRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -51,20 +52,20 @@ public class DepartementServiceImpl implements DepartementService {
}
@Override
public Page<Departement> getDepartementList(Pageable pageable) {
return departementRepository.findAll(pageable);
public Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable) {
return departementRepository.findAllDepartementToDtoPageable(pageable);
}
@Override
public List<Departement> getDepartementList() {
return departementRepository.findAll();
public List<DepartementPaylaodWeb> getDepartementList() {
return departementRepository.findAllDepartementToDto();
}
@Override
public Optional<Departement> getDepartementById(Long id) {
public Optional<DepartementPaylaodWeb> getDepartementById(Long id) {
if (departementRepository.existsById(id)) {
return departementRepository.findById(id);
return departementRepository.findDepartementToDtoById(id);
} else {
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
}

View File

@@ -6,6 +6,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -55,31 +56,28 @@ public class QuartierServiceImpl implements QuartierService {
}
@Override
public Page<Quartier> getQuartierList(Pageable pageable) {
return quartierRepository.findAll(pageable);
public Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable) {
return quartierRepository.findAllQuartierToDtoPageable(pageable);
}
@Override
public List<Quartier> getQuartierList() {
return quartierRepository.findAll();
public List<QuartierPaylaodWeb> getQuartierList() {
return quartierRepository.findAllQuartierToDto();
}
@Override
public Optional<Quartier> getQuartierById(Long id) {
if (quartierRepository.existsById(id)) {
return quartierRepository.findById(id);
} else {
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
}
public List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId) {
return quartierRepository.findAllQuartierByArrondissementToDto(arrondissementId);
}
@Override
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
if (arrondissementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
}
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
public Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId, Pageable pageable) {
return quartierRepository.findAllQuartierByArrondissementToDtoPageable(arrondissementId,pageable);
}
@Override
public Optional<QuartierPaylaodWeb> getQuartierById(Long id) {
return quartierRepository.findQuartierToDtoById(id);
}
}

View File

@@ -133,10 +133,7 @@ public class BlocServiceImpl implements BlocService {
@Override
public List<Bloc> getBlocsByArrondissement(Long idArrondissement) {
Arrondissement arrondissement = arrondissementService.getArrondissementById(idArrondissement).orElseThrow(() -> {
throw new NotFoundException("Impossible de trouver l'arrondissement");
});
return blocRepository.findAllByArrondissement(arrondissement);
return blocRepository.findAllByArrondissement_Id(idArrondissement);
}
@Override

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -17,11 +18,11 @@ public interface ArrondissementService {
void deleteArrondissement(Long id) throws NotFoundException;
Page<Arrondissement> getArrondissementList(Pageable pageable);
List<Arrondissement> getArrondissementList();
Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable);
List<ArrondissementPaylaodWeb> getArrondissementList();
List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId);
Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId,Pageable pageable);
Optional<Arrondissement> getArrondissementById(Long id);
List<Arrondissement> getArrondissementByComune(Long communeId);
Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id);
}

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -17,11 +18,12 @@ public interface CommuneService {
void deleteCommune(Long id) throws NotFoundException;
Page<Commune> getCommuneList(Pageable pageable);
Page<CommunePaylaodWeb> getCommuneList(Pageable pageable);
List<Commune> getCommuneList();
List<CommunePaylaodWeb> getCommuneList();
List<Commune> getCommunesByDepartement(Long departementId);
List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId);
Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId,Pageable pageable);
Optional<Commune> getCommuneById(Long id);
Optional<CommunePaylaodWeb> getCommuneById(Long id) ;
}

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -17,9 +18,9 @@ public interface DepartementService {
void deleteDepartement(Long id) throws NotFoundException;
Page<Departement> getDepartementList(Pageable pageable);
Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable);
List<Departement> getDepartementList();
List<DepartementPaylaodWeb> getDepartementList();
Optional<Departement> getDepartementById(Long id);
Optional<DepartementPaylaodWeb> getDepartementById(Long id);
}

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -17,11 +18,11 @@ public interface QuartierService {
void deleteQuartier(Long id) throws NotFoundException;
Page<Quartier> getQuartierList(Pageable pageable);
List<Quartier> getQuartierList();
Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable);
List<QuartierPaylaodWeb> getQuartierList();
List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId);
Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId,Pageable pageable);
Optional<Quartier> getQuartierById(Long id);
List<Quartier> getQuartierByArrondissement(Long arrondissementId);
Optional<QuartierPaylaodWeb> getQuartierById(Long id);
}

View File

@@ -0,0 +1,27 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
@Data
public class ArrondissementPaylaodWeb {
private Long id;
private String code;
private String nom;
private Long communeId;
private String communeCode;
private String communeNom;
public ArrondissementPaylaodWeb(Long id,
String code,
String nom,
Long communeId,
String communeCode,
String communeNom) {
this.id = id;
this.code = code;
this.nom = nom;
this.communeId = communeId;
this.communeCode = communeCode;
this.communeNom = communeNom;
}
}

View File

@@ -0,0 +1,22 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
@Data
public class CommunePaylaodWeb {
private Long id;
private String code;
private String nom;
private Long departementId;
private String departementCode;
private String departementNom;
public CommunePaylaodWeb(Long id, String code, String nom, Long departementId,String departementCode, String departementNom) {
this.id = id;
this.code = code;
this.nom = nom;
this.departementId = departementId;
this.departementCode = departementCode;
this.departementNom = departementNom;
}
}

View File

@@ -0,0 +1,18 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
import java.time.LocalDate;
@Data
public class DepartementPaylaodWeb {
private Long id;
private String code;
private String nom;
public DepartementPaylaodWeb(Long id, String code, String nom) {
this.id = id;
this.code = code;
this.nom = nom;
}
}

View File

@@ -0,0 +1,27 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import lombok.Data;
@Data
public class QuartierPaylaodWeb {
private Long id;
private String code;
private String nom;
private Long arrondissementId;
private String arrondissementCode;
private String arrondissementNom;
public QuartierPaylaodWeb(Long id,
String code,
String nom,
Long arrondissementId,
String arrondissementCode,
String arrondissementNom) {
this.id = id;
this.code = code;
this.nom = nom;
this.arrondissementId = arrondissementId;
this.arrondissementCode = arrondissementCode;
this.arrondissementNom = arrondissementNom;
}
}

View File

@@ -2,12 +2,17 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
import io.gmss.fiscad.paylaods.response.synchronisation.ArrondissementSyncResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
List<Arrondissement> findAllByCommune(Commune commune);
@@ -33,4 +38,94 @@ public interface ArrondissementRepository extends JpaRepository<Arrondissement,
" where sa.structure_id = ?1 )T " +
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
arr.id,
arr.code,
arr.nom,
com.id,
com.code,
com.nom
)
FROM Arrondissement arr
LEFT JOIN arr.commune com
""")
List<ArrondissementPaylaodWeb> findAllArrondissementToDto();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
arr.id,
arr.code,
arr.nom,
com.id,
com.code,
com.nom
)
FROM Arrondissement arr
LEFT JOIN arr.commune com
WHERE arr.id = :arrondissementId
""")
Optional<ArrondissementPaylaodWeb> findArrondissementToDtoById(@Param("arrondissementId") Long arrondissementId);
@Query(
value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
arr.id,
arr.code,
arr.nom,
com.id,
com.code,
com.nom
)
FROM Arrondissement arr
LEFT JOIN arr.commune com
""",
countQuery = """
SELECT COUNT(DISTINCT arr.id)
FROM Arrondissement arr
LEFT JOIN arr.commune com
"""
)
Page<ArrondissementPaylaodWeb> findAllArrondissementToDtoPageable(Pageable pageable);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
arr.id,
arr.code,
arr.nom,
com.id,
com.code,
com.nom
)
FROM Arrondissement arr
LEFT JOIN arr.commune com
WHERE arr.commune.id = :communeId
""")
List<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDto(@Param("communeId") Long communeId);
@Query(value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
arr.id,
arr.code,
arr.nom,
com.id,
com.code,
com.nom
)
FROM Arrondissement arr
LEFT JOIN arr.commune com
WHERE arr.commune.id = :communeId
""",
countQuery = """
SELECT COUNT(DISTINCT arr.id)
FROM Arrondissement arr
LEFT JOIN arr.commune com
WHERE arr.commune.id = :communeId
""")
Page<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDtoPageable(@Param("communeId") Long communeId, Pageable pageable);
}

View File

@@ -2,12 +2,17 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
import io.gmss.fiscad.paylaods.response.CommuneEnqResponse;
import io.gmss.fiscad.paylaods.response.synchronisation.CommuneSyncResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface CommuneRepository extends JpaRepository<Commune, Long> {
@@ -15,7 +20,7 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
List<CommuneSyncResponse> getCommuneResponse();
List<Commune> findAllByDepartement(Departement departement);
List<Commune> findAllByDepartement_Id(Long departementId);
@Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
" From (select distinct c.id as id,c.code as code, c.nom as libelle, c.longitude,c.latitude, e.id as enqueteId from arrondissement a" +
@@ -37,4 +42,95 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
" group by T.id,T.code, T.libelle,T.longitude,T.latitude",nativeQuery = true)
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
com.id,
com.code,
com.nom,
dep.id,
dep.code,
dep.nom
)
FROM Commune com
LEFT JOIN com.departement dep
""")
List<CommunePaylaodWeb> findAllCommuneToDto();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
com.id,
com.code,
com.nom,
dep.id,
dep.code,
dep.nom
)
FROM Commune com
LEFT JOIN com.departement dep
WHERE com.id = :idCommune
""")
Optional<CommunePaylaodWeb> findCommuneToDtoById(@Param("idCommune") Long idCommune);
@Query(
value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
com.id,
com.code,
com.nom,
dep.id,
dep.code,
dep.nom
)
FROM Commune com
LEFT JOIN com.departement dep
""",
countQuery = """
SELECT COUNT(DISTINCT com.id)
FROM Commune com
LEFT JOIN com.departement dep
"""
)
Page<CommunePaylaodWeb> findAllCommuneToDtoPageable(Pageable pageable);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
com.id,
com.code,
com.nom,
dep.id,
dep.code,
dep.nom
)
FROM Commune com
LEFT JOIN com.departement dep
WHERE com.departement.id = :departementId
""")
List<CommunePaylaodWeb> findAllCommuneByDepartementToDto(@Param("departementId") Long departementId);
@Query(value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
com.id,
com.code,
com.nom,
dep.id,
dep.code,
dep.nom
)
FROM Commune com
LEFT JOIN com.departement dep
WHERE com.departement.id = :departementId
""",
countQuery = """
SELECT COUNT(DISTINCT com.id)
FROM Commune com
LEFT JOIN com.departement dep
WHERE com.departement.id = :departementId
""")
Page<CommunePaylaodWeb> findAllCommuneByDepartementToDtoPageable(@Param("departementId") Long departementId, Pageable pageable);
}

View File

@@ -1,11 +1,16 @@
package io.gmss.fiscad.persistence.repositories.decoupage;
import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import io.gmss.fiscad.paylaods.response.synchronisation.DepartementSyncResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface DepartementRepository extends JpaRepository<Departement, Long> {
@@ -14,4 +19,44 @@ public interface DepartementRepository extends JpaRepository<Departement, Long>
" where departement.deleted is false ", nativeQuery = true)
List<DepartementSyncResponse> getDepartementResponse();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
dep.id,
dep.code,
dep.nom
)
FROM Departement dep
""")
List<DepartementPaylaodWeb> findAllDepartementToDto();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
dep.id,
dep.code,
dep.nom
)
FROM Departement dep
WHERE dep.id = :idDepartement
""")
Optional<DepartementPaylaodWeb> findDepartementToDtoById(@Param("idDepartement") Long idDepartement);
@Query(
value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
dep.id,
dep.code,
dep.nom
)
FROM Departement dep
""",
countQuery = """
SELECT COUNT(DISTINCT dep.id)
FROM Departement dep
"""
)
Page<DepartementPaylaodWeb> findAllDepartementToDtoPageable(Pageable pageable);
}

View File

@@ -2,11 +2,16 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
import io.gmss.fiscad.paylaods.response.synchronisation.QuartierSyncResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
@@ -23,5 +28,94 @@ public interface QuartierRepository extends JpaRepository<Quartier, Long> {
" where q.deleted is false ", nativeQuery = true)
List<QuartierSyncResponse> getAdminQuartierResponse();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
qua.id,
qua.code,
qua.nom,
arr.id,
arr.code,
arr.nom
)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
""")
List<QuartierPaylaodWeb> findAllQuartierToDto();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
qua.id,
qua.code,
qua.nom,
arr.id,
arr.code,
arr.nom
)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
WHERE qua.id = :idQuartier
""")
Optional<QuartierPaylaodWeb> findQuartierToDtoById(@Param("idQuartier") Long idQuartier);
@Query(
value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
qua.id,
qua.code,
qua.nom,
arr.id,
arr.code,
arr.nom
)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
""",
countQuery = """
SELECT COUNT(DISTINCT qua.id)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
"""
)
Page<QuartierPaylaodWeb> findAllQuartierToDtoPageable(Pageable pageable);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
qua.id,
qua.code,
qua.nom,
arr.id,
arr.code,
arr.nom
)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
WHERE qua.arrondissement.id = :arrondissementId
""")
List<QuartierPaylaodWeb> findAllQuartierByArrondissementToDto(@Param("arrondissementId") Long arrondissementId);
@Query(value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
qua.id,
qua.code,
qua.nom,
arr.id,
arr.code,
arr.nom
)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
WHERE qua.arrondissement.id = :arrondissementId
""",
countQuery = """
SELECT COUNT(DISTINCT qua.id)
FROM Quartier qua
LEFT JOIN qua.arrondissement arr
WHERE qua.arrondissement.id = :arrondissementId
""")
Page<QuartierPaylaodWeb> findAllQuartierByArrondissementToDtoPageable(@Param("arrondissementId") Long arrondissementId, Pageable pageable);
}

View File

@@ -36,6 +36,7 @@ public interface BlocRepository extends JpaRepository<Bloc, Long> {
List<BlocsParStructureResponse> getBlocsParStructureResponse(Long structure_id);
List<Bloc> findAllByArrondissement(Arrondissement arrondissement);
List<Bloc> findAllByArrondissement_Id(Long arrondissementId);
@Query(value = "select structure_id as id from arrondissements_structures " +
" where arrondissement_id = ?1" +