Compare commits
8 Commits
b3c288628c
...
features/c
| Author | SHA1 | Date | |
|---|---|---|---|
| 95eb4ad0b9 | |||
| 743bb46b47 | |||
| 2c0aad4d51 | |||
| fc6ff679f0 | |||
| 772f870dbd | |||
| 1c63303f3c | |||
| 9a118b41e5 | |||
| c65fd8a450 |
@@ -3,8 +3,8 @@ package io.gmss.fiscad.component;
|
|||||||
import io.gmss.fiscad.entities.user.Role;
|
import io.gmss.fiscad.entities.user.Role;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
import io.gmss.fiscad.enums.UserRole;
|
||||||
import io.gmss.fiscad.repositories.user.RoleRepository;
|
import io.gmss.fiscad.persistence.repositories.user.RoleRepository;
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
@@ -42,17 +42,13 @@ public class DataLoadConfig {
|
|||||||
|
|
||||||
|
|
||||||
public void loadRoles() {
|
public void loadRoles() {
|
||||||
|
|
||||||
if (roleRepository.count() > 0) return;
|
if (roleRepository.count() > 0) return;
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
roles.add(new Role(UserRole.ROLE_USER, "Role attribué aux utilisateurs simples."));
|
roles.add(new Role(UserRole.CREATE_USER, "Peut créer un utilisation."));
|
||||||
roles.add(new Role(UserRole.ROLE_ADMIN, "Role attribué aux administrateurs du système."));
|
roles.add(new Role(UserRole.READ_USER, "peut lire un utilisation"));
|
||||||
roles.add(new Role(UserRole.ROLE_DIRECTEUR, "Role attribué aux directeurs des structures."));
|
roles.add(new Role(UserRole.UPDATE_USER, "peut modifier un utilisation"));
|
||||||
roles.add(new Role(UserRole.ROLE_SUPERVISEUR, "Role attribué aux superviseurs des structures sur le terrain."));
|
roles.add(new Role(UserRole.DELETE_USER, "peut supprimer un utilisation"));
|
||||||
roles.add(new Role(UserRole.ROLE_ENQUETEUR, "Role attribué aux enquêteurs des structures sur le terrain."));
|
|
||||||
roles.add(new Role(UserRole.ROLE_ANONYMOUS, "Role attribué à toutes les personnes qui s'inscrivent en ligne pour le compte d'une structure."));
|
|
||||||
roleRepository.saveAll(roles);
|
roleRepository.saveAll(roles);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUsers() {
|
public void loadUsers() {
|
||||||
@@ -65,9 +61,6 @@ public class DataLoadConfig {
|
|||||||
admin.setPrenom("Principal");
|
admin.setPrenom("Principal");
|
||||||
admin.setPassword(passwordEncoder.encode(passwordFile));
|
admin.setPassword(passwordEncoder.encode(passwordFile));
|
||||||
admin.setActive(true);
|
admin.setActive(true);
|
||||||
Set<Role> roles = new HashSet<>();
|
|
||||||
roles.add(roleRepository.findRoleByNom(UserRole.ROLE_ADMIN).get());
|
|
||||||
admin.setRoles(roles);
|
|
||||||
userRepository.save(admin);
|
userRepository.save(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.gmss.fiscad.configuration;
|
package io.gmss.fiscad.configuration;
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.domain.AuditorAware;
|
import org.springframework.data.domain.AuditorAware;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.gmss.fiscad.configuration;
|
package io.gmss.fiscad.configuration;
|
||||||
|
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import io.gmss.fiscad.security.UserPrincipal;
|
import io.gmss.fiscad.security.UserPrincipal;
|
||||||
import org.springframework.data.domain.AuditorAware;
|
import org.springframework.data.domain.AuditorAware;
|
||||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Arrondissement")
|
@Tag(name = "Arrondissement")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class ArrondissementController {
|
public class ArrondissementController {
|
||||||
|
|
||||||
private final ArrondissementService arrondissementService;
|
private final ArrondissementService arrondissementService;
|
||||||
@@ -175,7 +175,7 @@ public class ArrondissementController {
|
|||||||
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -199,7 +199,31 @@ public class ArrondissementController {
|
|||||||
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Commune")
|
@Tag(name = "Commune")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class CommuneController {
|
public class CommuneController {
|
||||||
|
|
||||||
private final CommuneService communeService;
|
private final CommuneService communeService;
|
||||||
@@ -185,7 +185,31 @@ public class CommuneController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Département")
|
@Tag(name = "Département")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class DepartementController {
|
public class DepartementController {
|
||||||
|
|
||||||
private final DepartementService departementService;
|
private final DepartementService departementService;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Nationalité")
|
@Tag(name = "Nationalité")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class NationaliteController {
|
public class NationaliteController {
|
||||||
|
|
||||||
private final NationaliteService nationaliteService;
|
private final NationaliteService nationaliteService;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Quartier")
|
@Tag(name = "Quartier")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class QuartierController {
|
public class QuartierController {
|
||||||
|
|
||||||
private final QuartierService quartierService;
|
private final QuartierService quartierService;
|
||||||
@@ -158,7 +158,7 @@ public class QuartierController {
|
|||||||
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
|
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -182,7 +182,31 @@ public class QuartierController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import io.gmss.fiscad.entities.decoupage.Secteur;
|
|||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
|
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -24,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
//@SecurityRequirement(name = "bearer")
|
//@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Secteur")
|
@Tag(name = "Secteur")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class SecteurController {
|
public class SecteurController {
|
||||||
|
|
||||||
private final SecteurService secteurService;
|
private final SecteurService secteurService;
|
||||||
@@ -34,14 +36,16 @@ public class SecteurController {
|
|||||||
this.secteurService = secteurService;
|
this.secteurService = secteurService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "Créer un secteur",
|
||||||
|
description = "Permet de Créer un secteur"
|
||||||
|
)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) {
|
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPaylaodWeb secteurPaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
// Secteur secteur=getSecteurFromPayload(secteurPayload);
|
secteurPaylaodWeb = secteurService.createSecteur(secteurPaylaodWeb);
|
||||||
Secteur secteur = secteurService.createSecteur(secteurPayload);
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteur, "Secteur créé avec succès."),
|
new ApiResponse<>(true, secteurPaylaodWeb, "Secteur créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -60,12 +64,15 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "mettre à jour un secteur",
|
||||||
|
description = "Permet de modifier un secteur"
|
||||||
|
)
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) {
|
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPaylaodWeb secteurPayloadWeb) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."),
|
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayloadWeb), "Secteur mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -83,7 +90,10 @@ public class SecteurController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "supprimer un secteur",
|
||||||
|
description = "Permet de supprimer un secteur"
|
||||||
|
)
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
@@ -107,7 +117,10 @@ public class SecteurController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs"
|
||||||
|
)
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
public ResponseEntity<?> getAllSecteurList() {
|
public ResponseEntity<?> getAllSecteurList() {
|
||||||
try {
|
try {
|
||||||
@@ -131,6 +144,10 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs avec pagination",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs avec pagination"
|
||||||
|
)
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
@@ -155,6 +172,10 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer un secteurs par son ID ",
|
||||||
|
description = "Permet de récuperer le secteur ayant l'ID fournie en path"
|
||||||
|
)
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
@@ -178,12 +199,15 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs d'une structure",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs de la structure dont l'ID est fourni en path"
|
||||||
|
)
|
||||||
@GetMapping("/by-structure-id/{structureId}")
|
@GetMapping("/by-structure-id/{structureId}")
|
||||||
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
|
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurService.getSecteurListUneStruture(structureId), "Secteur trouvée avec succès."),
|
new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId), "Secteur trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -203,4 +227,92 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs d'une structure",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs de la structure dont l'ID est fourni en path avec pagination"
|
||||||
|
)
|
||||||
|
@GetMapping("/page/by-structure-id/{structureId}")
|
||||||
|
public ResponseEntity<?> getSecteurByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId,pageable), "Secteur trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs d'une section",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path"
|
||||||
|
)
|
||||||
|
@GetMapping("/by-section-id/{sectionId}")
|
||||||
|
public ResponseEntity<?> getSecteurBySectionId(@PathVariable Long sectionId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId), "Secteur trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les secteurs d'une section avec pagination",
|
||||||
|
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path avec pagination"
|
||||||
|
)
|
||||||
|
@GetMapping("/page/by-section-id/{sectionId}")
|
||||||
|
public ResponseEntity<?> getSecteurBySectionIdPage(@PathVariable Long sectionId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId,pageable), "Secteur trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,13 @@ package io.gmss.fiscad.controllers.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||||
|
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@@ -18,29 +21,26 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
@AllArgsConstructor
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/secteur-decoupage", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/secteur-decoupage", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "SecteurDecoupage")
|
@Tag(name = "SecteurDecoupage")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class SecteurDecoupageController {
|
public class SecteurDecoupageController {
|
||||||
|
|
||||||
private final SecteurDecoupageService secteurDecoupageService;
|
private final SecteurDecoupageService secteurDecoupageService;
|
||||||
|
private final SecteurService secteurService;
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
|
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
|
||||||
|
|
||||||
public SecteurDecoupageController(SecteurDecoupageService secteurDecoupageService) {
|
|
||||||
this.secteurDecoupageService = secteurDecoupageService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
|
secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
|
new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -60,10 +60,10 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
|
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
|
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -153,11 +153,82 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/by-secteur-id/{secteurId}")
|
||||||
|
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurId(@PathVariable Long secteurId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId), "Liste des secteurDecoupages 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-secteur-decoupage-id/{secteurId}")
|
||||||
|
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurIdPaged(@PathVariable Long secteurId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId,pageable), "Liste des secteurDecoupages 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("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
|
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvé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("/arbre/user-id/{userId}")
|
||||||
|
public ResponseEntity<?> getArborescenceByUserId(@PathVariable Long userId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, secteurDecoupageService.getStatParcelleDecoupageByUserId(userId), "SecteurDecoupage trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
package io.gmss.fiscad.controllers.decoupage;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.exceptions.*;
|
||||||
|
import io.gmss.fiscad.interfaces.decoupage.SectionService;
|
||||||
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SectionPaylaodWeb;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "api/section", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
//@SecurityRequirement(name = "bearer")
|
||||||
|
@Tag(name = "Section")
|
||||||
|
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
|
public class SectionController {
|
||||||
|
|
||||||
|
private final SectionService sectionService;
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SectionController.class);
|
||||||
|
|
||||||
|
public SectionController(SectionService sectionService) {
|
||||||
|
this.sectionService = sectionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "Créer un section",
|
||||||
|
description = "Permet de Créer un section"
|
||||||
|
)
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createSection(@RequestBody @Valid @Validated SectionPaylaodWeb sectionPaylaodWeb) {
|
||||||
|
try {
|
||||||
|
sectionPaylaodWeb = sectionService.createSection(sectionPaylaodWeb);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionPaylaodWeb, "Section créé 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "mettre à jour un section",
|
||||||
|
description = "Permet de modifier un section"
|
||||||
|
)
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateSection(@PathVariable Long id, @RequestBody SectionPaylaodWeb sectionPayloadWeb) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.updateSection(id, sectionPayloadWeb), "Section mis à jour 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "supprimer un section",
|
||||||
|
description = "Permet de supprimer un section"
|
||||||
|
)
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<?> deleteSection(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
sectionService.deleteSection(id);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, "Section supprimé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les sections",
|
||||||
|
description = "Permet de récuperer l'ensemble des sections"
|
||||||
|
)
|
||||||
|
@GetMapping("/all")
|
||||||
|
public ResponseEntity<?> getAllSectionList() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.getSectionList(), "Liste des sections 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les sections avec pagination",
|
||||||
|
description = "Permet de récuperer l'ensemble des sections avec pagination"
|
||||||
|
)
|
||||||
|
@GetMapping("/all-paged")
|
||||||
|
public ResponseEntity<?> getAllSectionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.getSectionList(pageable), "Liste des sections 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer un sections par son ID ",
|
||||||
|
description = "Permet de récuperer le section ayant l'ID fournie en path"
|
||||||
|
)
|
||||||
|
@GetMapping("/id/{id}")
|
||||||
|
public ResponseEntity<?> getSectionById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.getSectionById(id).orElse(null), "Section trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les sections d'une structure",
|
||||||
|
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path"
|
||||||
|
)
|
||||||
|
@GetMapping("/by-structure-id/{structureId}")
|
||||||
|
public ResponseEntity<?> getSectionByStructureId(@PathVariable Long structureId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId), "Section trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "recuperer tous les sections d'une structure",
|
||||||
|
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path avec pagination"
|
||||||
|
)
|
||||||
|
@GetMapping("/page/by-structure-id/{structureId}")
|
||||||
|
public ResponseEntity<?> getSectionByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId,pageable), "Section trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
|||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
|
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
||||||
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -207,6 +208,35 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "Récupérer les enquetes d'une parcelle",
|
||||||
|
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
|
||||||
|
)
|
||||||
|
@GetMapping("/all/by-parcelle-id/{parcelleId}")
|
||||||
|
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin(@PathVariable Long parcelleId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes 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("/all/dgi/decoupage-admin-for-enquete")
|
@GetMapping("/all/dgi/decoupage-admin-for-enquete")
|
||||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
package io.gmss.fiscad.controllers.infocad.metier;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
||||||
|
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
||||||
|
import io.gmss.fiscad.exceptions.*;
|
||||||
|
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
|
||||||
|
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
|
||||||
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
||||||
|
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@SecurityRequirement(name = "bearer")
|
||||||
|
@Tag(name = "Parcelle")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
|
public class ParcelleController {
|
||||||
|
|
||||||
|
private final EnqueteService enqueteService;
|
||||||
|
private final ParcelleService parcelleService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ParcelleController.class);
|
||||||
|
|
||||||
|
public ParcelleController(EnqueteService enqueteService, ParcelleService parcelleService) {
|
||||||
|
this.enqueteService = enqueteService;
|
||||||
|
this.parcelleService = parcelleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
|
||||||
|
try {
|
||||||
|
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelle, "parcelle créé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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateEnquete(@PathVariable Long id, @RequestBody ParcellePayLoadWeb parcellePayLoadWeb) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleService.updateParcelle(id,parcellePayLoadWeb), "parcelle mise à jour 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
parcelleService.deleteParcelle(id);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, "parcelle supprimé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("/all")
|
||||||
|
public ResponseEntity<?> getAllParcelle() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleService.getParcelleList(), "Liste des enquetes 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("/all/by-decoupage")
|
||||||
|
public ResponseEntity<?> getAllByDecoupage() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes 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("/all-paged")
|
||||||
|
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleService.getParcelleList(pageable), "Liste des enquetes 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("/id/{id}")
|
||||||
|
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé 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("/user-id/{userId}")
|
||||||
|
public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.metier.Upload;
|
|||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.JobModels;
|
import io.gmss.fiscad.paylaods.JobModels;
|
||||||
import io.gmss.fiscad.proprietes.ZipStorageProperties;
|
import io.gmss.fiscad.proprietes.ZipStorageProperties;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.service.FileStorageService;
|
import io.gmss.fiscad.service.FileStorageService;
|
||||||
import io.gmss.fiscad.service.StringManager;
|
import io.gmss.fiscad.service.StringManager;
|
||||||
import io.gmss.fiscad.service.ZipAsyncService;
|
import io.gmss.fiscad.service.ZipAsyncService;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.gmss.fiscad.exceptions.*;
|
|||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -27,7 +28,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Structure")
|
@Tag(name = "Structure")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public class StructureController {
|
public class StructureController {
|
||||||
|
|
||||||
private final StructureService structureService;
|
private final StructureService structureService;
|
||||||
@@ -40,11 +41,11 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
|
public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
structure = structureService.createStructure(structure);
|
structurePaylaodWeb = structureService.createStructure(structurePaylaodWeb);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, structure, "Structure créé avec succès."),
|
new ApiResponse<>(true, structurePaylaodWeb, "Structure créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -64,10 +65,10 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) {
|
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."),
|
new ApiResponse<>(true, structureService.updateStructure(id, structurePaylaodWeb), "Structure mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -134,36 +135,6 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-by-arrondissement")
|
|
||||||
public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) {
|
|
||||||
try {
|
|
||||||
if (arrondissementService.getArrondissementById(arrondissementId).isPresent()) {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, structureService.getStructuresByArrondissement(arrondissementId), "Liste des structures chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, "Impossible de trouver l'arrondissement spécifiée."),
|
|
||||||
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("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
@@ -189,6 +160,53 @@ public class StructureController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/by-commune/{communeId}")
|
||||||
|
public ResponseEntity<?> getAllStructureListByCommune(@PathVariable Long communeId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId), "Liste des structures 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-commune/{communeId}")
|
||||||
|
public ResponseEntity<?> getAllStructureListByCommunePageable(@PathVariable Long communeId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId,pageable), "Liste des structures 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("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ package io.gmss.fiscad.controllers.report;
|
|||||||
|
|
||||||
import io.gmss.fiscad.enums.FormatRapport;
|
import io.gmss.fiscad.enums.FormatRapport;
|
||||||
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
||||||
import io.gmss.fiscad.service.ReportService;
|
import io.gmss.fiscad.service.ReportService;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.gmss.fiscad.enums.StatusAvis;
|
|||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
|
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.gmss.fiscad.paylaods.ApiResponse;
|
|||||||
import io.gmss.fiscad.paylaods.JwtAuthenticationResponse;
|
import io.gmss.fiscad.paylaods.JwtAuthenticationResponse;
|
||||||
import io.gmss.fiscad.paylaods.Login;
|
import io.gmss.fiscad.paylaods.Login;
|
||||||
import io.gmss.fiscad.paylaods.UserRequest;
|
import io.gmss.fiscad.paylaods.UserRequest;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -90,13 +91,13 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/signup")
|
@PostMapping("/signup")
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) {
|
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
User user = getUser(userRequest);
|
//User user = getUser(userRequest);
|
||||||
user.setUsername(userRequest.getEmail());
|
//user.setUsername(userRequest.getEmail());
|
||||||
user = userService.createUser(user, true);
|
userPaylaodWeb = userService.createUser(userPaylaodWeb);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, user, "Inscription effectué avec succès."),
|
new ApiResponse<>(true, userPaylaodWeb, "Inscription effectué avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -115,19 +116,5 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User getUser(UserRequest userRequest) {
|
|
||||||
User user = new User();
|
|
||||||
user.setNom(userRequest.getNom());
|
|
||||||
user.setPrenom(userRequest.getPrenom());
|
|
||||||
user.setTel(userRequest.getTelephone());
|
|
||||||
user.setEmail(userRequest.getEmail());
|
|
||||||
user.setUsername(userRequest.getEmail());
|
|
||||||
user.setPassword(userRequest.getPassword());
|
|
||||||
user.setActive(false);
|
|
||||||
Set<Role> roleSet = new HashSet<>();
|
|
||||||
roleSet.add(roleService.getRoleByRoleName(UserRole.ROLE_ANONYMOUS).get());
|
|
||||||
user.setRoles(roleSet);
|
|
||||||
user.setStructure(structureService.getStructureById(userRequest.getStructureId()).get());
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
234
src/main/java/io/gmss/fiscad/controllers/user/AvoirFonctionController.java
Executable file
234
src/main/java/io/gmss/fiscad/controllers/user/AvoirFonctionController.java
Executable file
@@ -0,0 +1,234 @@
|
|||||||
|
package io.gmss.fiscad.controllers.user;
|
||||||
|
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||||
|
import io.gmss.fiscad.exceptions.*;
|
||||||
|
import io.gmss.fiscad.interfaces.user.AvoirFonctionService;
|
||||||
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "api/fonction-utilisateur", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@SecurityRequirement(name = "bearer")
|
||||||
|
@Tag(name = "Fonction Utilisateur")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
public class AvoirFonctionController {
|
||||||
|
|
||||||
|
private final AvoirFonctionService avoirFonctionService;
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AvoirFonctionController.class);
|
||||||
|
|
||||||
|
public AvoirFonctionController(AvoirFonctionService avoirFonctionService) {
|
||||||
|
this.avoirFonctionService = avoirFonctionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb), "Fonction utilisateur créé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateAvoirFonction(@PathVariable Long id, @RequestBody AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.updateAvoirFonction(id, avoirFonctionPaylaodWeb), "Fonction utilisateur mise à jour 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<?> deleteAvoirFonction(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
avoirFonctionService.deleteAvoirFonction(id);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, "Fonction Utilisateur supprimé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("/all")
|
||||||
|
public ResponseEntity<?> getAll() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionList(), "Liste des fonctions utilisateur."),
|
||||||
|
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("/all-paged")
|
||||||
|
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionList(pageable), "Liste des fonction utilisateurs."),
|
||||||
|
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("/id/{id}")
|
||||||
|
public ResponseEntity<?> getById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionById(id), "Fonction utilisateur trouvés 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("/by-utilisateur-id/{userId}")
|
||||||
|
public ResponseEntity<?> getByUserId(@PathVariable Long userId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId), "Fonctions de utilisateur trouvées 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-utilisateur-id/{userId}")
|
||||||
|
public ResponseEntity<?> getByUserIdPageable(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId,pageable), "Fonctions de utilisateur trouvées 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -113,30 +113,17 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
// @GetMapping("/all")
|
||||||
public ResponseEntity<?> getAllDemandeReinitialisationMPList(@CurrentUser UserPrincipal userPrincipal) {
|
// public ResponseEntity<?> getAllDemandeReinitialisationMPList(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
User user = userPrincipal.getUser();
|
// User user = userPrincipal.getUser();
|
||||||
|
//
|
||||||
if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
// if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
||||||
return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
|
// new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
|
||||||
HttpStatus.OK
|
// HttpStatus.OK
|
||||||
);
|
// );
|
||||||
} else {
|
|
||||||
if (user.getStructure() == null) {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// } else {
|
// } else {
|
||||||
// if (user.getStructure() == null) {
|
// if (user.getStructure() == null) {
|
||||||
// return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
@@ -150,22 +137,35 @@ public class DemandeReinitialisationMPController {
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
//// }else {
|
||||||
logger.error(e.getLocalizedMessage());
|
//// if (user.getStructure() == null) {
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
//// return new ResponseEntity<>(
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
//// new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
||||||
FileStorageException e) {
|
//// HttpStatus.OK
|
||||||
logger.error(e.getLocalizedMessage());
|
//// );
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
//// } else {
|
||||||
} catch (NullPointerException e) {
|
//// return new ResponseEntity<>(
|
||||||
logger.error(e.getLocalizedMessage());
|
//// new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
//// 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);
|
//// }
|
||||||
}
|
// } 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("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
package io.gmss.fiscad.controllers.user;
|
||||||
|
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.Fonction;
|
||||||
|
import io.gmss.fiscad.exceptions.*;
|
||||||
|
import io.gmss.fiscad.interfaces.rfu.metier.FonctionService;
|
||||||
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "api/fonction", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@SecurityRequirement(name = "bearer")
|
||||||
|
@Tag(name = "Fonction")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
public class FonctionController {
|
||||||
|
|
||||||
|
private final FonctionService fonctionService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FonctionController.class);
|
||||||
|
|
||||||
|
public FonctionController(FonctionService fonctionService) {
|
||||||
|
this.fonctionService = fonctionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createFonction(@RequestBody @Valid @Validated FonctionPaylaodWeb fonctionPaylaodWeb) {
|
||||||
|
try {
|
||||||
|
Fonction fonction = fonctionService.createFonction(fonctionPaylaodWeb);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, fonction, "Secteur affecté 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateFonction(@PathVariable Long id, @RequestBody FonctionPaylaodWeb fonctionPaylaodWeb) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, fonctionService.updateFonction(id, fonctionPaylaodWeb), "Affectation de Secteur mise à jour 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<?> deleteFonction(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
fonctionService.deleteFonction(id);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, "Fonction supprimé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("/all")
|
||||||
|
public ResponseEntity<?> getAllFonctionList() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, fonctionService.getFonctionListToDto(), "Liste des caractéristiques 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("/all-paged")
|
||||||
|
public ResponseEntity<?> getAllFonctionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, fonctionService.getFonctionListToDtoPageable(pageable), "Liste des caractéristiques 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("/id/{id}")
|
||||||
|
public ResponseEntity<?> getFonctionById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, fonctionService.getFonctionById(id), "Fonction trouvé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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
182
src/main/java/io/gmss/fiscad/controllers/user/ProfileController.java
Executable file
182
src/main/java/io/gmss/fiscad/controllers/user/ProfileController.java
Executable file
@@ -0,0 +1,182 @@
|
|||||||
|
package io.gmss.fiscad.controllers.user;
|
||||||
|
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.Profile;
|
||||||
|
import io.gmss.fiscad.exceptions.*;
|
||||||
|
import io.gmss.fiscad.interfaces.user.ProfileService;
|
||||||
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.ProfilePaylaodWeb;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "api/profile", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@SecurityRequirement(name = "bearer")
|
||||||
|
@Tag(name = "Profile")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
public class ProfileController {
|
||||||
|
|
||||||
|
private final ProfileService profileService;
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProfileController.class);
|
||||||
|
|
||||||
|
public ProfileController(ProfileService profileService) {
|
||||||
|
this.profileService = profileService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createProfile(@RequestBody @Valid @Validated ProfilePaylaodWeb profilePaylaodWeb ) {
|
||||||
|
try {
|
||||||
|
Profile profile = profileService.createProfile(profilePaylaodWeb);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, profile, "Profile created successully."),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateProfile(@PathVariable Long id, @RequestBody ProfilePaylaodWeb profilePaylaodWeb) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, profileService.updateProfile(id, profilePaylaodWeb), "Profile updated successully."),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<?> deleteProfile(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
profileService.deleteProfile(id);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, "Profile deleted successully"),
|
||||||
|
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("/all")
|
||||||
|
public ResponseEntity<?> getAll() {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, profileService.getProfileList(), "Liste des profiles."),
|
||||||
|
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("/id/{id}")
|
||||||
|
public ResponseEntity<?> getById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, profileService.getProfileById(id), "Profile trouvé 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("/all-paged")
|
||||||
|
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, profileService.getProfileList(pageable), "Liste des profiles."),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,12 +8,15 @@ import io.gmss.fiscad.exceptions.*;
|
|||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.Login;
|
import io.gmss.fiscad.paylaods.Login;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
import io.gmss.fiscad.security.CurrentUser;
|
import io.gmss.fiscad.security.CurrentUser;
|
||||||
import io.gmss.fiscad.security.UserPrincipal;
|
import io.gmss.fiscad.security.UserPrincipal;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -21,6 +24,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,12 +44,11 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
|
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
user.setUsername(user.getEmail());
|
userPaylaodWeb = userService.createUser(userPaylaodWeb);
|
||||||
user = userService.createUser(user, true);
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, user, "Utilisateur créé avec succès"),
|
new ApiResponse<>(true, userPaylaodWeb, "Utilisateur créé avec succès"),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -91,9 +94,9 @@ public class UserController {
|
|||||||
@PostMapping("/reset-password")
|
@PostMapping("/reset-password")
|
||||||
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||||
try {
|
try {
|
||||||
User user = userService.resetPassword(login.getUsername(), login.getPassword());
|
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername(), login.getPassword());
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."),
|
new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -112,10 +115,10 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/validate-user-account")
|
@PostMapping("/validate-user-account/{userName}")
|
||||||
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
|
||||||
try {
|
try {
|
||||||
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
|
User user = userService.validateUserAccount(userName);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
|
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
@@ -138,10 +141,10 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) {
|
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody UserPaylaodWeb userPaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.updateUser(id, user), "Utilisateur modifié avec succès."),
|
new ApiResponse<>(true, userService.updateUser(id, userPaylaodWeb), "Utilisateur modifié avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -165,12 +168,13 @@ public class UserController {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
User user = userService.getUserById(id);
|
User user = userService.getUserById(id);
|
||||||
if(containsRoleAnonyme(user.getRoles())){
|
// if(user.getAvoirFonctions().isEmpty()){
|
||||||
return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
// new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
HttpStatus.OK
|
// HttpStatus.OK
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(user.isResetPassword()){
|
if(user.isResetPassword()){
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
@@ -228,27 +232,12 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
|
public ResponseEntity<?> getAll() {
|
||||||
try {
|
try {
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "Vous n'êtes pas authorisés à accéder à la liste des utilisateurs"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user = userPrincipal.getUser();
|
|
||||||
|
|
||||||
if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."),
|
new ApiResponse<>(true, userService.getListUserToDto(), "Liste des utilisateurs chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
logger.error(e.getLocalizedMessage());
|
logger.error(e.getLocalizedMessage());
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
@@ -265,20 +254,65 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-by-structure")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
if (userPrincipal.getUser().getStructure() != null) {
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
new ApiResponse<>(true, userService.getListUserToDto(pageable), "Liste des utilisateurs chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK);
|
||||||
);
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
} else {
|
logger.error(e.getLocalizedMessage());
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
HttpStatus.OK
|
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("/all-by-structure/{structureId}")
|
||||||
|
public ResponseEntity<?> getAllByStructure(@PathVariable Long structureId) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs 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/all-by-structure/{structureId}")
|
||||||
|
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
|
||||||
|
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
logger.error(e.getLocalizedMessage());
|
logger.error(e.getLocalizedMessage());
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
@@ -351,35 +385,5 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-by-role/{userrole}")
|
|
||||||
public ResponseEntity<?> getUserByUserRole(@PathVariable UserRole userrole) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getUserByProfil(userrole), "Users found."),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsRoleAnonyme(Set<Role> roles){
|
|
||||||
for(Role r: roles ){
|
|
||||||
if(r.getNom().equals(UserRole.ROLE_ANONYMOUS)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,6 @@ public class BaseEntity implements Serializable {
|
|||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
private Long externalKey;
|
private Long externalKey;
|
||||||
private Long enqueteExternalKey;
|
private Long enqueteExternalKey;
|
||||||
|
@JsonIgnore
|
||||||
|
private String source ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ public class Quartier extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
|
private String codeExterne;
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Arrondissement arrondissement;
|
private Arrondissement arrondissement;
|
||||||
|
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
// @OneToOne(mappedBy = "quartier")
|
// @OneToOne(mappedBy = "quartier")
|
||||||
// private Bloc bloc;
|
// private Bloc bloc;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.gmss.fiscad.entities.decoupage;
|
package io.gmss.fiscad.entities.decoupage;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
@@ -26,16 +27,16 @@ public class Secteur extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
@ManyToOne
|
|
||||||
private User chefSecteur;
|
|
||||||
@ManyToOne
|
|
||||||
private Structure structure;
|
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
// @ManyToOne
|
||||||
@JoinColumn(name = "secteur_id")
|
// private Structure structure;
|
||||||
@JsonManagedReference
|
|
||||||
private List<SecteurDecoupage> secteurDecoupages;
|
|
||||||
|
|
||||||
///Creer un payload pour la creation de secteur découpage
|
//@JsonBackReference
|
||||||
/// ressource pour envoyer les découpage d'un secteur
|
@ManyToOne
|
||||||
|
private Section section ;
|
||||||
|
|
||||||
|
//@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
// @JoinColumn(name = "secteur_id")
|
||||||
|
// @JsonManagedReference
|
||||||
|
// private List<SecteurDecoupage> secteurDecoupages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Where(clause = " deleted = false")
|
@Where(clause = " deleted = false")
|
||||||
public class SecteurDecoupage extends BaseEntity implements Serializable {
|
public class SecteurDecoupage extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -36,16 +35,20 @@ public class SecteurDecoupage extends BaseEntity implements Serializable {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFin;
|
private LocalDate dateFin;
|
||||||
|
|
||||||
@JsonBackReference
|
//@JsonBackReference
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Secteur secteur;
|
private Secteur secteur;
|
||||||
|
|
||||||
|
private String codeSecteur ;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Arrondissement arrondissement;
|
private Arrondissement arrondissement;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Quartier quartier;
|
private Quartier quartier;
|
||||||
|
|
||||||
|
private String codeQuartier ;
|
||||||
|
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
// @OneToMany(mappedBy = "secteurDecoupage")
|
// @OneToMany(mappedBy = "secteurDecoupage")
|
||||||
// private List<Bloc> blocs;
|
// private List<Bloc> blocs;
|
||||||
|
|||||||
37
src/main/java/io/gmss/fiscad/entities/decoupage/Section.java
Normal file
37
src/main/java/io/gmss/fiscad/entities/decoupage/Section.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package io.gmss.fiscad.entities.decoupage;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
|
import io.gmss.fiscad.entities.user.Fonction;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Where(clause = " deleted = false")
|
||||||
|
public class Section extends BaseEntity implements Serializable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
private String code;
|
||||||
|
private String nom;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Structure structure;
|
||||||
|
|
||||||
|
//@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
//@JoinColumn(name = "section_id")
|
||||||
|
//@JsonManagedReference
|
||||||
|
//private List<Secteur> secteurs;
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
|||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Campagne;
|
import io.gmss.fiscad.entities.rfu.parametre.Campagne;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
||||||
|
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
|
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
import io.gmss.fiscad.enums.StatutEnquete;
|
||||||
@@ -55,10 +56,14 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
private boolean litige;
|
private boolean litige;
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@ManyToOne
|
||||||
|
private Exercice exercice;
|
||||||
|
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -152,18 +157,18 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
private String numeroTitreFoncier;
|
private String numeroTitreFoncier;
|
||||||
|
|
||||||
/// Nouveau champs ajoutés pour RFU Abomey
|
/// Nouveau champs ajoutés pour RFU Abomey
|
||||||
private String numEnterParcelle;
|
private String numEntreeParcelle;
|
||||||
private String numRue;
|
private String numRue;
|
||||||
private String nomRue;
|
private String nomRue;
|
||||||
private String emplacement;
|
private String emplacement;
|
||||||
private float altitude;
|
private Float altitude;
|
||||||
private float precision;
|
private Float precision;
|
||||||
private int nbreCoProprietaire;
|
private Integer nbreCoProprietaire;
|
||||||
private int nbreIndivisiaire;
|
private Integer nbreIndivisiaire;
|
||||||
private String autreAdresse;
|
private String autreAdresse;
|
||||||
private float superficie ;
|
private Float superficie ;
|
||||||
private int nbreBatiment;
|
private Integer nbreBatiment;
|
||||||
private int nbrePiscine;
|
private Integer nbrePiscine;
|
||||||
private Long montantMensuelleLocation;
|
private Long montantMensuelleLocation;
|
||||||
private Long montantAnnuelleLocation;
|
private Long montantAnnuelleLocation;
|
||||||
private Long valeurParcelleEstime;
|
private Long valeurParcelleEstime;
|
||||||
|
|||||||
@@ -59,9 +59,11 @@ public class Parcelle extends BaseEntity implements Serializable {
|
|||||||
private boolean synchronise;
|
private boolean synchronise;
|
||||||
private Long idDerniereEnquete;
|
private Long idDerniereEnquete;
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
private String numEnterParcelle;
|
private String numEntreeParcelle;
|
||||||
|
private String codeQuartier;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Rue rue ;
|
private Rue rue ;
|
||||||
|
private String numeroRue ;
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
// @OneToMany(mappedBy = "parcelle")
|
// @OneToMany(mappedBy = "parcelle")
|
||||||
// private List<Batiment> batiments;
|
// private List<Batiment> batiments;
|
||||||
|
|||||||
@@ -78,10 +78,12 @@ public class Personne extends BaseEntity implements Serializable {
|
|||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
private int mustHaveRepresentant;
|
private int mustHaveRepresentant;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
private String observation;
|
private String observation;
|
||||||
@ColumnDefault("false")
|
@ColumnDefault("false")
|
||||||
private boolean synchronise;
|
private boolean synchronise;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "personne")
|
@OneToMany(mappedBy = "personne")
|
||||||
private List<Upload> uploads;
|
private List<Upload> uploads;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package io.gmss.fiscad.entities.infocad.parametre;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
|
import io.gmss.fiscad.entities.user.Fonction;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
@@ -28,12 +30,12 @@ import java.util.Set;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@SQLDelete(sql =
|
//@SQLDelete(sql =
|
||||||
"UPDATE structure " +
|
// "UPDATE structure " +
|
||||||
"SET deleted = true " +
|
// "SET deleted = true " +
|
||||||
"WHERE id = ?")
|
// "WHERE id = ?")
|
||||||
@Where(clause = " deleted = false")
|
//@Where(clause = " deleted = false")
|
||||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||||
public class Structure extends BaseEntity implements Serializable {
|
public class Structure extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -47,21 +49,29 @@ public class Structure extends BaseEntity implements Serializable {
|
|||||||
private String tel;
|
private String tel;
|
||||||
private String email;
|
private String email;
|
||||||
private String adresse;
|
private String adresse;
|
||||||
@NotNull
|
//@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Commune commune;
|
private Commune commune;
|
||||||
//@JsonIgnore
|
|
||||||
|
@JsonIgnore
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "arrondissements_structures",
|
@JoinTable(name = "arrondissements_structures",
|
||||||
joinColumns = @JoinColumn(name = "structure_id"),
|
joinColumns = @JoinColumn(name = "structure_id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "arrondissement_id")
|
inverseJoinColumns = @JoinColumn(name = "arrondissement_id")
|
||||||
)
|
)
|
||||||
private Set<Arrondissement> arrondissements;
|
private Set<Arrondissement> arrondissements;
|
||||||
// @JsonIgnore
|
|
||||||
// @OneToMany(mappedBy = "structure")
|
|
||||||
// private List<User> agents;
|
|
||||||
// @JsonIgnore
|
|
||||||
// @OneToMany(mappedBy = "structure")
|
|
||||||
// private List<Bloc> blocs;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Structure{" +
|
||||||
|
"id=" + id +
|
||||||
|
", code='" + code + '\'' +
|
||||||
|
", nom='" + nom + '\'' +
|
||||||
|
", ifu='" + ifu + '\'' +
|
||||||
|
", rccm='" + rccm + '\'' +
|
||||||
|
", tel='" + tel + '\'' +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", adresse='" + adresse + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|||||||
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
||||||
|
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.enums.StatutEnregistrement;
|
import io.gmss.fiscad.enums.StatutEnregistrement;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -70,6 +71,10 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "categorie_caracteristique_id")
|
||||||
|
private Caracteristique caracteristique;
|
||||||
|
|
||||||
private Long personneExternalKey;
|
private Long personneExternalKey;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package io.gmss.fiscad.entities.user;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Section;
|
||||||
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
|
import io.gmss.fiscad.enums.Titre;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
//@SQLDelete(sql =
|
||||||
|
// "UPDATE parcelle " +
|
||||||
|
// "SET deleted = true " +
|
||||||
|
// "WHERE id = ?")
|
||||||
|
//@Where(clause = " deleted = false")
|
||||||
|
public class AvoirFonction extends BaseEntity implements Serializable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
|
private LocalDate dateDebut;
|
||||||
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
|
private LocalDate dateFin;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "user_id", nullable = false)
|
||||||
|
@NotNull
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "fonction_id", nullable = false)
|
||||||
|
@NotNull
|
||||||
|
private Fonction fonction;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Titre titre;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getExternalKey() {
|
||||||
|
return super.getExternalKey();
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getEnqueteExternalKey() {
|
||||||
|
return super.getEnqueteExternalKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
71
src/main/java/io/gmss/fiscad/entities/user/Fonction.java
Normal file
71
src/main/java/io/gmss/fiscad/entities/user/Fonction.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package io.gmss.fiscad.entities.user;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Section;
|
||||||
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
|
import io.gmss.fiscad.entities.user.User;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
//@SQLDelete(sql =
|
||||||
|
// "UPDATE parcelle " +
|
||||||
|
// "SET deleted = true " +
|
||||||
|
// "WHERE id = ?")
|
||||||
|
//@Where(clause = " deleted = false")
|
||||||
|
public class Fonction extends BaseEntity implements Serializable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
private String code ;
|
||||||
|
private String nom ;
|
||||||
|
|
||||||
|
@JsonBackReference
|
||||||
|
@ManyToOne
|
||||||
|
private Secteur secteur;
|
||||||
|
|
||||||
|
//@JsonBackReference
|
||||||
|
@ManyToOne
|
||||||
|
private Section section;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "structure_id")
|
||||||
|
private Structure structure;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Departement departement;
|
||||||
|
|
||||||
|
//@JsonIgnore
|
||||||
|
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "profile_id", nullable = false)
|
||||||
|
@NotNull
|
||||||
|
private Profile profile;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getExternalKey() {
|
||||||
|
return super.getExternalKey();
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getEnqueteExternalKey() {
|
||||||
|
return super.getEnqueteExternalKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
78
src/main/java/io/gmss/fiscad/entities/user/Profile.java
Executable file
78
src/main/java/io/gmss/fiscad/entities/user/Profile.java
Executable file
@@ -0,0 +1,78 @@
|
|||||||
|
package io.gmss.fiscad.entities.user;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
|
import io.gmss.fiscad.enums.UserProfile;
|
||||||
|
import io.gmss.fiscad.enums.UserRole;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
//@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
public class Profile extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private UserProfile nom;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Profile(UserProfile name, String description) {
|
||||||
|
this.nom = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
|
@JoinTable(name = "profile_role",
|
||||||
|
joinColumns = @JoinColumn(name = "profile_id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(name = "role_id")
|
||||||
|
)
|
||||||
|
private Set<Role> roles = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
|
||||||
|
// If the object is compared with itself then return true
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if o is an instance of Complex or not
|
||||||
|
"null instanceof [type]" also returns false */
|
||||||
|
if (!(o instanceof Profile)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// typecast o to Complex so that we can compare data members
|
||||||
|
Profile r = (Profile) o;
|
||||||
|
|
||||||
|
// Compare the data members and return accordingly
|
||||||
|
return r.getNom().equals(this.getNom());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, nom, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getExternalKey() {
|
||||||
|
return super.getExternalKey();
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getEnqueteExternalKey() {
|
||||||
|
return super.getEnqueteExternalKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.gmss.fiscad.entities.user;
|
package io.gmss.fiscad.entities.user;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
import io.gmss.fiscad.enums.UserRole;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -54,4 +55,13 @@ public class Role extends BaseEntity implements Serializable {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, nom, description);
|
return Objects.hash(id, nom, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getExternalKey() {
|
||||||
|
return super.getExternalKey();
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public Long getEnqueteExternalKey() {
|
||||||
|
return super.getEnqueteExternalKey();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.hibernate.annotations.SQLDelete;
|
|||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -39,6 +40,12 @@ public class User extends BaseEntity implements Serializable {
|
|||||||
private String prenom;
|
private String prenom;
|
||||||
private String tel;
|
private String tel;
|
||||||
private String email;
|
private String email;
|
||||||
|
@Column(
|
||||||
|
name = "username",
|
||||||
|
nullable = false,
|
||||||
|
unique = true,
|
||||||
|
length = 200
|
||||||
|
)
|
||||||
private String username;
|
private String username;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String password;
|
private String password;
|
||||||
@@ -46,42 +53,31 @@ public class User extends BaseEntity implements Serializable {
|
|||||||
private boolean active;
|
private boolean active;
|
||||||
@Column(columnDefinition = "boolean default false")
|
@Column(columnDefinition = "boolean default false")
|
||||||
private boolean resetPassword;
|
private boolean resetPassword;
|
||||||
@ManyToMany
|
|
||||||
@JoinTable(name = "users_roles",
|
@OneToMany(mappedBy = "user")
|
||||||
joinColumns = @JoinColumn(name = "user_id"),
|
private Set<AvoirFonction> avoirFonctions= new HashSet<>();
|
||||||
inverseJoinColumns = @JoinColumn(name = "roles_id")
|
|
||||||
)
|
|
||||||
private Set<Role> roles;
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Structure structure;
|
private Structure structure;
|
||||||
// @JsonIgnore
|
|
||||||
// @OneToMany(mappedBy = "user")
|
|
||||||
// private List<Enquete> enquetes;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(mappedBy = "user")
|
@OneToMany(mappedBy = "user")
|
||||||
private List<Participer> participers;
|
private List<Participer> participers;
|
||||||
|
|
||||||
// @JsonIgnore
|
|
||||||
// @OneToMany(mappedBy = "chefSecteur")
|
|
||||||
// private List<Secteur> secteurs;
|
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private Long idCampagneCourant;
|
private Long idCampagneCourant;
|
||||||
@Transient
|
@Transient
|
||||||
private Long idSecteurCourant;
|
private Long idSecteurCourant;
|
||||||
|
|
||||||
// public void setUsername(String username) {
|
|
||||||
// this.username = username;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
for (Role r : this.roles) {
|
// for (Role r : this.roles) {
|
||||||
if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
|
// if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
src/main/java/io/gmss/fiscad/enums/Titre.java
Normal file
6
src/main/java/io/gmss/fiscad/enums/Titre.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package io.gmss.fiscad.enums;
|
||||||
|
|
||||||
|
public enum Titre {
|
||||||
|
TITULAIRE,
|
||||||
|
INTERIMAIRE
|
||||||
|
}
|
||||||
9
src/main/java/io/gmss/fiscad/enums/UserProfile.java
Normal file
9
src/main/java/io/gmss/fiscad/enums/UserProfile.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package io.gmss.fiscad.enums;
|
||||||
|
|
||||||
|
public enum UserProfile {
|
||||||
|
INSPECTEUR_GESTIONNAIRE,
|
||||||
|
ADMIN_FONCTIONNEL,
|
||||||
|
INSPECTEUR_GESTIONNAIRE_CHEF_SECTEUR,
|
||||||
|
INSPECTEUR_GESTIONNAIRE_CHEF_SECTION,
|
||||||
|
INSPECTEUR_GESTIONNAIRE_CHEF_CENTRE
|
||||||
|
}
|
||||||
@@ -2,11 +2,23 @@ package io.gmss.fiscad.enums;
|
|||||||
|
|
||||||
public enum UserRole {
|
public enum UserRole {
|
||||||
|
|
||||||
ROLE_ADMIN,
|
ADMIN,
|
||||||
ROLE_USER,
|
CREATE_USER,
|
||||||
ROLE_DIRECTEUR,
|
UPDATE_USER,
|
||||||
ROLE_SUPERVISEUR,
|
READ_USER,
|
||||||
ROLE_ENQUETEUR,
|
DELETE_USER,
|
||||||
ROLE_ANONYMOUS,
|
CREATE_PARCELLE,
|
||||||
ROLE_RESPONSABLE
|
UPDATE_PARCELLE,
|
||||||
|
READ_PARCELLE,
|
||||||
|
DELETE_PARCELLE,
|
||||||
|
CREATE_ENQUETE,
|
||||||
|
UPDATE_ENQUETE,
|
||||||
|
READ_ENQUETE,
|
||||||
|
DELETE_ENQUETE,
|
||||||
|
CREATE_BATIMENT,
|
||||||
|
UPDATE_BATIMENT,
|
||||||
|
READ_BATIMENT,
|
||||||
|
DELETE_BATIMENT
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
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.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -55,27 +56,28 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Arrondissement> getArrondissementList(Pageable pageable) {
|
public Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable) {
|
||||||
return arrondissementRepository.findAll(pageable);
|
return arrondissementRepository.findAllArrondissementToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Arrondissement> getArrondissementList() {
|
public List<ArrondissementPaylaodWeb> getArrondissementList() {
|
||||||
return arrondissementRepository.findAll();
|
return arrondissementRepository.findAllArrondissementToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Arrondissement> getArrondissementById(Long id) {
|
public List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId) {
|
||||||
return arrondissementRepository.findById(id);
|
return arrondissementRepository.findAllArrondissementByCommuneToDto(communeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Arrondissement> getArrondissementByComune(Long communeId) {
|
public Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId, Pageable pageable) {
|
||||||
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
|
return arrondissementRepository.findAllArrondissementByCommuneToDtoPageable(communeId,pageable);
|
||||||
if (communeOptional.isEmpty()) {
|
|
||||||
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
|
|
||||||
}
|
}
|
||||||
return arrondissementRepository.findAllByCommune(communeOptional.get());
|
|
||||||
|
@Override
|
||||||
|
public Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id) {
|
||||||
|
return arrondissementRepository.findArrondissementToDtoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.CommuneRepository;
|
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.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -55,27 +57,28 @@ public class CommuneServiceImpl implements CommuneService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Commune> getCommuneList(Pageable pageable) {
|
public Page<CommunePaylaodWeb> getCommuneList(Pageable pageable) {
|
||||||
return communeRepository.findAll(pageable);
|
return communeRepository.findAllCommuneToDtoPageable(pageable);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Commune> getCommuneList() {
|
|
||||||
return communeRepository.findAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Commune> getCommunesByDepartement(Long departementId) {
|
public List<CommunePaylaodWeb> getCommuneList() {
|
||||||
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
|
return communeRepository.findAllCommuneToDto();
|
||||||
if (departementOptional.isEmpty()) {
|
|
||||||
throw new NotFoundException("Impossible de trouver le département spécifié.");
|
|
||||||
}
|
|
||||||
return communeRepository.findAllByDepartement(departementOptional.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Commune> getCommuneById(Long id) {
|
public List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId) {
|
||||||
return communeRepository.findById(id);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import io.gmss.fiscad.entities.decoupage.Departement;
|
|||||||
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.decoupage.DepartementService;
|
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.DepartementRepository;
|
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.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -51,20 +52,20 @@ public class DepartementServiceImpl implements DepartementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Departement> getDepartementList(Pageable pageable) {
|
public Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable) {
|
||||||
return departementRepository.findAll(pageable);
|
return departementRepository.findAllDepartementToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Departement> getDepartementList() {
|
public List<DepartementPaylaodWeb> getDepartementList() {
|
||||||
return departementRepository.findAll();
|
return departementRepository.findAllDepartementToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Departement> getDepartementById(Long id) {
|
public Optional<DepartementPaylaodWeb> getDepartementById(Long id) {
|
||||||
if (departementRepository.existsById(id)) {
|
if (departementRepository.existsById(id)) {
|
||||||
return departementRepository.findById(id);
|
return departementRepository.findDepartementToDtoById(id);
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.decoupage.Nationalite;
|
|||||||
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.decoupage.NationaliteService;
|
import io.gmss.fiscad.interfaces.decoupage.NationaliteService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.NationaliteRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.QuartierRepository;
|
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.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -55,31 +56,28 @@ public class QuartierServiceImpl implements QuartierService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Quartier> getQuartierList(Pageable pageable) {
|
public Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable) {
|
||||||
return quartierRepository.findAll(pageable);
|
return quartierRepository.findAllQuartierToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Quartier> getQuartierList() {
|
public List<QuartierPaylaodWeb> getQuartierList() {
|
||||||
return quartierRepository.findAll();
|
return quartierRepository.findAllQuartierToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Quartier> getQuartierById(Long id) {
|
public List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId) {
|
||||||
if (quartierRepository.existsById(id)) {
|
return quartierRepository.findAllQuartierByArrondissementToDto(arrondissementId);
|
||||||
return quartierRepository.findById(id);
|
|
||||||
} else {
|
|
||||||
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
|
public Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId, Pageable pageable) {
|
||||||
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
|
return quartierRepository.findAllQuartierByArrondissementToDtoPageable(arrondissementId,pageable);
|
||||||
if (arrondissementOptional.isEmpty()) {
|
|
||||||
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
|
|
||||||
}
|
}
|
||||||
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
|
|
||||||
|
@Override
|
||||||
|
public Optional<QuartierPaylaodWeb> getQuartierById(Long id) {
|
||||||
|
return quartierRepository.findQuartierToDtoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,58 @@
|
|||||||
package io.gmss.fiscad.implementations.decoupage;
|
package io.gmss.fiscad.implementations.decoupage;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
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.decoupage.SecteurDecoupageService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||||
import io.gmss.fiscad.repositories.decoupage.SecteurDecoupageRepository;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
||||||
|
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||||
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||||
|
private final SecteurService secteurService;
|
||||||
|
private final ParcelleRepository parcelleRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
|
|
||||||
public SecteurDecoupageServiceImpl(SecteurDecoupageRepository secteurDecoupageRepository) {
|
|
||||||
this.secteurDecoupageRepository = secteurDecoupageRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
|
public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
|
||||||
if (secteurDecoupage.getId() != null) {
|
if (secteurDecoupagePaylaodWeb.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
||||||
}
|
}
|
||||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
||||||
|
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
||||||
|
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
|
public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
|
||||||
if (secteurDecoupage.getId() == null) {
|
if (secteurDecoupagePaylaodWeb.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
||||||
}
|
}
|
||||||
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
|
if (!secteurDecoupageRepository.existsById(secteurDecoupagePaylaodWeb.getId())) {
|
||||||
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
||||||
}
|
}
|
||||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
|
||||||
|
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
||||||
|
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
||||||
|
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,13 +66,28 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) {
|
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
|
||||||
return secteurDecoupageRepository.findAll(pageable);
|
return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SecteurDecoupage> getSecteurDecoupageList() {
|
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList() {
|
||||||
return secteurDecoupageRepository.findAll();
|
return secteurDecoupageRepository.findAllSecteurDecoupageToDto();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long secteurId, Pageable pageable) {
|
||||||
|
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDtoPageable(secteurId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId) {
|
||||||
|
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDto(sectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id) {
|
||||||
|
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,4 +95,21 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
|||||||
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
|
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
|
||||||
return secteurDecoupageRepository.findById(id);
|
return secteurDecoupageRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ParcelleStatsProjectionUnSecteur> getStatParcelleDecoupageUnSecteur(Long secteurId) {
|
||||||
|
return parcelleRepository.findStatsBySecteurs(List.of(secteurId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ParcelleStatsProjectionUnSecteur> getStatParcelleDecoupageByUserId(Long userId) {
|
||||||
|
List<ParcelleStatsProjectionUnSecteur> parcelleStatsProjectionUnSecteurs = new ArrayList<>();
|
||||||
|
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
|
||||||
|
List<Long> secteurIds = secteurs.stream()
|
||||||
|
.map(Secteur::getId)
|
||||||
|
.toList();
|
||||||
|
parcelleStatsProjectionUnSecteurs = parcelleRepository.findStatsBySecteurs(secteurIds);
|
||||||
|
|
||||||
|
return parcelleStatsProjectionUnSecteurs ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,105 +3,103 @@ package io.gmss.fiscad.implementations.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
|
import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
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.decoupage.SecteurService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurDecoupagePayload;
|
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurDecoupagePayload;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
|
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
|
||||||
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
||||||
import io.gmss.fiscad.repositories.decoupage.QuartierRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
||||||
import io.gmss.fiscad.repositories.decoupage.SecteurRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SecteurServiceImpl implements SecteurService {
|
public class SecteurServiceImpl implements SecteurService {
|
||||||
private final SecteurRepository secteurRepository;
|
private final SecteurRepository secteurRepository;
|
||||||
|
private final ParcelleRepository parcelleRepository;
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final ArrondissementRepository arrondissementRepository;
|
private final ArrondissementRepository arrondissementRepository;
|
||||||
private final QuartierRepository quartierRepository;
|
private final QuartierRepository quartierRepository;
|
||||||
private final StructureRepository structureRepository;
|
private final StructureRepository structureRepository;
|
||||||
|
private final AvoirFonctionRepository avoirFonctionRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
|
|
||||||
public SecteurServiceImpl(SecteurRepository secteurRepository, UserRepository userRepository, ArrondissementRepository arrondissementRepository, QuartierRepository quartierRepository, StructureRepository structureRepository) {
|
|
||||||
this.secteurRepository = secteurRepository;
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
this.arrondissementRepository = arrondissementRepository;
|
|
||||||
this.quartierRepository = quartierRepository;
|
|
||||||
this.structureRepository = structureRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Secteur createSecteur(SecteurPayload secteurPayload) throws BadRequestException {
|
public SecteurPaylaodWeb createSecteur(SecteurPaylaodWeb secteurPaylaodWeb) throws BadRequestException {
|
||||||
if (secteurPayload.getId() != null) {
|
if (secteurPaylaodWeb.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
||||||
}
|
}
|
||||||
|
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
||||||
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
secteur = secteurRepository.save(secteur);
|
||||||
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
||||||
return secteurRepository.save(secteur);
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
|
// private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
|
||||||
Secteur secteur = new Secteur();
|
// Secteur secteur = new Secteur();
|
||||||
Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
|
//// Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
|
||||||
secteur.setChefSecteur(optionalUser.orElse(null));
|
// //secteur.setChefSecteur(optionalUser.orElse(null));
|
||||||
Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
|
//// Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
|
||||||
secteur.setStructure(optionalStructure.orElse(null));
|
//// secteur.setStructure(optionalStructure.orElse(null));
|
||||||
List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
|
//// List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
|
||||||
|
//
|
||||||
for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
|
//// for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
|
||||||
SecteurDecoupage sd = new SecteurDecoupage();
|
//// SecteurDecoupage sd = new SecteurDecoupage();
|
||||||
if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
|
//// if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
|
||||||
sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null));
|
//// sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null));
|
||||||
}
|
//// }
|
||||||
|
////
|
||||||
if (sdp.getArrondissementId() != null && arrondissementRepository.existsById(sdp.getArrondissementId())) {
|
//// if (sdp.getArrondissementId() != null && arrondissementRepository.existsById(sdp.getArrondissementId())) {
|
||||||
sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null));
|
//// sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null));
|
||||||
}
|
//// }
|
||||||
|
////
|
||||||
if (sdp.getQuartierId() != null && quartierRepository.existsById(sdp.getQuartierId())) {
|
//// if (sdp.getQuartierId() != null && quartierRepository.existsById(sdp.getQuartierId())) {
|
||||||
sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null));
|
//// sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null));
|
||||||
}
|
//// }
|
||||||
sd.setDateDebut(sdp.getDateDebut());
|
//// sd.setDateDebut(sdp.getDateDebut());
|
||||||
sd.setDateFin(sdp.getDateFin());
|
//// sd.setDateFin(sdp.getDateFin());
|
||||||
sd.setId(sdp.getId());
|
//// sd.setId(sdp.getId());
|
||||||
secteurDecoupageList.add(sd);
|
//// secteurDecoupageList.add(sd);
|
||||||
}
|
//// }
|
||||||
secteur.setSecteurDecoupages(secteurDecoupageList);
|
// //secteur.setSecteurDecoupages(secteurDecoupageList);
|
||||||
//TODO
|
// //TODO
|
||||||
secteur.setId(secteurPayload.getId());
|
// secteur.setId(secteurPayload.getId());
|
||||||
secteur.setCode(secteurPayload.getCode());
|
// secteur.setCode(secteurPayload.getCode());
|
||||||
secteur.setNom(secteurPayload.getNom());
|
// secteur.setNom(secteurPayload.getNom());
|
||||||
return secteur;
|
// return secteur;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Secteur updateSecteur(Long id, SecteurPayload secteurPayload) throws NotFoundException {
|
public SecteurPaylaodWeb updateSecteur(Long id, SecteurPaylaodWeb secteurPaylaodWeb) throws NotFoundException {
|
||||||
if (secteurPayload.getId() == null) {
|
if (secteurPaylaodWeb.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
|
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!secteurRepository.existsById(secteurPayload.getId())) {
|
if (!secteurRepository.existsById(secteurPaylaodWeb.getId())) {
|
||||||
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
||||||
}
|
}
|
||||||
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
||||||
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
secteur = secteurRepository.save(secteur);
|
||||||
return secteurRepository.save(secteur);
|
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
||||||
} else {
|
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,23 +113,58 @@ public class SecteurServiceImpl implements SecteurService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Secteur> getSecteurList(Pageable pageable) {
|
public Page<SecteurPaylaodWeb> getSecteurList(Pageable pageable) {
|
||||||
return secteurRepository.findAll(pageable);
|
return secteurRepository.findAllSecteurToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Secteur> getSecteurList() {
|
public List<SecteurPaylaodWeb> getSecteurList() {
|
||||||
return secteurRepository.findAll();
|
return secteurRepository.findAllSecteurToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Secteur> getSecteurListUneStruture(Long structureId) {
|
public Page<SecteurPaylaodWeb> getSecteurListBySectionId(Long sectionId, Pageable pageable) {
|
||||||
return secteurRepository.findAllByStructure_Id(structureId);
|
return secteurRepository.findAllSecteurBySectionIdToDtoPageable(sectionId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SecteurPaylaodWeb> getSecteurListBySectionId(Long sectionId) {
|
||||||
|
return secteurRepository.findAllSecteurBySectionIdToDto(sectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SecteurPaylaodWeb> getSecteurListByStructureId(Long structureId) {
|
||||||
|
return secteurRepository.findAllSecteurByStructureIdToDto(structureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SecteurPaylaodWeb> getSecteurListByStructureId(Long structureId, Pageable pageable) {
|
||||||
|
return secteurRepository.findAllSecteurByStructureIdToDtoPageable(structureId,pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Secteur> getSecteurById(Long id) {
|
public Optional<SecteurPaylaodWeb> getSecteurById(Long id) {
|
||||||
return secteurRepository.findById(id);
|
return secteurRepository.findSecteurToDtoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Secteur> getListSecteurUserId(Long userId) {
|
||||||
|
List<AvoirFonction> avoirFonctions= avoirFonctionRepository.findAvoirFonctionByUser_Id(userId);
|
||||||
|
List<Secteur> secteurs = new ArrayList<>();
|
||||||
|
avoirFonctions.stream()
|
||||||
|
.filter(af -> af.getDateFin() == null || af.getDateFin().isAfter(LocalDate.now()))
|
||||||
|
.forEach(avoirFonction -> {
|
||||||
|
if(avoirFonction.getFonction().getSecteur()!=null){
|
||||||
|
secteurs.addAll(List.of(avoirFonction.getFonction().getSecteur()));
|
||||||
|
}else
|
||||||
|
if (avoirFonction.getFonction().getSection()!=null){
|
||||||
|
secteurs.addAll(secteurRepository.findDistinctBySection_Id(avoirFonction.getFonction().getSection().getId()));
|
||||||
|
}else if(avoirFonction.getFonction().getStructure()!=null){
|
||||||
|
secteurs.addAll(secteurRepository.findDistinctBySection_Structure_Id(avoirFonction.getFonction().getStructure().getId()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return secteurs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package io.gmss.fiscad.implementations.decoupage;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Section;
|
||||||
|
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||||
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
|
import io.gmss.fiscad.interfaces.decoupage.SectionService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SectionPaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.decoupage.SectionRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class SectionServiceImpl implements SectionService {
|
||||||
|
private final StructureRepository structureRepository;
|
||||||
|
private final SectionRepository sectionRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
@Override
|
||||||
|
public SectionPaylaodWeb createSection(SectionPaylaodWeb sectionPaylaodWeb) throws BadRequestException {
|
||||||
|
if (sectionPaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("Impossible de créer une nouvelle section ayant un id non null.");
|
||||||
|
}
|
||||||
|
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
||||||
|
section=sectionRepository.save(section);
|
||||||
|
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SectionPaylaodWeb updateSection(Long id, SectionPaylaodWeb sectionPaylaodWeb) throws NotFoundException {
|
||||||
|
if (sectionPaylaodWeb.getId() == null) {
|
||||||
|
throw new BadRequestException("Impossible de mettre à jour un nouveau section ayant un id null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sectionRepository.existsById(sectionPaylaodWeb.getId())) {
|
||||||
|
throw new NotFoundException("Impossible de trouver le section spécifié.");
|
||||||
|
}
|
||||||
|
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
||||||
|
section=sectionRepository.save(section);
|
||||||
|
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteSection(Long id) throws NotFoundException {
|
||||||
|
Optional<Section> optionalSection = sectionRepository.findById(id);
|
||||||
|
if (optionalSection.isPresent()) {
|
||||||
|
sectionRepository.deleteById(optionalSection.get().getId());
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("Impossible de trouver la section spécifié.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SectionPaylaodWeb> getSectionList(Pageable pageable) {
|
||||||
|
|
||||||
|
return sectionRepository.findAllSectionToDtoPageable(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SectionPaylaodWeb> getSectionList() {
|
||||||
|
return sectionRepository.findAllSectionToDto();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SectionPaylaodWeb> getSectionListByStructureId(Long structureId) {
|
||||||
|
return sectionRepository.findAllSectionByStructureToDto(structureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SectionPaylaodWeb> getSectionListByStructureId(Long structureId, Pageable pageable) {
|
||||||
|
return sectionRepository.findAllSectionByStructureToDtoPageable(structureId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SectionPaylaodWeb> getSectionById(Long id) {
|
||||||
|
return sectionRepository.findSectionToDtoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.metier.ActeurConcerne;
|
|||||||
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.infocad.metier.ActeurConcerneService;
|
import io.gmss.fiscad.interfaces.infocad.metier.ActeurConcerneService;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ActeurConcerneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ActeurConcerneRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.gmss.fiscad.exceptions.NotFoundException;
|
|||||||
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
|
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
|
||||||
import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
|
import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
|
||||||
import io.gmss.fiscad.paylaods.response.CommentaireResponse;
|
import io.gmss.fiscad.paylaods.response.CommentaireResponse;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.CommentaireRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.CommentaireRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.gmss.fiscad.implementations.infocad.metier;
|
package io.gmss.fiscad.implementations.infocad.metier;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.*;
|
import io.gmss.fiscad.entities.infocad.metier.*;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Bloc;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
|
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
|
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
|
||||||
@@ -18,7 +17,6 @@ import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
|
|||||||
import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
|
import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
|
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
|
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
|
||||||
import io.gmss.fiscad.interfaces.rfu.parametre.CaracteristiqueService;
|
|
||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
//import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad ;
|
//import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad ;
|
||||||
//import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb ;
|
//import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb ;
|
||||||
@@ -27,20 +25,20 @@ import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
|||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.* ;
|
import io.gmss.fiscad.paylaods.response.* ;
|
||||||
import io.gmss.fiscad.paylaods.response.FicheResponse.* ;
|
import io.gmss.fiscad.paylaods.response.FicheResponse.* ;
|
||||||
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
import io.gmss.fiscad.paylaods.response.synchronisation.EnqueteNonSyncResponse;
|
||||||
import io.gmss.fiscad.repositories.decoupage.CommuneRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
||||||
import io.gmss.fiscad.repositories.decoupage.SecteurRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.*;
|
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.CaracteristiqueParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.EnqueteBatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueParcelleRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.EnqueteUniteLogementRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.EquipeRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.EquipeRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.ZoneRfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ZoneRfuRepository;
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
@@ -153,7 +151,7 @@ public class EnqueteServiceImpl implements EnqueteService {
|
|||||||
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
|
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
|
||||||
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
|
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
|
||||||
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
|
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
|
||||||
enquete.setNumEnterParcelle(enquetePayLoadWeb.getNumEnterParcelle());
|
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
|
||||||
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
|
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
|
||||||
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
|
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
|
||||||
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
|
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
|
||||||
@@ -267,7 +265,7 @@ public class EnqueteServiceImpl implements EnqueteService {
|
|||||||
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
|
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
|
||||||
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
|
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
|
||||||
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
|
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
|
||||||
enquete.setNumEnterParcelle(enquetePayLoadWeb.getNumEnterParcelle());
|
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
|
||||||
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
|
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
|
||||||
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
|
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
|
||||||
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
|
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
|
||||||
@@ -401,6 +399,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
|||||||
return enqueteRepository.findAll();
|
return enqueteRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Enquete> getEnqueteListByParcelle(Long parcelleId) {
|
||||||
|
return enqueteRepository.findAllByParcelle_Id(parcelleId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Enquete> getEnqueteById(Long id) {
|
public Optional<Enquete> getEnqueteById(Long id) {
|
||||||
if (enqueteRepository.existsById(id)) {
|
if (enqueteRepository.existsById(id)) {
|
||||||
|
|||||||
@@ -3,19 +3,15 @@ package io.gmss.fiscad.implementations.infocad.metier;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.ParcelleGeom;
|
import io.gmss.fiscad.entities.infocad.metier.ParcelleGeom;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
||||||
import io.gmss.fiscad.enums.StatutParcelle;
|
|
||||||
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.infocad.metier.ParcelleGeomService;
|
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService;
|
||||||
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
|
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.UploadPayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.response.EnqueteCheckResponse;
|
import io.gmss.fiscad.paylaods.response.EnqueteCheckResponse;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ParcelleGeomRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleGeomRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.service.FileStorageService;
|
import io.gmss.fiscad.service.FileStorageService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.locationtech.jts.geom.Coordinate;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
package io.gmss.fiscad.implementations.infocad.metier;
|
package io.gmss.fiscad.implementations.infocad.metier;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
|
import io.gmss.fiscad.entities.infocad.metier.EnqueteFiltreResponse;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Rue;
|
import io.gmss.fiscad.entities.infocad.metier.Rue;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.SituationGeographique;
|
|
||||||
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.decoupage.SecteurService;
|
||||||
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
|
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.FiltreParcellePayLoad;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
|
||||||
import io.gmss.fiscad.repositories.decoupage.QuartierRepository;
|
import io.gmss.fiscad.paylaods.response.dataTableResponse.ParcelleDataTableResponse;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.RueRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.NatureDomaineRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.RueRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.SituationGeographiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.NatureDomaineRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationGeographiqueRepository;
|
||||||
|
import io.gmss.fiscad.persistence.specification.ParcelleSpecification;
|
||||||
import io.gmss.fiscad.service.GeometryService;
|
import io.gmss.fiscad.service.GeometryService;
|
||||||
|
import jakarta.persistence.Query;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.data.domain.*;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -32,6 +36,7 @@ public class ParcelleServiceImpl implements ParcelleService {
|
|||||||
private final ParcelleRepository parcelleRepository;
|
private final ParcelleRepository parcelleRepository;
|
||||||
private final RueRepository rueRepository;
|
private final RueRepository rueRepository;
|
||||||
private final GeometryService geometryService;
|
private final GeometryService geometryService;
|
||||||
|
private final SecteurService secteurService;
|
||||||
|
|
||||||
// @Value("${infocad.geom.srid}")
|
// @Value("${infocad.geom.srid}")
|
||||||
// private String defaultSrid32631;
|
// private String defaultSrid32631;
|
||||||
@@ -95,6 +100,15 @@ public class ParcelleServiceImpl implements ParcelleService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Parcelle> getParcelleList(Pageable pageable) {
|
public Page<Parcelle> getParcelleList(Pageable pageable) {
|
||||||
|
Sort sort = pageable.getSort().isSorted()
|
||||||
|
? pageable.getSort()
|
||||||
|
: Sort.by(Sort.Direction.DESC, "id");
|
||||||
|
|
||||||
|
Pageable pageableWithSort = PageRequest.of(
|
||||||
|
pageable.getPageNumber(),
|
||||||
|
pageable.getPageSize(),
|
||||||
|
sort
|
||||||
|
);
|
||||||
return parcelleRepository.findAll(pageable);
|
return parcelleRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +126,37 @@ public class ParcelleServiceImpl implements ParcelleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ParcelleDataTableResponse> getParcelleDataTableListByUserId(Long userId, Pageable pageable) {
|
||||||
|
|
||||||
|
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
|
||||||
|
List<Long> secteurIds = secteurs.stream()
|
||||||
|
.map(Secteur::getId)
|
||||||
|
.toList();
|
||||||
|
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable);
|
||||||
|
|
||||||
|
return parcelleDataTableResponses ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ParcelleDataTableResponse> getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable) {
|
||||||
|
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
|
||||||
|
List<Long> secteurIds = secteurs.stream()
|
||||||
|
.map(Secteur::getId)
|
||||||
|
.toList();
|
||||||
|
//
|
||||||
|
// return parcelleRepository.findAll(
|
||||||
|
// ParcelleSpecification.filtre(filtreParcellePayLoad, secteurIds),
|
||||||
|
// pageable
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable);
|
||||||
|
|
||||||
|
return parcelleDataTableResponses ;
|
||||||
|
}
|
||||||
|
|
||||||
private Parcelle getParcelleFromPayload(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb) {
|
private Parcelle getParcelleFromPayload(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb) {
|
||||||
if(parcellePayLoadWeb.getRueId()!=null) {
|
if(parcellePayLoadWeb.getRueId()!=null) {
|
||||||
Optional<Rue> optionalRue = rueRepository.findById(parcellePayLoadWeb.getRueId());
|
Optional<Rue> optionalRue = rueRepository.findById(parcellePayLoadWeb.getRueId());
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package io.gmss.fiscad.implementations.infocad.metier;
|
package io.gmss.fiscad.implementations.infocad.metier;
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Nationalite;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.*;
|
import io.gmss.fiscad.entities.infocad.parametre.*;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
@@ -11,15 +8,15 @@ import io.gmss.fiscad.exceptions.NotFoundException;
|
|||||||
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
|
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
|
||||||
import io.gmss.fiscad.paylaods.dto.*;
|
import io.gmss.fiscad.paylaods.dto.*;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
|
||||||
import io.gmss.fiscad.repositories.decoupage.CommuneRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
||||||
import io.gmss.fiscad.repositories.decoupage.NationaliteRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.MembreGroupeRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.MembreGroupeRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.PieceRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.ProfessionRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.SituationMatrimonialeRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypePersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import jakarta.persistence.EntityNotFoundException;
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
|||||||
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.infocad.metier.TpeService;
|
import io.gmss.fiscad.interfaces.infocad.metier.TpeService;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.TpeRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.TpeRepository;
|
||||||
import io.gmss.fiscad.service.StringService;
|
import io.gmss.fiscad.service.StringService;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import io.gmss.fiscad.exceptions.NotFoundException;
|
|||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.infocad.parametre.BlocService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.BlocService;
|
||||||
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository;
|
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
|
||||||
import io.gmss.fiscad.service.StringService;
|
import io.gmss.fiscad.service.StringService;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -77,7 +78,7 @@ public class BlocServiceImpl implements BlocService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Structure> structureOptional = structureService.getStructureById(structure_id);
|
Optional<StructurePaylaodWeb> structureOptional = structureService.getStructureById(structure_id);
|
||||||
if (structureOptional.isPresent()) {
|
if (structureOptional.isPresent()) {
|
||||||
builder.append(structureOptional.get().getCode());
|
builder.append(structureOptional.get().getCode());
|
||||||
builder.append(bloc.getArrondissement().getCode());
|
builder.append(bloc.getArrondissement().getCode());
|
||||||
@@ -133,10 +134,7 @@ public class BlocServiceImpl implements BlocService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Bloc> getBlocsByArrondissement(Long idArrondissement) {
|
public List<Bloc> getBlocsByArrondissement(Long idArrondissement) {
|
||||||
Arrondissement arrondissement = arrondissementService.getArrondissementById(idArrondissement).orElseThrow(() -> {
|
return blocRepository.findAllByArrondissement_Id(idArrondissement);
|
||||||
throw new NotFoundException("Impossible de trouver l'arrondissement");
|
|
||||||
});
|
|
||||||
return blocRepository.findAllByArrondissement(arrondissement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition;
|
|||||||
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.infocad.parametre.ModeAcquisitionService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.ModeAcquisitionService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.ModeAcquisitionRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.ModeAcquisitionRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
|||||||
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.infocad.parametre.NatureDomaineService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.NatureDomaineService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.NatureDomaineRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.NatureDomaineRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.PositionRepresentation;
|
|||||||
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.infocad.parametre.PositionRepresentationService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.PositionRepresentationService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PositionRepresentationRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PositionRepresentationRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.Profession;
|
|||||||
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.infocad.parametre.ProfessionService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.ProfessionService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.ProfessionRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.SituationGeographique;
|
|||||||
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.infocad.parametre.SituationGeographiqueService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.SituationGeographiqueService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.SituationGeographiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationGeographiqueRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.SituationMatrimoniale;
|
|||||||
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.infocad.parametre.SituationMatrimonialeService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.SituationMatrimonialeService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.SituationMatrimonialeRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
|
|||||||
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.infocad.parametre.SourceDroitService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.SourceDroitService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.SourceDroitRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SourceDroitRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -1,60 +1,57 @@
|
|||||||
package io.gmss.fiscad.implementations.infocad.parametre;
|
package io.gmss.fiscad.implementations.infocad.parametre;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Section;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
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.infocad.parametre.StructureService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class StructureServiceImpl implements StructureService {
|
public class StructureServiceImpl implements StructureService {
|
||||||
|
|
||||||
private final StructureRepository structureRepository;
|
private final StructureRepository structureRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
public StructureServiceImpl(StructureRepository structureRepository) {
|
@Override
|
||||||
this.structureRepository = structureRepository;
|
public StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException {
|
||||||
|
if (structurePaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("Impossible de créer un nouveau centre ayant un id non null.");
|
||||||
|
}
|
||||||
|
Structure structure= entityFromPayLoadService.getStructureFromPayLoadWeb(structurePaylaodWeb);
|
||||||
|
structure=structureRepository.save(structure);
|
||||||
|
return structureRepository.findStructureToDtoById(structure.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Structure createStructure(Structure structure) throws BadRequestException {
|
public StructurePaylaodWeb updateStructure(Long id, StructurePaylaodWeb structurePaylaodWeb) throws NotFoundException {
|
||||||
if (structure.getId() != null) {
|
if (structurePaylaodWeb.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de créer une structure ayant un id non null.");
|
throw new BadRequestException("ID obligatoire pour une mise à jour.");
|
||||||
}
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("C");
|
|
||||||
builder.append(structureRepository.getLastRecordId() + 1);
|
|
||||||
structure.setCode(builder.toString());
|
|
||||||
return structureRepository.save(structure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
System.out.println(structurePaylaodWeb.getId());
|
||||||
public Structure updateStructure(Long id, Structure structure) throws NotFoundException {
|
Optional<Structure> optionalStructure = structureRepository.findById(structurePaylaodWeb.getId());
|
||||||
|
if(optionalStructure.isEmpty()){
|
||||||
System.out.println("structure = " + structure);
|
throw new NotFoundException("Structure inexistante.");
|
||||||
|
|
||||||
if (structure.getId() == null) {
|
|
||||||
throw new BadRequestException("Impossible de mettre à jour une structure ayant un id null.");
|
|
||||||
}
|
}
|
||||||
if (!structureRepository.existsById(structure.getId())) {
|
|
||||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données.");
|
Structure structure = entityFromPayLoadService.getStructureFromPayLoadWeb(structurePaylaodWeb);
|
||||||
}
|
|
||||||
try {
|
|
||||||
structureRepository.save(structure);
|
structureRepository.save(structure);
|
||||||
|
|
||||||
}catch (Exception e){
|
return structureRepository
|
||||||
e.printStackTrace();
|
.findStructureToDtoById(structure.getId())
|
||||||
}
|
.orElse(null);
|
||||||
|
|
||||||
Structure structure1 = structureRepository.getById(structure.getId());
|
|
||||||
|
|
||||||
return structure1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,26 +65,29 @@ public class StructureServiceImpl implements StructureService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Structure> getStructureList(Pageable pageable) {
|
public Page<StructurePaylaodWeb> getStructureList(Pageable pageable) {
|
||||||
return structureRepository.findAll(pageable);
|
return structureRepository.findAllStructureToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Structure> getStructureList() {
|
public List<StructurePaylaodWeb> getStructureList() {
|
||||||
return structureRepository.findAll();
|
return structureRepository.findAllStructureToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StructureResponse> getStructuresByArrondissement(Long arrondissementID) {
|
public List<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId) {
|
||||||
return structureRepository.getStructureByArrondissement(arrondissementID);
|
return structureRepository.findAllStructureByCommuneToDto(communeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Structure> getStructureById(Long id) {
|
public Page<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId, Pageable pageable) {
|
||||||
if (structureRepository.existsById(id)) {
|
return structureRepository.findAllStructureByCommuneToDtoPageable(communeId,pageable);
|
||||||
return structureRepository.findById(id);
|
|
||||||
} else {
|
|
||||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans la base de données.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<StructurePaylaodWeb> getStructureById(Long id) {
|
||||||
|
return structureRepository.findStructureToDtoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypeContestation;
|
|||||||
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.infocad.parametre.TypeContestationService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypeContestationService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypeContestationRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeContestationRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
|
|||||||
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.infocad.parametre.TypeDomaineService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypeDomaineService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypeDomaineRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeDomaineRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypePersonne;
|
|||||||
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.infocad.parametre.TypePersonneService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypePersonneService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypePersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypePiece;
|
|||||||
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.infocad.parametre.TypePieceService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypePieceService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypePieceRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePieceRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypeRepresentation;
|
|||||||
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.infocad.parametre.TypeRepresentationService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypeRepresentationService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypeRepresentationRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeRepresentationRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.parametre.TypeRue;
|
|||||||
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.infocad.parametre.TypeRueService;
|
import io.gmss.fiscad.interfaces.infocad.parametre.TypeRueService;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.TypeRueRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeRueRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.BatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
|||||||
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.metier.CaracteristiqueBatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.CaracteristiqueBatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueBatimentRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
|
|||||||
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.metier.CaracteristiqueParcelleService;
|
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.CaracteristiqueParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueParcelleRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
|
|||||||
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.metier.CaracteristiqueUniteLogementService;
|
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.CaracteristiqueUniteLogementRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.CaracteristiqueUniteLogementRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
|
|||||||
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.metier.DeclarationNcService;
|
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.DeclarationNcRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.DeclarationNcRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
package io.gmss.fiscad.implementations.rfu.metier;
|
package io.gmss.fiscad.implementations.rfu.metier;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu;
|
import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
|
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
|
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
|
||||||
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.metier.DonneesImpositionTfuService;
|
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
|
||||||
import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse;
|
import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse;
|
||||||
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.DonneesImpositionTfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.DonneesImpositionTfuRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.BaremRfuNonBatiRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.ExerciceRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteActiviteService;
|
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteActiviteService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteActivitePayLoadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteActivitePayLoadWeb;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.EnqueteActiviteRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteActiviteRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -26,18 +26,10 @@ public class EnqueteActiviteServiceImpl implements EnqueteActiviteService {
|
|||||||
if (enqueteActivitePayLoadWeb.getId() != null) {
|
if (enqueteActivitePayLoadWeb.getId() != null) {
|
||||||
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
||||||
}
|
}
|
||||||
if (enqueteActivitePayLoadWeb.getPersonneId() != null) {
|
if (enqueteActivitePayLoadWeb.getPersonneId() == null) {
|
||||||
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
throw new BadRequestException("Veuillez préciser le contribuable : " + enqueteActivitePayLoadWeb.getId());
|
||||||
}
|
|
||||||
if (enqueteActivitePayLoadWeb.getId() != null) {
|
|
||||||
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
|
||||||
}
|
|
||||||
if (enqueteActivitePayLoadWeb.getId() != null) {
|
|
||||||
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
|
||||||
}
|
|
||||||
if (enqueteActivitePayLoadWeb.getId() != null) {
|
|
||||||
throw new BadRequestException("Il ne s'agit pas ici d'une nouvelle activité : " + enqueteActivitePayLoadWeb.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EnqueteActivite enqueteActivite = entityFromPayLoadService.getEnqueteActivitePayLoadWeb(enqueteActivitePayLoadWeb);
|
EnqueteActivite enqueteActivite = entityFromPayLoadService.getEnqueteActivitePayLoadWeb(enqueteActivitePayLoadWeb);
|
||||||
return enqueteActiviteRepository.save(enqueteActivite);
|
return enqueteActiviteRepository.save(enqueteActivite);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.infocad.metier.Upload;
|
|||||||
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
||||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
@@ -13,17 +12,16 @@ import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
|||||||
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.EnqueteBatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteBatimentRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.swing.text.html.Option;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
|
|||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
|
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb;
|
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.EnqueteUniteLogementRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.EnqueteUniteLogementRepository;
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package io.gmss.fiscad.implementations.rfu.metier;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.Fonction;
|
||||||
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
|
import io.gmss.fiscad.interfaces.rfu.metier.FonctionService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.FonctionRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class FonctionServiceImpl implements FonctionService {
|
||||||
|
|
||||||
|
private final FonctionRepository fonctionRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fonction createFonction(FonctionPaylaodWeb fonctionPaylaodWeb) throws BadRequestException {
|
||||||
|
if (fonctionPaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("Impossible de créer un nouveau fonction ayant un id non null.");
|
||||||
|
}
|
||||||
|
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
||||||
|
|
||||||
|
return fonctionRepository.save(fonction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fonction updateFonction(Long id, FonctionPaylaodWeb fonctionPaylaodWeb) throws NotFoundException {
|
||||||
|
if (fonctionPaylaodWeb.getId() == null) {
|
||||||
|
throw new BadRequestException("Impossible de mettre à jour un nouveau fonction ayant un id null.");
|
||||||
|
}
|
||||||
|
if (!fonctionRepository.existsById(fonctionPaylaodWeb.getId())) {
|
||||||
|
throw new NotFoundException("Impossible de trouver le fonction spécifié dans notre base de données.");
|
||||||
|
}
|
||||||
|
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
||||||
|
|
||||||
|
return fonctionRepository.save(fonction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFonction(Long id) throws NotFoundException {
|
||||||
|
Optional<Fonction> fonctionOptional = fonctionRepository.findById(id);
|
||||||
|
if (fonctionOptional.isPresent()) {
|
||||||
|
fonctionRepository.deleteById(fonctionOptional.get().getId());
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("Impossible de trouver le fonction spécifié dans notre base de données.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Fonction> getFonctionList(Pageable pageable) {
|
||||||
|
return fonctionRepository.findAll(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Fonction> getFonctionList() {
|
||||||
|
return fonctionRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FonctionPaylaodWeb> getFonctionListToDto() {
|
||||||
|
return fonctionRepository.findAllFonctionToDto() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<FonctionPaylaodWeb> getFonctionListToDtoPageable(Pageable pageable) {
|
||||||
|
return fonctionRepository.findAllFonctionToDtoPageable(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Fonction> getFonctionById(Long id) {
|
||||||
|
if (fonctionRepository.existsById(id)) {
|
||||||
|
return fonctionRepository.findById(id);
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.enums.StatusAvis;
|
|||||||
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.metier.ImpositionsTfuService;
|
import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
|
|||||||
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.metier.UniteLogementService;
|
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.UniteLogementRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
|
|||||||
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.BaremRfuNonBatiService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.BaremRfuNonBatiRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati;
|
|||||||
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.BaremRfuService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.BaremRfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.enums.TypeCampagne;
|
|||||||
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.CampagneService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.CampagneService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CampagneRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CampagneRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
|
|||||||
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.CaracteristiqueService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.CaracteristiqueService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
|
|||||||
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.CategorieBatimentService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.CategorieBatimentService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CategorieBatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CategorieBatimentRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import io.gmss.fiscad.exceptions.NotFoundException;
|
|||||||
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EquipePayload;
|
import io.gmss.fiscad.paylaods.request.synchronisation.EquipePayload;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.ParticiperPayload;
|
import io.gmss.fiscad.paylaods.request.synchronisation.ParticiperPayload;
|
||||||
import io.gmss.fiscad.repositories.decoupage.SecteurRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CampagneRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CampagneRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.EquipeRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.EquipeRepository;
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
|||||||
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;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.ExerciceRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.TypeCaracteristique;
|
|||||||
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.TypeCaracteristiqueService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.TypeCaracteristiqueService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.TypeCaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.TypeCaracteristiqueRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
|
|||||||
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.ZoneRfuService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.ZoneRfuService;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.ZoneRfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ZoneRfuRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package io.gmss.fiscad.implementations.statistiques;
|
|||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
|
import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
|
||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
import io.gmss.fiscad.paylaods.response.*;
|
import io.gmss.fiscad.paylaods.response.statistique.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.BatimentRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.UniteLogementRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import io.gmss.fiscad.interfaces.synchronisation.RestaurationService;
|
|||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.UploadPayLoad;
|
import io.gmss.fiscad.paylaods.request.synchronisation.UploadPayLoad;
|
||||||
import io.gmss.fiscad.paylaods.response.restoration.*;
|
import io.gmss.fiscad.paylaods.response.restoration.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.*;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.*;
|
||||||
import io.gmss.fiscad.repositories.rfu.metier.*;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneRepository;
|
||||||
import io.gmss.fiscad.service.FileStorageService;
|
import io.gmss.fiscad.service.FileStorageService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ import io.gmss.fiscad.enums.TypeObjet;
|
|||||||
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
|
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
|
||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteAllDataPayload;
|
import io.gmss.fiscad.paylaods.request.EnqueteAllDataPayload;
|
||||||
import io.gmss.fiscad.paylaods.response.*;
|
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.*;
|
import io.gmss.fiscad.paylaods.request.synchronisation.*;
|
||||||
import io.gmss.fiscad.repositories.decoupage.*;
|
import io.gmss.fiscad.paylaods.response.synchronisation.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.*;
|
||||||
import io.gmss.fiscad.repositories.infocad.parametre.*;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.*;
|
||||||
import io.gmss.fiscad.repositories.metadata.*;
|
import io.gmss.fiscad.persistence.repositories.metadata.*;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.CaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.TypeCaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
|
||||||
import io.gmss.fiscad.repositories.rfu.parametre.ZoneRfuRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.TypeCaracteristiqueRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ZoneRfuRepository;
|
||||||
import io.gmss.fiscad.service.FileStorageService;
|
import io.gmss.fiscad.service.FileStorageService;
|
||||||
import io.gmss.fiscad.service.worker.*;
|
import io.gmss.fiscad.service.worker.*;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
@@ -31,7 +31,6 @@ import org.springframework.security.core.Authentication;
|
|||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package io.gmss.fiscad.implementations.user;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||||
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
|
import io.gmss.fiscad.interfaces.user.AvoirFonctionService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class AvoirFonctionServiceImpl implements AvoirFonctionService {
|
||||||
|
|
||||||
|
private final AvoirFonctionRepository avoirFonctionRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService ;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AvoirFonctionPaylaodWeb createAvoirFonction(AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws BadRequestException {
|
||||||
|
if (avoirFonctionPaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("A new avoirFonction id to save must be null or empty.");
|
||||||
|
}
|
||||||
|
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
||||||
|
avoirFonction=avoirFonctionRepository.save(avoirFonction);
|
||||||
|
return avoirFonctionRepository.findAvoirFonctionToDtoById(avoirFonction.getId()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AvoirFonctionPaylaodWeb updateAvoirFonction(Long id, AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws NotFoundException {
|
||||||
|
if (avoirFonctionPaylaodWeb.getId() == null) {
|
||||||
|
throw new BadRequestException("La fonction utilisateur à modifier n'est pas précisée");
|
||||||
|
}
|
||||||
|
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findById(avoirFonctionPaylaodWeb.getId());
|
||||||
|
if(optionalAvoirFonction.isEmpty()){
|
||||||
|
throw new BadRequestException("Impossible de trouver la Fonction utilisateur à modifier");
|
||||||
|
}
|
||||||
|
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
||||||
|
avoirFonction=avoirFonctionRepository.save(avoirFonction);
|
||||||
|
return avoirFonctionRepository.findAvoirFonctionToDtoById(avoirFonction.getId()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAvoirFonction(Long id) throws NotFoundException {
|
||||||
|
if (id == null) {
|
||||||
|
throw new BadRequestException("Impossible de supprimer un avoirFonction null ");
|
||||||
|
}
|
||||||
|
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findById(id);
|
||||||
|
if(optionalAvoirFonction.isEmpty()){
|
||||||
|
throw new BadRequestException("Impossible de trouver le avoirFonction à supprimer");
|
||||||
|
}
|
||||||
|
avoirFonctionRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<AvoirFonctionPaylaodWeb> getAvoirFonctionList(Pageable pageable) {
|
||||||
|
return avoirFonctionRepository.findAllAvoirFonctionToDtoPageable(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AvoirFonctionPaylaodWeb> getAvoirFonctionList() {
|
||||||
|
return avoirFonctionRepository.findAllAvoirFonctionToDto();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<AvoirFonctionPaylaodWeb> getAvoirFonctionById(Long id) {
|
||||||
|
return avoirFonctionRepository.findAvoirFonctionToDtoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AvoirFonctionPaylaodWeb> getAvoirFonctionByUserId(Long userId) {
|
||||||
|
return avoirFonctionRepository.findAllAvoirFonctionByUserToDto(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<AvoirFonctionPaylaodWeb> getAvoirFonctionByUserId(Long userId, Pageable pageable) {
|
||||||
|
return avoirFonctionRepository.findAllAvoirFonctionByUserToDtoPageable(userId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.user.DemandeReinitialisationMPService;
|
import io.gmss.fiscad.interfaces.user.DemandeReinitialisationMPService;
|
||||||
import io.gmss.fiscad.interfaces.user.UserService;
|
import io.gmss.fiscad.interfaces.user.UserService;
|
||||||
import io.gmss.fiscad.repositories.user.DemandeReinitialisationMPRepository;
|
import io.gmss.fiscad.persistence.repositories.user.DemandeReinitialisationMPRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package io.gmss.fiscad.implementations.user;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.user.Profile;
|
||||||
|
import io.gmss.fiscad.enums.UserProfile;
|
||||||
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
|
import io.gmss.fiscad.interfaces.user.ProfileService;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.ProfilePaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.ProfileRepository;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class ProfileServiceImpl implements ProfileService {
|
||||||
|
|
||||||
|
private final ProfileRepository profileRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService ;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Profile createProfile(ProfilePaylaodWeb profilePaylaodWeb) throws BadRequestException {
|
||||||
|
if (profilePaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("A new profile id to save must be null or empty.");
|
||||||
|
}
|
||||||
|
Profile profile = entityFromPayLoadService.getProfileFromPayLoadWeb(profilePaylaodWeb);
|
||||||
|
return profileRepository.save(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Profile updateProfile(Long id, ProfilePaylaodWeb profilePaylaodWeb) throws NotFoundException {
|
||||||
|
if (profilePaylaodWeb.getId() == null) {
|
||||||
|
throw new BadRequestException("A new profile id to save must be null or empty.");
|
||||||
|
}
|
||||||
|
Optional<Profile> optionalProfile= profileRepository.findProfileById(profilePaylaodWeb.getId());
|
||||||
|
if(optionalProfile.isEmpty()){
|
||||||
|
throw new BadRequestException("Impossible de trouver le profile à modifier");
|
||||||
|
}
|
||||||
|
Profile profile = entityFromPayLoadService.getProfileFromPayLoadWeb(profilePaylaodWeb);
|
||||||
|
return profileRepository.save(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteProfile(Long id) throws NotFoundException {
|
||||||
|
if (id == null) {
|
||||||
|
throw new BadRequestException("Impossible de supprimer un profile null ");
|
||||||
|
}
|
||||||
|
Optional<Profile> optionalProfile= profileRepository.findProfileById(id);
|
||||||
|
if(optionalProfile.isEmpty()){
|
||||||
|
throw new BadRequestException("Impossible de trouver le profile à supprimer");
|
||||||
|
}
|
||||||
|
profileRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Profile> getProfileList(Pageable pageable) {
|
||||||
|
return profileRepository.findAll(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Profile> getProfileList() {
|
||||||
|
return profileRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Profile> getProfileById(Long id) {
|
||||||
|
return profileRepository.findProfileById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Profile> getProfileByProfileName(UserProfile userProfile) {
|
||||||
|
return profileRepository.findProfileByNom(userProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean profileExistByProfileName(UserProfile userProfile) {
|
||||||
|
return profileRepository.existsByNom(userProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Profile retrieveProfileByProfileName(UserProfile userProfile) {
|
||||||
|
return profileRepository.getProfilesByNom(userProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.enums.UserRole;
|
|||||||
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.user.RoleService;
|
import io.gmss.fiscad.interfaces.user.RoleService;
|
||||||
import io.gmss.fiscad.repositories.user.RoleRepository;
|
import io.gmss.fiscad.persistence.repositories.user.RoleRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.gmss.fiscad.implementations.user;
|
package io.gmss.fiscad.implementations.user;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
import io.gmss.fiscad.entities.user.Role;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
import io.gmss.fiscad.enums.UserRole;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
@@ -13,8 +12,11 @@ import io.gmss.fiscad.paylaods.JwtAuthenticationResponse;
|
|||||||
import io.gmss.fiscad.paylaods.Login;
|
import io.gmss.fiscad.paylaods.Login;
|
||||||
import io.gmss.fiscad.paylaods.UserListByStructureResponse;
|
import io.gmss.fiscad.paylaods.UserListByStructureResponse;
|
||||||
import io.gmss.fiscad.paylaods.UserResponse;
|
import io.gmss.fiscad.paylaods.UserResponse;
|
||||||
import io.gmss.fiscad.repositories.user.UserRepository;
|
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import io.gmss.fiscad.security.TokenAuthentificationProvider;
|
import io.gmss.fiscad.security.TokenAuthentificationProvider;
|
||||||
|
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
@@ -27,7 +29,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
@@ -37,41 +39,27 @@ public class UserServiceImpl implements UserService {
|
|||||||
private final AuthenticationManager authenticationManager;
|
private final AuthenticationManager authenticationManager;
|
||||||
private final TokenAuthentificationProvider tokenAuthentificationProvider;
|
private final TokenAuthentificationProvider tokenAuthentificationProvider;
|
||||||
private final StructureService structureService;
|
private final StructureService structureService;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
|
|
||||||
public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder, RoleService roleService, AuthenticationManager authenticationManager, TokenAuthentificationProvider tokenAuthentificationProvider, StructureService structureService) {
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
this.passwordEncoder = passwordEncoder;
|
|
||||||
this.roleService = roleService;
|
|
||||||
this.authenticationManager = authenticationManager;
|
|
||||||
this.tokenAuthentificationProvider = tokenAuthentificationProvider;
|
|
||||||
this.structureService = structureService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User createUser(User user, boolean resetPassword) {
|
public UserPaylaodWeb createUser(UserPaylaodWeb userPaylaodWeb) {
|
||||||
|
|
||||||
if (userRepository.findByUsername(user.getUsername()).isPresent()) {
|
if ((userRepository.findByUsername(userPaylaodWeb.getLogin()).isPresent())
|
||||||
throw new BadRequestException("Ce nom d'utilisateur existe déjà.");
|
|| (userRepository.findByEmail(userPaylaodWeb.getEmail()).isPresent())) {
|
||||||
|
throw new BadRequestException("Cet utilisateur existe déjà.");
|
||||||
|
}
|
||||||
|
if (userPaylaodWeb.getId() != null) {
|
||||||
|
throw new BadRequestException("Cet utilisateur existe déjà.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.getId() != null) {
|
User user = entityFromPayLoadService.getUserFromPayLoadWeb(userPaylaodWeb);
|
||||||
throw new BadRequestException("Cet utilisateur existe déjà dans la base de donnéees.");
|
user.setPassword(passwordEncoder.encode(userPaylaodWeb.getPassword()));
|
||||||
}
|
|
||||||
|
|
||||||
Set<Role> roleSet = new HashSet<>();
|
|
||||||
|
|
||||||
user.getRoles().stream().forEach(role -> {
|
|
||||||
if (roleService.roleExistByRoleName(role.getNom())) {
|
|
||||||
roleSet.add(roleService.retrieveRoleByRoleName(role.getNom()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
user.setUsername(user.getEmail());
|
|
||||||
user.setResetPassword(resetPassword);
|
|
||||||
user.setRoles(roleSet);
|
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
return user;
|
|
||||||
|
return userRepository.findUserToDtoById(userPaylaodWeb.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,29 +86,23 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User updateUser(Long id, User user) {
|
public UserPaylaodWeb updateUser(Long id, UserPaylaodWeb userPaylaodWeb) {
|
||||||
User user1 = userRepository.findById(id)
|
|
||||||
.orElseThrow(() -> new NotFoundException(
|
|
||||||
String.format("L'utilisateur ayant pour id %s n'existe pas.", id)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (user.getRoles() == null || user.getRoles().isEmpty()) {
|
|
||||||
user.setRoles(user1.getRoles());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.getPassword() == null || user.getPassword().isBlank()) {
|
if ((userRepository.findByUsername(userPaylaodWeb.getLogin()).isEmpty())
|
||||||
user.setPassword(user1.getPassword());
|
|| (userRepository.findByEmail(userPaylaodWeb.getEmail()).isEmpty())) {
|
||||||
} else {
|
throw new BadRequestException("Cet utilisateur n'existe pas.");
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
|
||||||
}
|
}
|
||||||
|
if (userPaylaodWeb.getId() == null) {
|
||||||
if (user.getEmail() == null || user.getEmail().isEmpty()) {
|
throw new BadRequestException("Cet utilisateur n'existe déjà.");
|
||||||
user.setEmail(user1.getEmail());
|
|
||||||
} else {
|
|
||||||
user.setEmail(user.getEmail());
|
|
||||||
}
|
}
|
||||||
user.setResetPassword(user1.isResetPassword());
|
if(userRepository.findUserToDtoById(userPaylaodWeb.getId()).isEmpty()){
|
||||||
return userRepository.save(user);
|
throw new BadRequestException("Cet utilisateur n'existe pas.");
|
||||||
|
}
|
||||||
|
User user = entityFromPayLoadService.getUserFromPayLoadWeb(userPaylaodWeb);
|
||||||
|
user.setActive(true);
|
||||||
|
user.setResetPassword(false);
|
||||||
|
userRepository.save(user);
|
||||||
|
return userRepository.findUserToDtoById(userPaylaodWeb.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -145,42 +127,30 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<User> getUserList(Pageable pageable) {
|
public Page<UserPaylaodWeb> getUserList(Pageable pageable) {
|
||||||
return userRepository.findAll(pageable);
|
|
||||||
|
return userRepository.findAllUserToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUserList() {
|
public List<UserPaylaodWeb> getUserList() {
|
||||||
return userRepository.findAll();
|
return userRepository.findAllUserToDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserResponse> getAllUserListResponse() {
|
public List<UserResponse> getAllUserListResponse() {
|
||||||
return getUserResponses(getUserList());
|
|
||||||
|
return null ;//getUserResponses(getUserList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getActivatedUserListByStructure(Long structureId) {
|
public List<User> getActivatedUserListByStructure(Long structureId) {
|
||||||
Set<Role> roleSet = new HashSet<>();
|
return null;
|
||||||
roleSet.add(roleService.retrieveRoleByRoleName(UserRole.ROLE_ANONYMOUS));
|
|
||||||
Optional<Structure> structureOptional = structureService.getStructureById(structureId);
|
|
||||||
if (structureOptional.isPresent()) {
|
|
||||||
return userRepository.findAllByStructureAndRolesNotIn(structureOptional.get(), roleSet);
|
|
||||||
} else {
|
|
||||||
throw new NotFoundException("Impossible de trouver la structure spécifiée.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUserUnActivatedListByStructure(Long structureId) {
|
public List<User> getUserUnActivatedListByStructure(Long structureId) {
|
||||||
Set<Role> roleSet = new HashSet<>();
|
return null;
|
||||||
roleSet.add(roleService.retrieveRoleByRoleName(UserRole.ROLE_ANONYMOUS));
|
|
||||||
Optional<Structure> structureOptional = structureService.getStructureById(structureId);
|
|
||||||
if (structureOptional.isPresent()) {
|
|
||||||
return userRepository.findAllByStructureAndRolesIn(structureOptional.get(), roleSet);
|
|
||||||
} else {
|
|
||||||
throw new NotFoundException("Impossible de trouver la structure spécifiée.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<UserResponse> getUserResponses(List<User> users) {
|
private static List<UserResponse> getUserResponses(List<User> users) {
|
||||||
@@ -194,7 +164,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
user.getUsername(),
|
user.getUsername(),
|
||||||
user.isActive(),
|
user.isActive(),
|
||||||
user.isResetPassword(),
|
user.isResetPassword(),
|
||||||
user.getRoles(),
|
user.getAvoirFonctions(),
|
||||||
user.getStructure(),
|
user.getStructure(),
|
||||||
user.getIdCampagneCourant(),
|
user.getIdCampagneCourant(),
|
||||||
user.getIdSecteurCourant()))
|
user.getIdSecteurCourant()))
|
||||||
@@ -213,14 +183,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
String.format("L'utilisateur ayant pour id %s n'existe pas.", id)
|
String.format("L'utilisateur ayant pour id %s n'existe pas.", id)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<User> getUserByProfil(UserRole userRole) {
|
|
||||||
return userRepository.findAllByRolesContains(userRole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getUserByUsername(String username) {
|
public User getUserByUsername(String username) {
|
||||||
return userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
return userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
||||||
@@ -243,33 +208,25 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User resetPassword(String username, String password) {
|
public UserPaylaodWeb resetPassword(String username, String password) {
|
||||||
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
||||||
String.format("L'utilisateur %s n'existe pas.", username)
|
String.format("L'utilisateur %s n'existe pas.", username)
|
||||||
));
|
));
|
||||||
//String pwd = PasswordGenerator.generatePassword();
|
|
||||||
user.setPassword(passwordEncoder.encode(password));
|
user.setPassword(passwordEncoder.encode(password));
|
||||||
user.setResetPassword(true);
|
user.setResetPassword(true);
|
||||||
userRepository.save(user);
|
user= userRepository.save(user);
|
||||||
return user;
|
Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId());
|
||||||
|
return optionalUserPaylaodWeb.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public User assignStructureToUser(Structure structure) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User validateUserAccount(String username, UserRole userRole) {
|
public User validateUserAccount(String username) {
|
||||||
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
||||||
String.format("L'utilisateur %s n'existe pas.", username)
|
String.format("L'utilisateur %s n'existe pas.", username)
|
||||||
));
|
));
|
||||||
Set<Role> roleSet = new HashSet<>();
|
|
||||||
if (roleService.roleExistByRoleName(userRole)) {
|
|
||||||
roleSet.add(roleService.retrieveRoleByRoleName(userRole));
|
|
||||||
}
|
|
||||||
user.setRoles(roleSet);
|
|
||||||
user.setResetPassword(false);
|
user.setResetPassword(false);
|
||||||
|
user.setActive(true);
|
||||||
return userRepository.save(user);
|
return userRepository.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,26 +254,41 @@ public class UserServiceImpl implements UserService {
|
|||||||
user.getUsername(),
|
user.getUsername(),
|
||||||
user.isActive(),
|
user.isActive(),
|
||||||
user.isResetPassword(),
|
user.isResetPassword(),
|
||||||
user.getRoles(),
|
user.getAvoirFonctions(),
|
||||||
user.getStructure(),
|
user.getStructure(),
|
||||||
user.getIdCampagneCourant(),
|
user.getIdCampagneCourant(),
|
||||||
user.getIdSecteurCourant());
|
user.getIdSecteurCourant());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static List<UserResponse> getUserResponses(List<User> users) {
|
@Override
|
||||||
// return users.stream()
|
public Optional<UserPaylaodWeb> getUserByToDto(String username) {
|
||||||
// .map(user -> new UserResponse(
|
return userRepository.findUserToDtoByUserName(username);
|
||||||
// user.getId(),
|
}
|
||||||
// user.getNom(),
|
|
||||||
// user.getPrenom(),
|
@Override
|
||||||
// user.getTel(),
|
public Optional<UserPaylaodWeb> getUserByIdToDto(Long id) {
|
||||||
// user.getEmail(),
|
return userRepository.findUserToDtoById(id);
|
||||||
// user.getUsername(),
|
}
|
||||||
// user.isActive(),
|
|
||||||
// user.isResetPassword(),
|
@Override
|
||||||
// user.getRoles(),
|
public List<UserPaylaodWeb> getListUserToDto() {
|
||||||
// user.getStructure()))
|
return userRepository.findAllUserToDto();
|
||||||
// .collect(Collectors.toList());
|
}
|
||||||
// }
|
|
||||||
|
@Override
|
||||||
|
public Page<UserPaylaodWeb> getListUserToDto(Pageable pageable) {
|
||||||
|
return userRepository.findAllUserToDtoPageable(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserPaylaodWeb> getListUserByStructureToDto(Long structureId) {
|
||||||
|
return userRepository.findAllUserByStructureToDto(structureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<UserPaylaodWeb> getListUserByStructureToDto(Long structureId, Pageable pageable) {
|
||||||
|
return userRepository.findAllUserByStructureToDtoPageable(structureId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user