Compare commits
4 Commits
209d1cd777
...
features/c
| Author | SHA1 | Date | |
|---|---|---|---|
| 95eb4ad0b9 | |||
| 743bb46b47 | |||
| 2c0aad4d51 | |||
| fc6ff679f0 |
@@ -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) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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.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;
|
||||||
@@ -35,11 +36,11 @@ public class SecteurDecoupageController {
|
|||||||
|
|
||||||
|
|
||||||
@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) {
|
||||||
@@ -59,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) {
|
||||||
@@ -152,11 +153,58 @@ 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
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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,18 +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<>();
|
|
||||||
//user.setAvoirFonctions(roleSet);
|
|
||||||
user.setStructure(structureService.getStructureById(userRequest.getStructureId()).get());
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ public class AvoirFonctionController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
|
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
|
||||||
try {
|
try {
|
||||||
AvoirFonction avoirFonction = avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, avoirFonction, "Fonction utilisateur créée avec succès."),
|
new ApiResponse<>(true, avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb), "Fonction utilisateur créée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -131,52 +130,6 @@ public class AvoirFonctionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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("/utilisateur-id/{userId}")
|
|
||||||
public ResponseEntity<?> getByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getUserAvoirFonctionById(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("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
@@ -203,4 +156,79 @@ public class AvoirFonctionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
@@ -229,17 +232,11 @@ 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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "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);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
logger.error(e.getLocalizedMessage());
|
logger.error(e.getLocalizedMessage());
|
||||||
@@ -257,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);
|
||||||
@@ -343,26 +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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ 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 {
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ 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;
|
||||||
|
|
||||||
@@ -61,4 +61,17 @@ public class Structure extends BaseEntity implements Serializable {
|
|||||||
)
|
)
|
||||||
private Set<Arrondissement> arrondissements;
|
private Set<Arrondissement> arrondissements;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Structure{" +
|
||||||
|
"id=" + id +
|
||||||
|
", code='" + code + '\'' +
|
||||||
|
", nom='" + nom + '\'' +
|
||||||
|
", ifu='" + ifu + '\'' +
|
||||||
|
", rccm='" + rccm + '\'' +
|
||||||
|
", tel='" + tel + '\'' +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", adresse='" + adresse + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
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;
|
||||||
@@ -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,6 +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.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.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
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;
|
||||||
@@ -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,6 +4,7 @@ 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.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.DepartementRepository;
|
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;
|
||||||
@@ -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.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
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;
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ 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.interfaces.decoupage.SecteurService;
|
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.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
|
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;
|
||||||
@@ -23,26 +26,33 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
|||||||
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||||
private final SecteurService secteurService;
|
private final SecteurService secteurService;
|
||||||
private final ParcelleRepository parcelleRepository;
|
private final ParcelleRepository parcelleRepository;
|
||||||
|
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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
|
||||||
@@ -56,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public class SecteurServiceImpl implements SecteurService {
|
|||||||
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);
|
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
||||||
|
|
||||||
secteur = secteurRepository.save(secteur);
|
secteur = secteurRepository.save(secteur);
|
||||||
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class SectionServiceImpl implements SectionService {
|
|||||||
throw new BadRequestException("Impossible de créer une nouvelle section ayant un id non null.");
|
throw new BadRequestException("Impossible de créer une nouvelle section ayant un id non null.");
|
||||||
}
|
}
|
||||||
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
||||||
|
section=sectionRepository.save(section);
|
||||||
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ public class SectionServiceImpl implements SectionService {
|
|||||||
throw new NotFoundException("Impossible de trouver le section spécifié.");
|
throw new NotFoundException("Impossible de trouver le section spécifié.");
|
||||||
}
|
}
|
||||||
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
|
||||||
sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
section=sectionRepository.save(section);
|
||||||
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
|
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;
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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.persistence.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,25 +22,27 @@ public class AvoirFonctionServiceImpl implements AvoirFonctionService {
|
|||||||
private final EntityFromPayLoadService entityFromPayLoadService ;
|
private final EntityFromPayLoadService entityFromPayLoadService ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AvoirFonction createAvoirFonction(AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws BadRequestException {
|
public AvoirFonctionPaylaodWeb createAvoirFonction(AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws BadRequestException {
|
||||||
if (avoirFonctionPaylaodWeb.getId() != null) {
|
if (avoirFonctionPaylaodWeb.getId() != null) {
|
||||||
throw new BadRequestException("A new avoirFonction id to save must be null or empty.");
|
throw new BadRequestException("A new avoirFonction id to save must be null or empty.");
|
||||||
}
|
}
|
||||||
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
||||||
return avoirFonctionRepository.save(avoirFonction);
|
avoirFonction=avoirFonctionRepository.save(avoirFonction);
|
||||||
|
return avoirFonctionRepository.findAvoirFonctionToDtoById(avoirFonction.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AvoirFonction updateAvoirFonction(Long id, AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws NotFoundException {
|
public AvoirFonctionPaylaodWeb updateAvoirFonction(Long id, AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws NotFoundException {
|
||||||
if (avoirFonctionPaylaodWeb.getId() == null) {
|
if (avoirFonctionPaylaodWeb.getId() == null) {
|
||||||
throw new BadRequestException("A new avoirFonction id to save must be null or empty.");
|
throw new BadRequestException("La fonction utilisateur à modifier n'est pas précisée");
|
||||||
}
|
}
|
||||||
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findAvoirFonctionById(avoirFonctionPaylaodWeb.getId());
|
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findById(avoirFonctionPaylaodWeb.getId());
|
||||||
if(optionalAvoirFonction.isEmpty()){
|
if(optionalAvoirFonction.isEmpty()){
|
||||||
throw new BadRequestException("Impossible de trouver la Fonction utilisateur à modifier");
|
throw new BadRequestException("Impossible de trouver la Fonction utilisateur à modifier");
|
||||||
}
|
}
|
||||||
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
AvoirFonction avoirFonction= entityFromPayLoadService.getAvoirFonctionFromPayLoadWeb(avoirFonctionPaylaodWeb);
|
||||||
return avoirFonctionRepository.save(avoirFonction);
|
avoirFonction=avoirFonctionRepository.save(avoirFonction);
|
||||||
|
return avoirFonctionRepository.findAvoirFonctionToDtoById(avoirFonction.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +50,7 @@ public class AvoirFonctionServiceImpl implements AvoirFonctionService {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new BadRequestException("Impossible de supprimer un avoirFonction null ");
|
throw new BadRequestException("Impossible de supprimer un avoirFonction null ");
|
||||||
}
|
}
|
||||||
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findAvoirFonctionById(id);
|
Optional<AvoirFonction> optionalAvoirFonction= avoirFonctionRepository.findById(id);
|
||||||
if(optionalAvoirFonction.isEmpty()){
|
if(optionalAvoirFonction.isEmpty()){
|
||||||
throw new BadRequestException("Impossible de trouver le avoirFonction à supprimer");
|
throw new BadRequestException("Impossible de trouver le avoirFonction à supprimer");
|
||||||
}
|
}
|
||||||
@@ -56,25 +58,28 @@ public class AvoirFonctionServiceImpl implements AvoirFonctionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<AvoirFonction> getAvoirFonctionList(Pageable pageable) {
|
public Page<AvoirFonctionPaylaodWeb> getAvoirFonctionList(Pageable pageable) {
|
||||||
return avoirFonctionRepository.findAll(pageable);
|
return avoirFonctionRepository.findAllAvoirFonctionToDtoPageable(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AvoirFonction> getAvoirFonctionList() {
|
public List<AvoirFonctionPaylaodWeb> getAvoirFonctionList() {
|
||||||
return avoirFonctionRepository.findAll();
|
return avoirFonctionRepository.findAllAvoirFonctionToDto();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<AvoirFonction> getAvoirFonctionById(Long id) {
|
|
||||||
return avoirFonctionRepository.findAvoirFonctionById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AvoirFonction> getUserAvoirFonctionById(Long userId) {
|
public Optional<AvoirFonctionPaylaodWeb> getAvoirFonctionById(Long id) {
|
||||||
return avoirFonctionRepository.findAvoirFonctionByUser_Id(userId);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,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.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
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;
|
||||||
@@ -26,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 {
|
||||||
|
|
||||||
@@ -36,42 +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,43 +127,29 @@ 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<>();
|
|
||||||
// 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.");
|
|
||||||
// }
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUserUnActivatedListByStructure(Long structureId) {
|
public List<User> getUserUnActivatedListByStructure(Long structureId) {
|
||||||
// Set<Role> roleSet = new HashSet<>();
|
|
||||||
// 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.");
|
|
||||||
// }
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,15 +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);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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(
|
||||||
@@ -246,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,19 +261,34 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
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.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -17,11 +18,11 @@ public interface ArrondissementService {
|
|||||||
|
|
||||||
void deleteArrondissement(Long id) throws NotFoundException;
|
void deleteArrondissement(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Arrondissement> getArrondissementList(Pageable pageable);
|
|
||||||
|
|
||||||
List<Arrondissement> getArrondissementList();
|
Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable);
|
||||||
|
List<ArrondissementPaylaodWeb> getArrondissementList();
|
||||||
|
List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId);
|
||||||
|
Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId,Pageable pageable);
|
||||||
|
|
||||||
Optional<Arrondissement> getArrondissementById(Long id);
|
Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id);
|
||||||
|
|
||||||
List<Arrondissement> getArrondissementByComune(Long communeId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
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.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -17,11 +18,12 @@ public interface CommuneService {
|
|||||||
|
|
||||||
void deleteCommune(Long id) throws NotFoundException;
|
void deleteCommune(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Commune> getCommuneList(Pageable pageable);
|
Page<CommunePaylaodWeb> getCommuneList(Pageable pageable);
|
||||||
|
|
||||||
List<Commune> getCommuneList();
|
List<CommunePaylaodWeb> getCommuneList();
|
||||||
|
|
||||||
List<Commune> getCommunesByDepartement(Long departementId);
|
List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId);
|
||||||
|
Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId,Pageable pageable);
|
||||||
|
|
||||||
Optional<Commune> getCommuneById(Long id);
|
Optional<CommunePaylaodWeb> getCommuneById(Long id) ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
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.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -17,9 +18,9 @@ public interface DepartementService {
|
|||||||
|
|
||||||
void deleteDepartement(Long id) throws NotFoundException;
|
void deleteDepartement(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Departement> getDepartementList(Pageable pageable);
|
Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable);
|
||||||
|
|
||||||
List<Departement> getDepartementList();
|
List<DepartementPaylaodWeb> getDepartementList();
|
||||||
|
|
||||||
Optional<Departement> getDepartementById(Long id);
|
Optional<DepartementPaylaodWeb> getDepartementById(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||||
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.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -17,11 +18,11 @@ public interface QuartierService {
|
|||||||
|
|
||||||
void deleteQuartier(Long id) throws NotFoundException;
|
void deleteQuartier(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Quartier> getQuartierList(Pageable pageable);
|
|
||||||
|
|
||||||
List<Quartier> getQuartierList();
|
Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable);
|
||||||
|
List<QuartierPaylaodWeb> getQuartierList();
|
||||||
|
List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId);
|
||||||
|
Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId,Pageable pageable);
|
||||||
|
|
||||||
Optional<Quartier> getQuartierById(Long id);
|
Optional<QuartierPaylaodWeb> getQuartierById(Long id);
|
||||||
|
|
||||||
List<Quartier> getQuartierByArrondissement(Long arrondissementId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package io.gmss.fiscad.interfaces.decoupage;
|
|||||||
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.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -12,15 +14,20 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public interface SecteurDecoupageService {
|
public interface SecteurDecoupageService {
|
||||||
|
|
||||||
SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException;
|
SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteur) throws BadRequestException;
|
||||||
|
|
||||||
SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException;
|
SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteur) throws NotFoundException;
|
||||||
|
|
||||||
void deleteSecteurDecoupage(Long id) throws NotFoundException;
|
void deleteSecteurDecoupage(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable);
|
Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable);
|
||||||
|
|
||||||
List<SecteurDecoupage> getSecteurDecoupageList();
|
List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList();
|
||||||
|
|
||||||
|
Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId,Pageable pageable);
|
||||||
|
List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId);
|
||||||
|
|
||||||
|
Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id);
|
||||||
|
|
||||||
Optional<SecteurDecoupage> getSecteurDecoupageById(Long id);
|
Optional<SecteurDecoupage> getSecteurDecoupageById(Long id);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.interfaces.infocad.parametre;
|
|||||||
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.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -11,18 +12,23 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface StructureService {
|
public interface StructureService {
|
||||||
|
StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException;
|
||||||
|
|
||||||
Structure createStructure(Structure structure) throws BadRequestException;
|
StructurePaylaodWeb updateStructure(Long id, StructurePaylaodWeb structurePaylaodWeb) throws NotFoundException;
|
||||||
|
|
||||||
Structure updateStructure(Long id, Structure structure) throws NotFoundException;
|
|
||||||
|
|
||||||
void deleteStructure(Long id) throws NotFoundException;
|
void deleteStructure(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Structure> getStructureList(Pageable pageable);
|
Page<StructurePaylaodWeb> getStructureList(Pageable pageable);
|
||||||
|
List<StructurePaylaodWeb> getStructureList();
|
||||||
|
|
||||||
List<Structure> getStructureList();
|
List<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId);
|
||||||
|
|
||||||
|
Page<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId,Pageable pageable);
|
||||||
|
|
||||||
|
Optional<StructurePaylaodWeb> getStructureById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
//List<StructureResponse> getStructuresByArrondissement(Long arrondissementID);
|
||||||
|
|
||||||
List<StructureResponse> getStructuresByArrondissement(Long arrondissementID);
|
|
||||||
|
|
||||||
Optional<Structure> getStructureById(Long id);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,18 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public interface AvoirFonctionService {
|
public interface AvoirFonctionService {
|
||||||
|
|
||||||
AvoirFonction createAvoirFonction(AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws BadRequestException;
|
AvoirFonctionPaylaodWeb createAvoirFonction(AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws BadRequestException;
|
||||||
|
|
||||||
AvoirFonction updateAvoirFonction(Long id, AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws NotFoundException;
|
AvoirFonctionPaylaodWeb updateAvoirFonction(Long id, AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) throws NotFoundException;
|
||||||
|
|
||||||
void deleteAvoirFonction(Long id) throws NotFoundException;
|
void deleteAvoirFonction(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<AvoirFonction> getAvoirFonctionList(Pageable pageable);
|
Page<AvoirFonctionPaylaodWeb> getAvoirFonctionList(Pageable pageable);
|
||||||
|
|
||||||
List<AvoirFonction> getAvoirFonctionList();
|
List<AvoirFonctionPaylaodWeb> getAvoirFonctionList();
|
||||||
|
|
||||||
Optional<AvoirFonction> getAvoirFonctionById(Long id);
|
Optional<AvoirFonctionPaylaodWeb> getAvoirFonctionById(Long id);
|
||||||
List<AvoirFonction> getUserAvoirFonctionById(Long userId);
|
List<AvoirFonctionPaylaodWeb> getAvoirFonctionByUserId(Long userId);
|
||||||
|
Page<AvoirFonctionPaylaodWeb> getAvoirFonctionByUserId(Long userId,Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,26 +7,27 @@ 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.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
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 java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
UserPaylaodWeb createUser(UserPaylaodWeb userPaylaodWeb);
|
||||||
User createUser(User user, boolean resetPassword);
|
|
||||||
|
|
||||||
JwtAuthenticationResponse loginUser(Login login);
|
JwtAuthenticationResponse loginUser(Login login);
|
||||||
|
|
||||||
User updateUser(Long id, User user);
|
UserPaylaodWeb updateUser(Long id, UserPaylaodWeb userPaylaodWeb);
|
||||||
|
|
||||||
void updatePassword(String username, String pwd);
|
void updatePassword(String username, String pwd);
|
||||||
|
|
||||||
void deleteUser(Long id);
|
void deleteUser(Long id);
|
||||||
|
|
||||||
Page<User> getUserList(Pageable pageable);
|
Page<UserPaylaodWeb> getUserList(Pageable pageable);
|
||||||
|
|
||||||
List<User> getUserList();
|
List<UserPaylaodWeb> getUserList();
|
||||||
|
|
||||||
List<UserResponse> getAllUserListResponse();
|
List<UserResponse> getAllUserListResponse();
|
||||||
|
|
||||||
@@ -38,15 +39,16 @@ public interface UserService {
|
|||||||
|
|
||||||
User getUserById(Long id);
|
User getUserById(Long id);
|
||||||
|
|
||||||
|
|
||||||
User getUserByUsername(String username);
|
User getUserByUsername(String username);
|
||||||
|
|
||||||
|
|
||||||
User activateOrNotUser(Long id);
|
User activateOrNotUser(Long id);
|
||||||
|
|
||||||
User resetPassword(String username, String password);
|
UserPaylaodWeb resetPassword(String username, String password);
|
||||||
|
|
||||||
User assignStructureToUser(Structure structure);
|
|
||||||
|
|
||||||
User validateUserAccount(String username, UserRole userRole);
|
User validateUserAccount(String username);
|
||||||
|
|
||||||
UserListByStructureResponse getListUserByStructure(Long structureId);
|
UserListByStructureResponse getListUserByStructure(Long structureId);
|
||||||
|
|
||||||
@@ -54,6 +56,11 @@ public interface UserService {
|
|||||||
|
|
||||||
UserResponse getUserResponseFromUser(User user);
|
UserResponse getUserResponseFromUser(User user);
|
||||||
|
|
||||||
List<User> getUserByProfil(UserRole userRole);
|
Optional<UserPaylaodWeb> getUserByToDto(String username);
|
||||||
|
Optional<UserPaylaodWeb> getUserByIdToDto(Long id);
|
||||||
|
List<UserPaylaodWeb> getListUserToDto();
|
||||||
|
Page<UserPaylaodWeb> getListUserToDto(Pageable pageable);
|
||||||
|
List<UserPaylaodWeb> getListUserByStructureToDto(Long structureId);
|
||||||
|
Page<UserPaylaodWeb> getListUserByStructureToDto(Long structureId, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ArrondissementPaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String code;
|
||||||
|
private String nom;
|
||||||
|
private Long communeId;
|
||||||
|
private String communeCode;
|
||||||
|
private String communeNom;
|
||||||
|
|
||||||
|
public ArrondissementPaylaodWeb(Long id,
|
||||||
|
String code,
|
||||||
|
String nom,
|
||||||
|
Long communeId,
|
||||||
|
String communeCode,
|
||||||
|
String communeNom) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.nom = nom;
|
||||||
|
this.communeId = communeId;
|
||||||
|
this.communeCode = communeCode;
|
||||||
|
this.communeNom = communeNom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,9 +20,41 @@ public class AvoirFonctionPaylaodWeb {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFin;
|
private LocalDate dateFin;
|
||||||
private Long fonctionId;
|
private Long fonctionId;
|
||||||
|
private String fonctionCode;
|
||||||
private String fonctionNom;
|
private String fonctionNom;
|
||||||
private Long userId ;
|
private Long userId ;
|
||||||
private Long userNom ;
|
private String userLogin ;
|
||||||
@Enumerated(EnumType.STRING)
|
private String userNom ;
|
||||||
|
private String userPrenom ;
|
||||||
|
private String email ;
|
||||||
|
//@Enumerated(EnumType.STRING)
|
||||||
private Titre titre;
|
private Titre titre;
|
||||||
|
|
||||||
|
public AvoirFonctionPaylaodWeb(
|
||||||
|
Long id,
|
||||||
|
LocalDate dateDebut,
|
||||||
|
LocalDate dateFin,
|
||||||
|
Long fonctionId,
|
||||||
|
String fonctionCode,
|
||||||
|
String fonctionNom,
|
||||||
|
Long userId,
|
||||||
|
String userLogin,
|
||||||
|
String userNom,
|
||||||
|
String userPrenom,
|
||||||
|
String email,
|
||||||
|
Titre titre)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.dateDebut = dateDebut;
|
||||||
|
this.dateFin = dateFin;
|
||||||
|
this.fonctionId = fonctionId;
|
||||||
|
this.fonctionCode = fonctionCode;
|
||||||
|
this.fonctionNom = fonctionNom;
|
||||||
|
this.userId = userId;
|
||||||
|
this.userLogin = userLogin;
|
||||||
|
this.userNom = userNom;
|
||||||
|
this.userPrenom = userPrenom;
|
||||||
|
this.email = email;
|
||||||
|
this.titre = titre;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CommunePaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String code;
|
||||||
|
private String nom;
|
||||||
|
private Long departementId;
|
||||||
|
private String departementCode;
|
||||||
|
private String departementNom;
|
||||||
|
|
||||||
|
public CommunePaylaodWeb(Long id, String code, String nom, Long departementId,String departementCode, String departementNom) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.nom = nom;
|
||||||
|
this.departementId = departementId;
|
||||||
|
this.departementCode = departementCode;
|
||||||
|
this.departementNom = departementNom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DepartementPaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String code;
|
||||||
|
private String nom;
|
||||||
|
|
||||||
|
public DepartementPaylaodWeb(Long id, String code, String nom) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.nom = nom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QuartierPaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String code;
|
||||||
|
private String nom;
|
||||||
|
private Long arrondissementId;
|
||||||
|
private String arrondissementCode;
|
||||||
|
private String arrondissementNom;
|
||||||
|
|
||||||
|
public QuartierPaylaodWeb(Long id,
|
||||||
|
String code,
|
||||||
|
String nom,
|
||||||
|
Long arrondissementId,
|
||||||
|
String arrondissementCode,
|
||||||
|
String arrondissementNom) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.nom = nom;
|
||||||
|
this.arrondissementId = arrondissementId;
|
||||||
|
this.arrondissementCode = arrondissementCode;
|
||||||
|
this.arrondissementNom = arrondissementNom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecteurDecoupagePaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
|
private LocalDate dateDebut;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
|
private LocalDate dateFin;
|
||||||
|
private Long secteurId;
|
||||||
|
private String secteurCode;
|
||||||
|
private String secteurNom;
|
||||||
|
private Long arrondissementId;
|
||||||
|
private String arrondissementCode;
|
||||||
|
private String arrondissementNom;
|
||||||
|
private Long quartierId;
|
||||||
|
private String quartierCode;
|
||||||
|
private String quartierNom;
|
||||||
|
|
||||||
|
public SecteurDecoupagePaylaodWeb(Long id, LocalDate dateDebut, LocalDate dateFin, Long secteurId, String secteurCode, String secteurNom, Long arrondissementId, String arrondissementCode, String arrondissementNom, Long quartierId, String quartierCode, String quartierNom) {
|
||||||
|
this.id = id;
|
||||||
|
this.dateDebut = dateDebut;
|
||||||
|
this.dateFin = dateFin;
|
||||||
|
this.secteurId = secteurId;
|
||||||
|
this.secteurCode = secteurCode;
|
||||||
|
this.secteurNom = secteurNom;
|
||||||
|
this.arrondissementId = arrondissementId;
|
||||||
|
this.arrondissementCode = arrondissementCode;
|
||||||
|
this.arrondissementNom = arrondissementNom;
|
||||||
|
this.quartierId = quartierId;
|
||||||
|
this.quartierCode = quartierCode;
|
||||||
|
this.quartierNom = quartierNom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StructurePaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String code ;
|
||||||
|
private String nom ;
|
||||||
|
private Long communeId ;
|
||||||
|
private String communeCode ;
|
||||||
|
private String communeNom ;
|
||||||
|
private String ifu;
|
||||||
|
private String rccm;
|
||||||
|
private String tel;
|
||||||
|
private String email;
|
||||||
|
private String adresse;
|
||||||
|
|
||||||
|
public StructurePaylaodWeb(Long id, String code, String nom, Long communeId, String communeCode, String communeNom, String ifu, String rccm, String tel, String email, String adresse) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.nom = nom;
|
||||||
|
this.communeId = communeId;
|
||||||
|
this.communeCode = communeCode;
|
||||||
|
this.communeNom = communeNom;
|
||||||
|
this.ifu = ifu;
|
||||||
|
this.rccm = rccm;
|
||||||
|
this.tel = tel;
|
||||||
|
this.email = email;
|
||||||
|
this.adresse = adresse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
|
import io.gmss.fiscad.enums.Titre;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserPaylaodWeb {
|
||||||
|
private Long id;
|
||||||
|
private String nom;
|
||||||
|
private String prenom;
|
||||||
|
private String telephone;
|
||||||
|
private String login;
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private Long structureId;
|
||||||
|
private String structureCode;
|
||||||
|
private String structureNom;
|
||||||
|
|
||||||
|
public UserPaylaodWeb(Long id,
|
||||||
|
String nom,
|
||||||
|
String prenom,
|
||||||
|
String telephone,
|
||||||
|
String login,
|
||||||
|
String email,
|
||||||
|
Long structureId,
|
||||||
|
String structureCode,
|
||||||
|
String structureNom) {
|
||||||
|
this.id = id;
|
||||||
|
this.nom = nom;
|
||||||
|
this.prenom = prenom;
|
||||||
|
this.telephone = telephone;
|
||||||
|
this.login = login;
|
||||||
|
this.email = email;
|
||||||
|
this.structureId = structureId;
|
||||||
|
this.structureCode = structureCode;
|
||||||
|
this.structureNom = structureNom;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,17 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
|||||||
|
|
||||||
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.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
|
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
|
||||||
import io.gmss.fiscad.paylaods.response.synchronisation.ArrondissementSyncResponse;
|
import io.gmss.fiscad.paylaods.response.synchronisation.ArrondissementSyncResponse;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
|
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
|
||||||
List<Arrondissement> findAllByCommune(Commune commune);
|
List<Arrondissement> findAllByCommune(Commune commune);
|
||||||
@@ -33,4 +38,94 @@ public interface ArrondissementRepository extends JpaRepository<Arrondissement,
|
|||||||
" where sa.structure_id = ?1 )T " +
|
" where sa.structure_id = ?1 )T " +
|
||||||
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
|
||||||
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
|
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom,
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom
|
||||||
|
)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
""")
|
||||||
|
List<ArrondissementPaylaodWeb> findAllArrondissementToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom,
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom
|
||||||
|
)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
WHERE arr.id = :arrondissementId
|
||||||
|
""")
|
||||||
|
Optional<ArrondissementPaylaodWeb> findArrondissementToDtoById(@Param("arrondissementId") Long arrondissementId);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom,
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom
|
||||||
|
)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT arr.id)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<ArrondissementPaylaodWeb> findAllArrondissementToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom,
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom
|
||||||
|
)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
WHERE arr.commune.id = :communeId
|
||||||
|
""")
|
||||||
|
List<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDto(@Param("communeId") Long communeId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom,
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom
|
||||||
|
)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
WHERE arr.commune.id = :communeId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT arr.id)
|
||||||
|
FROM Arrondissement arr
|
||||||
|
LEFT JOIN arr.commune com
|
||||||
|
WHERE arr.commune.id = :communeId
|
||||||
|
""")
|
||||||
|
Page<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDtoPageable(@Param("communeId") Long communeId, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
|||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.CommuneEnqResponse;
|
import io.gmss.fiscad.paylaods.response.CommuneEnqResponse;
|
||||||
import io.gmss.fiscad.paylaods.response.synchronisation.CommuneSyncResponse;
|
import io.gmss.fiscad.paylaods.response.synchronisation.CommuneSyncResponse;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
||||||
|
|
||||||
@@ -15,7 +20,7 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
|||||||
List<CommuneSyncResponse> getCommuneResponse();
|
List<CommuneSyncResponse> getCommuneResponse();
|
||||||
|
|
||||||
|
|
||||||
List<Commune> findAllByDepartement(Departement departement);
|
List<Commune> findAllByDepartement_Id(Long departementId);
|
||||||
|
|
||||||
@Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
@Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
||||||
" From (select distinct c.id as id,c.code as code, c.nom as libelle, c.longitude,c.latitude, e.id as enqueteId from arrondissement a" +
|
" From (select distinct c.id as id,c.code as code, c.nom as libelle, c.longitude,c.latitude, e.id as enqueteId from arrondissement a" +
|
||||||
@@ -37,4 +42,95 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
|||||||
" group by T.id,T.code, T.libelle,T.longitude,T.latitude",nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude",nativeQuery = true)
|
||||||
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
|
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom,
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
""")
|
||||||
|
List<CommunePaylaodWeb> findAllCommuneToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom,
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
WHERE com.id = :idCommune
|
||||||
|
""")
|
||||||
|
Optional<CommunePaylaodWeb> findCommuneToDtoById(@Param("idCommune") Long idCommune);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom,
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT com.id)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<CommunePaylaodWeb> findAllCommuneToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom,
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
WHERE com.departement.id = :departementId
|
||||||
|
""")
|
||||||
|
List<CommunePaylaodWeb> findAllCommuneByDepartementToDto(@Param("departementId") Long departementId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||||
|
com.id,
|
||||||
|
com.code,
|
||||||
|
com.nom,
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
WHERE com.departement.id = :departementId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT com.id)
|
||||||
|
FROM Commune com
|
||||||
|
LEFT JOIN com.departement dep
|
||||||
|
WHERE com.departement.id = :departementId
|
||||||
|
""")
|
||||||
|
Page<CommunePaylaodWeb> findAllCommuneByDepartementToDtoPageable(@Param("departementId") Long departementId, Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package io.gmss.fiscad.persistence.repositories.decoupage;
|
package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.synchronisation.DepartementSyncResponse;
|
import io.gmss.fiscad.paylaods.response.synchronisation.DepartementSyncResponse;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
public interface DepartementRepository extends JpaRepository<Departement, Long> {
|
public interface DepartementRepository extends JpaRepository<Departement, Long> {
|
||||||
@@ -14,4 +19,44 @@ public interface DepartementRepository extends JpaRepository<Departement, Long>
|
|||||||
" where departement.deleted is false ", nativeQuery = true)
|
" where departement.deleted is false ", nativeQuery = true)
|
||||||
List<DepartementSyncResponse> getDepartementResponse();
|
List<DepartementSyncResponse> getDepartementResponse();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Departement dep
|
||||||
|
""")
|
||||||
|
List<DepartementPaylaodWeb> findAllDepartementToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Departement dep
|
||||||
|
WHERE dep.id = :idDepartement
|
||||||
|
""")
|
||||||
|
Optional<DepartementPaylaodWeb> findDepartementToDtoById(@Param("idDepartement") Long idDepartement);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||||
|
dep.id,
|
||||||
|
dep.code,
|
||||||
|
dep.nom
|
||||||
|
)
|
||||||
|
FROM Departement dep
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT dep.id)
|
||||||
|
FROM Departement dep
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<DepartementPaylaodWeb> findAllDepartementToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
|||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.synchronisation.QuartierSyncResponse;
|
import io.gmss.fiscad.paylaods.response.synchronisation.QuartierSyncResponse;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
||||||
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
|
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
|
||||||
@@ -23,5 +28,94 @@ public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
|||||||
" where q.deleted is false ", nativeQuery = true)
|
" where q.deleted is false ", nativeQuery = true)
|
||||||
List<QuartierSyncResponse> getAdminQuartierResponse();
|
List<QuartierSyncResponse> getAdminQuartierResponse();
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||||
|
qua.id,
|
||||||
|
qua.code,
|
||||||
|
qua.nom,
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom
|
||||||
|
)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
""")
|
||||||
|
List<QuartierPaylaodWeb> findAllQuartierToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||||
|
qua.id,
|
||||||
|
qua.code,
|
||||||
|
qua.nom,
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom
|
||||||
|
)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
WHERE qua.id = :idQuartier
|
||||||
|
""")
|
||||||
|
Optional<QuartierPaylaodWeb> findQuartierToDtoById(@Param("idQuartier") Long idQuartier);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||||
|
qua.id,
|
||||||
|
qua.code,
|
||||||
|
qua.nom,
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom
|
||||||
|
)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT qua.id)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<QuartierPaylaodWeb> findAllQuartierToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||||
|
qua.id,
|
||||||
|
qua.code,
|
||||||
|
qua.nom,
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom
|
||||||
|
)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
WHERE qua.arrondissement.id = :arrondissementId
|
||||||
|
""")
|
||||||
|
List<QuartierPaylaodWeb> findAllQuartierByArrondissementToDto(@Param("arrondissementId") Long arrondissementId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||||
|
qua.id,
|
||||||
|
qua.code,
|
||||||
|
qua.nom,
|
||||||
|
arr.id,
|
||||||
|
arr.code,
|
||||||
|
arr.nom
|
||||||
|
)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
WHERE qua.arrondissement.id = :arrondissementId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT qua.id)
|
||||||
|
FROM Quartier qua
|
||||||
|
LEFT JOIN qua.arrondissement arr
|
||||||
|
WHERE qua.arrondissement.id = :arrondissementId
|
||||||
|
""")
|
||||||
|
Page<QuartierPaylaodWeb> findAllQuartierByArrondissementToDtoPageable(@Param("arrondissementId") Long arrondissementId, Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,148 @@
|
|||||||
package io.gmss.fiscad.persistence.repositories.decoupage;
|
package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface SecteurDecoupageRepository extends JpaRepository<SecteurDecoupage, Long> {
|
public interface SecteurDecoupageRepository extends JpaRepository<SecteurDecoupage, Long> {
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
|
||||||
|
sd.id,
|
||||||
|
sd.dateDebut,
|
||||||
|
sd.dateFin,
|
||||||
|
sect.id,
|
||||||
|
sect.code,
|
||||||
|
sect.nom,
|
||||||
|
a.id,
|
||||||
|
a.code,
|
||||||
|
a.nom,
|
||||||
|
q.id,
|
||||||
|
q.code,
|
||||||
|
q.nom
|
||||||
|
)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
""")
|
||||||
|
List<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
|
||||||
|
sd.id,
|
||||||
|
sd.dateDebut,
|
||||||
|
sd.dateFin,
|
||||||
|
sect.id,
|
||||||
|
sect.code,
|
||||||
|
sect.nom,
|
||||||
|
a.id,
|
||||||
|
a.code,
|
||||||
|
a.nom,
|
||||||
|
q.id,
|
||||||
|
q.code,
|
||||||
|
q.nom
|
||||||
|
)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
WHERE sd.id = :idSecteurDecoupage
|
||||||
|
""")
|
||||||
|
Optional<SecteurDecoupagePaylaodWeb> findSecteurDecoupageToDtoById(@Param("idSecteurDecoupage") Long idSecteurDecoupage);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
|
||||||
|
sd.id,
|
||||||
|
sd.dateDebut,
|
||||||
|
sd.dateFin,
|
||||||
|
sect.id,
|
||||||
|
sect.code,
|
||||||
|
sect.nom,
|
||||||
|
a.id,
|
||||||
|
a.code,
|
||||||
|
a.nom,
|
||||||
|
q.id,
|
||||||
|
q.code,
|
||||||
|
q.nom
|
||||||
|
)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT sd.id)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
|
||||||
|
sd.id,
|
||||||
|
sd.dateDebut,
|
||||||
|
sd.dateFin,
|
||||||
|
sect.id,
|
||||||
|
sect.code,
|
||||||
|
sect.nom,
|
||||||
|
a.id,
|
||||||
|
a.code,
|
||||||
|
a.nom,
|
||||||
|
q.id,
|
||||||
|
q.code,
|
||||||
|
q.nom
|
||||||
|
)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
WHERE sd.secteur.id = :secteurId
|
||||||
|
""")
|
||||||
|
List<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageBySecteurToDto(@Param("secteurId") Long secteurId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
|
||||||
|
sd.id,
|
||||||
|
sd.dateDebut,
|
||||||
|
sd.dateFin,
|
||||||
|
sect.id,
|
||||||
|
sect.code,
|
||||||
|
sect.nom,
|
||||||
|
a.id,
|
||||||
|
a.code,
|
||||||
|
a.nom,
|
||||||
|
q.id,
|
||||||
|
q.code,
|
||||||
|
q.nom
|
||||||
|
)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
WHERE sd.secteur.id = :secteurId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT sd.id)
|
||||||
|
FROM SecteurDecoupage sd
|
||||||
|
LEFT JOIN sd.secteur sect
|
||||||
|
LEFT JOIN sd.arrondissement a
|
||||||
|
LEFT JOIN sd.quartier q
|
||||||
|
WHERE sd.secteur.id = :secteurId
|
||||||
|
""")
|
||||||
|
Page<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageBySecteurToDtoPageable(@Param("secteurId") Long secteurId, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ public interface BlocRepository extends JpaRepository<Bloc, Long> {
|
|||||||
List<BlocsParStructureResponse> getBlocsParStructureResponse(Long structure_id);
|
List<BlocsParStructureResponse> getBlocsParStructureResponse(Long structure_id);
|
||||||
|
|
||||||
List<Bloc> findAllByArrondissement(Arrondissement arrondissement);
|
List<Bloc> findAllByArrondissement(Arrondissement arrondissement);
|
||||||
|
List<Bloc> findAllByArrondissement_Id(Long arrondissementId);
|
||||||
|
|
||||||
@Query(value = "select structure_id as id from arrondissements_structures " +
|
@Query(value = "select structure_id as id from arrondissements_structures " +
|
||||||
" where arrondissement_id = ?1" +
|
" where arrondissement_id = ?1" +
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
package io.gmss.fiscad.persistence.repositories.infocad.parametre;
|
package io.gmss.fiscad.persistence.repositories.infocad.parametre;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
|
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
|
||||||
import io.gmss.fiscad.paylaods.response.StructureEnqResponse;
|
import io.gmss.fiscad.paylaods.response.StructureEnqResponse;
|
||||||
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
import io.gmss.fiscad.paylaods.response.StructureResponse;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface StructureRepository extends JpaRepository<Structure, Long> {
|
public interface StructureRepository extends JpaRepository<Structure, Long> {
|
||||||
boolean existsDistinctByCode(String code);
|
boolean existsDistinctByCode(String code);
|
||||||
@@ -54,4 +59,119 @@ public interface StructureRepository extends JpaRepository<Structure, Long> {
|
|||||||
group by s.id,s.code,s.nom,c.id ;
|
group by s.id,s.code,s.nom,c.id ;
|
||||||
""", nativeQuery = true)
|
""", nativeQuery = true)
|
||||||
List<StructureEnqResponse> getStructureEnqResponse(Long structure_id);
|
List<StructureEnqResponse> getStructureEnqResponse(Long structure_id);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb(
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
c.id,
|
||||||
|
c.code,
|
||||||
|
c.nom,
|
||||||
|
st.ifu,
|
||||||
|
st.rccm,
|
||||||
|
st.tel,
|
||||||
|
st.email,
|
||||||
|
st.adresse
|
||||||
|
)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
""")
|
||||||
|
List<StructurePaylaodWeb> findAllStructureToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb(
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
c.id,
|
||||||
|
c.code,
|
||||||
|
c.nom,
|
||||||
|
st.ifu,
|
||||||
|
st.rccm,
|
||||||
|
st.tel,
|
||||||
|
st.email,
|
||||||
|
st.adresse
|
||||||
|
)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
WHERE st.id = :idStructure
|
||||||
|
""")
|
||||||
|
Optional<StructurePaylaodWeb> findStructureToDtoById(@Param("idStructure") Long idStructure);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb(
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
c.id,
|
||||||
|
c.code,
|
||||||
|
c.nom,
|
||||||
|
st.ifu,
|
||||||
|
st.rccm,
|
||||||
|
st.tel,
|
||||||
|
st.email,
|
||||||
|
st.adresse
|
||||||
|
)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT st.id)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<StructurePaylaodWeb> findAllStructureToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb(
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
c.id,
|
||||||
|
c.code,
|
||||||
|
c.nom,
|
||||||
|
st.ifu,
|
||||||
|
st.rccm,
|
||||||
|
st.tel,
|
||||||
|
st.email,
|
||||||
|
st.adresse
|
||||||
|
)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
WHERE c.id = :communeId
|
||||||
|
""")
|
||||||
|
List<StructurePaylaodWeb> findAllStructureByCommuneToDto(@Param("communeId") Long communeId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb(
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
c.id,
|
||||||
|
c.code,
|
||||||
|
c.nom,
|
||||||
|
st.ifu,
|
||||||
|
st.rccm,
|
||||||
|
st.tel,
|
||||||
|
st.email,
|
||||||
|
st.adresse
|
||||||
|
)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
WHERE c.id = :communeId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT st.id)
|
||||||
|
FROM Structure st
|
||||||
|
LEFT JOIN st.commune c
|
||||||
|
WHERE c.id = :communeId
|
||||||
|
""")
|
||||||
|
Page<StructurePaylaodWeb> findAllStructureByCommuneToDtoPageable(@Param("communeId") Long communeId, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,143 @@
|
|||||||
package io.gmss.fiscad.persistence.repositories.user;
|
package io.gmss.fiscad.persistence.repositories.user;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||||
import io.gmss.fiscad.entities.user.AvoirFonction;
|
import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||||
import io.gmss.fiscad.entities.user.AvoirFonction;
|
import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||||
|
import io.gmss.fiscad.enums.Titre;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface AvoirFonctionRepository extends JpaRepository<AvoirFonction, Long> {
|
public interface AvoirFonctionRepository extends JpaRepository<AvoirFonction, Long> {
|
||||||
Optional<AvoirFonction> findAvoirFonctionById(Long id);
|
@Query("""
|
||||||
List<AvoirFonction> findAvoirFonctionByUser_Id(Long userId);
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
|
af.id,
|
||||||
|
af.dateDebut,
|
||||||
|
af.dateFin,
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
u.id,
|
||||||
|
u.username,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.email,
|
||||||
|
af.titre
|
||||||
|
)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
""")
|
||||||
|
List<AvoirFonctionPaylaodWeb> findAllAvoirFonctionToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
|
af.id,
|
||||||
|
af.dateDebut,
|
||||||
|
af.dateFin,
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
u.id,
|
||||||
|
u.username,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.email,
|
||||||
|
af.titre
|
||||||
|
)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
WHERE af.id = :idAvoirFonction
|
||||||
|
""")
|
||||||
|
Optional<AvoirFonctionPaylaodWeb> findAvoirFonctionToDtoById(@Param("idAvoirFonction") Long idAvoirFonction);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
|
af.id,
|
||||||
|
af.dateDebut,
|
||||||
|
af.dateFin,
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
u.id,
|
||||||
|
u.username,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.email,
|
||||||
|
af.titre
|
||||||
|
)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<AvoirFonctionPaylaodWeb> findAllAvoirFonctionToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
|
af.id,
|
||||||
|
af.dateDebut,
|
||||||
|
af.dateFin,
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
u.id,
|
||||||
|
u.username,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.email,
|
||||||
|
af.titre
|
||||||
|
)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
WHERE u.id = :userId
|
||||||
|
""")
|
||||||
|
List<AvoirFonctionPaylaodWeb> findAllAvoirFonctionByUserToDto(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb(
|
||||||
|
af.id,
|
||||||
|
af.dateDebut,
|
||||||
|
af.dateFin,
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
u.id,
|
||||||
|
u.username,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.email,
|
||||||
|
af.titre
|
||||||
|
)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
WHERE u.id = :userId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT af.id)
|
||||||
|
FROM AvoirFonction af
|
||||||
|
LEFT JOIN af.user u
|
||||||
|
LEFT JOIN af.fonction f
|
||||||
|
WHERE u.id = :userId
|
||||||
|
""")
|
||||||
|
Page<AvoirFonctionPaylaodWeb> findAllAvoirFonctionByUserToDtoPageable(@Param("userId") Long userId, Pageable pageable);
|
||||||
|
|
||||||
|
List<AvoirFonction> findAvoirFonctionByUser_Id(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
|||||||
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.paylaods.request.crudweb.UserPaylaodWeb;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -13,14 +18,132 @@ import java.util.Set;
|
|||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
|
|
||||||
Optional<User> findByUsername(String username);
|
Optional<User> findByUsername(String username);
|
||||||
|
Optional<User> findByEmail(String email);
|
||||||
|
|
||||||
boolean existsByUsername(String username);
|
boolean existsByUsername(String username);
|
||||||
|
|
||||||
long countAllByUsernameIsNotNull();
|
long countAllByUsernameIsNotNull();
|
||||||
|
|
||||||
// List<User> findAllByStructureAndRolesIn(Structure structure, Set<Role> roleSet);
|
|
||||||
|
|
||||||
// List<User> findAllByStructureAndRolesNotIn(Structure structure, Set<Role> roleSet);
|
|
||||||
|
|
||||||
// List<User> findAllByRolesContains(UserRole userRole);
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
""")
|
||||||
|
List<UserPaylaodWeb> findAllUserToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
WHERE u.id = :idUser
|
||||||
|
""")
|
||||||
|
Optional<UserPaylaodWeb> findUserToDtoById(@Param("idUser") Long idUser);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
WHERE u.username = :userName
|
||||||
|
""")
|
||||||
|
Optional<UserPaylaodWeb> findUserToDtoByUserName(@Param("userName") String userName);
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT u.id)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<UserPaylaodWeb> findAllUserToDtoPageable(Pageable pageable);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
WHERE st.id = :structureId
|
||||||
|
""")
|
||||||
|
List<UserPaylaodWeb> findAllUserByStructureToDto(@Param("structureId") Long structureId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
|
||||||
|
u.id,
|
||||||
|
u.nom,
|
||||||
|
u.prenom,
|
||||||
|
u.tel,
|
||||||
|
u.username,
|
||||||
|
u.email,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom
|
||||||
|
)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
WHERE st.id = :structureId
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(DISTINCT u.id)
|
||||||
|
FROM User u
|
||||||
|
LEFT JOIN u.structure st
|
||||||
|
WHERE st.id = :structureId
|
||||||
|
""")
|
||||||
|
Page<UserPaylaodWeb> findAllUserByStructureToDtoPageable(@Param("structureId") Long structureId, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package io.gmss.fiscad.service;
|
package io.gmss.fiscad.service;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
import io.gmss.fiscad.entities.decoupage.*;
|
||||||
import io.gmss.fiscad.entities.decoupage.Nationalite;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Section;
|
|
||||||
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.Parcelle;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
||||||
@@ -15,17 +12,18 @@ import io.gmss.fiscad.entities.user.AvoirFonction;
|
|||||||
import io.gmss.fiscad.entities.user.Fonction;
|
import io.gmss.fiscad.entities.user.Fonction;
|
||||||
import io.gmss.fiscad.entities.user.Profile;
|
import io.gmss.fiscad.entities.user.Profile;
|
||||||
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.NotFoundException;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.*;
|
import io.gmss.fiscad.paylaods.request.crudweb.*;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
import io.gmss.fiscad.persistence.repositories.decoupage.*;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.SectionRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.parametre.*;
|
import io.gmss.fiscad.persistence.repositories.infocad.parametre.*;
|
||||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.*;
|
import io.gmss.fiscad.persistence.repositories.rfu.metier.*;
|
||||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
|
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
|
||||||
|
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.user.ProfileRepository;
|
import io.gmss.fiscad.persistence.repositories.user.ProfileRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -60,9 +58,22 @@ public class EntityFromPayLoadService {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final ProfileRepository profileRepository;
|
private final ProfileRepository profileRepository;
|
||||||
private final SectionRepository sectionRepository;
|
private final SectionRepository sectionRepository;
|
||||||
|
private final ArrondissementRepository arrondissementRepository;
|
||||||
|
private final QuartierRepository quartierRepository;
|
||||||
|
private final CaracteristiqueBatimentRepository caracteristiqueBatimentRepository;
|
||||||
|
private final CaracteristiqueParcelleRepository caracteristiqueParcelleRepository;
|
||||||
|
private final CaracteristiqueUniteLogementRepository caracteristiqueUniteLogementRepository;
|
||||||
|
private final UploadRepository uploadRepository;
|
||||||
|
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||||
|
private final AvoirFonctionRepository avoirFonctionRepository;
|
||||||
|
private final EnqueteActiviteRepository enqueteActiviteRepository;
|
||||||
|
|
||||||
|
|
||||||
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
|
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
|
||||||
CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle();
|
CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle();
|
||||||
|
if(caracteristiqueParcellePayloadWeb.getId()!=null)
|
||||||
|
caracteristiqueParcelle = caracteristiqueParcelleRepository.findById(caracteristiqueParcellePayloadWeb.getId()).orElse(new CaracteristiqueParcelle());
|
||||||
|
|
||||||
Optional<Enquete> optionalEnquete=Optional.empty();
|
Optional<Enquete> optionalEnquete=Optional.empty();
|
||||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||||
|
|
||||||
@@ -81,6 +92,9 @@ public class EntityFromPayLoadService {
|
|||||||
|
|
||||||
public CaracteristiqueBatiment getCaracteristiqueBatimentFromPayLoadWeb(CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb){
|
public CaracteristiqueBatiment getCaracteristiqueBatimentFromPayLoadWeb(CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb){
|
||||||
CaracteristiqueBatiment caracteristiqueBatiment=new CaracteristiqueBatiment();
|
CaracteristiqueBatiment caracteristiqueBatiment=new CaracteristiqueBatiment();
|
||||||
|
if(caracteristiqueBatimentPayloadWeb.getId()!=null)
|
||||||
|
caracteristiqueBatiment = caracteristiqueBatimentRepository.findById(caracteristiqueBatimentPayloadWeb.getId()).orElse(new CaracteristiqueBatiment());
|
||||||
|
|
||||||
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
||||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||||
|
|
||||||
@@ -105,6 +119,10 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
||||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||||
|
|
||||||
|
if(caracteristiqueUniteLogementPayloadWeb.getId()!=null)
|
||||||
|
caracteristiqueUniteLogement = caracteristiqueUniteLogementRepository.findById(caracteristiqueUniteLogementPayloadWeb.getId()).orElse(new CaracteristiqueUniteLogement());
|
||||||
|
|
||||||
|
|
||||||
if(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId()!=null)
|
if(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId()!=null)
|
||||||
optionalEnqueteUniteLogement=enqueteUniteLogementRepository.findById(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId());
|
optionalEnqueteUniteLogement=enqueteUniteLogementRepository.findById(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId());
|
||||||
|
|
||||||
@@ -127,6 +145,9 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<SourceDroit> optionalSourceDroit=Optional.empty();
|
Optional<SourceDroit> optionalSourceDroit=Optional.empty();
|
||||||
Optional<ModeAcquisition> optionalModeAcquisition=Optional.empty();
|
Optional<ModeAcquisition> optionalModeAcquisition=Optional.empty();
|
||||||
Optional<Personne> optionalPersonne=Optional.empty();
|
Optional<Personne> optionalPersonne=Optional.empty();
|
||||||
|
if(piecePayLoadWeb.getId()!=null)
|
||||||
|
piece = pieceRepository.findById(piecePayLoadWeb.getId()).orElse(new Piece());
|
||||||
|
|
||||||
|
|
||||||
if(piecePayLoadWeb.getEnqueteId()!=null)
|
if(piecePayLoadWeb.getEnqueteId()!=null)
|
||||||
optionalEnquete=enqueteRepository.findById(piecePayLoadWeb.getEnqueteId());
|
optionalEnquete=enqueteRepository.findById(piecePayLoadWeb.getEnqueteId());
|
||||||
@@ -160,6 +181,10 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<Enquete> optionalEnquete=Optional.empty();
|
Optional<Enquete> optionalEnquete=Optional.empty();
|
||||||
Optional<Personne> optionalPersonne=Optional.empty();
|
Optional<Personne> optionalPersonne=Optional.empty();
|
||||||
Optional<Structure> optionalStructure=Optional.empty();
|
Optional<Structure> optionalStructure=Optional.empty();
|
||||||
|
if(declarationNcPayloadWeb.getId()!=null)
|
||||||
|
declarationNc = declarationNcRepository.findById(declarationNcPayloadWeb.getId()).orElse(new DeclarationNc());
|
||||||
|
|
||||||
|
|
||||||
if(declarationNcPayloadWeb.getEnqueteId()!=null)
|
if(declarationNcPayloadWeb.getEnqueteId()!=null)
|
||||||
optionalEnquete=enqueteRepository.findById(declarationNcPayloadWeb.getEnqueteId());
|
optionalEnquete=enqueteRepository.findById(declarationNcPayloadWeb.getEnqueteId());
|
||||||
if(declarationNcPayloadWeb.getPersonneId()!=null)
|
if(declarationNcPayloadWeb.getPersonneId()!=null)
|
||||||
@@ -182,6 +207,8 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<Personne> optionalPersonne=Optional.empty();
|
Optional<Personne> optionalPersonne=Optional.empty();
|
||||||
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
||||||
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
||||||
|
if(uploadPayLoadWeb.getId()!=null)
|
||||||
|
upload = uploadRepository.findById(uploadPayLoadWeb.getId()).orElse(new Upload());
|
||||||
|
|
||||||
// if(uploadPayLoadWeb.getEnqueteId()!=null)
|
// if(uploadPayLoadWeb.getEnqueteId()!=null)
|
||||||
// optionalEnquete=enqueteRepository.findById(uploadPayLoadWeb.getEnqueteId());
|
// optionalEnquete=enqueteRepository.findById(uploadPayLoadWeb.getEnqueteId());
|
||||||
@@ -210,6 +237,9 @@ public class EntityFromPayLoadService {
|
|||||||
public Batiment getBatimentFromPayLoadWeb(BatimentPaylaodWeb batimentPaylaodWeb){
|
public Batiment getBatimentFromPayLoadWeb(BatimentPaylaodWeb batimentPaylaodWeb){
|
||||||
Batiment batiment=new Batiment();
|
Batiment batiment=new Batiment();
|
||||||
Optional<Parcelle> optionalParcelle=Optional.empty();
|
Optional<Parcelle> optionalParcelle=Optional.empty();
|
||||||
|
if(batimentPaylaodWeb.getId()!=null)
|
||||||
|
batiment = batimentRepository.findById(batimentPaylaodWeb.getId()).orElse(new Batiment());
|
||||||
|
|
||||||
|
|
||||||
if(batimentPaylaodWeb.getParcelleId()!=null)
|
if(batimentPaylaodWeb.getParcelleId()!=null)
|
||||||
optionalParcelle=parcelleRepository.findById(batimentPaylaodWeb.getParcelleId());
|
optionalParcelle=parcelleRepository.findById(batimentPaylaodWeb.getParcelleId());
|
||||||
@@ -227,6 +257,9 @@ public class EntityFromPayLoadService {
|
|||||||
public Section getSectionFromPayLoadWeb(SectionPaylaodWeb sectionPaylaodWeb){
|
public Section getSectionFromPayLoadWeb(SectionPaylaodWeb sectionPaylaodWeb){
|
||||||
Section section =new Section();
|
Section section =new Section();
|
||||||
Optional<Structure> optionalStructure = Optional.empty();
|
Optional<Structure> optionalStructure = Optional.empty();
|
||||||
|
if(sectionPaylaodWeb.getId()!=null)
|
||||||
|
section = sectionRepository.findById(sectionPaylaodWeb.getId()).orElse(new Section());
|
||||||
|
|
||||||
|
|
||||||
if(sectionPaylaodWeb.getStructureId()!=null)
|
if(sectionPaylaodWeb.getStructureId()!=null)
|
||||||
optionalStructure=structureRepository.findById(sectionPaylaodWeb.getStructureId());
|
optionalStructure=structureRepository.findById(sectionPaylaodWeb.getStructureId());
|
||||||
@@ -238,9 +271,33 @@ public class EntityFromPayLoadService {
|
|||||||
return section ;
|
return section ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Structure getStructureFromPayLoadWeb(StructurePaylaodWeb structurePaylaodWeb){
|
||||||
|
Structure structure =new Structure();
|
||||||
|
if(structurePaylaodWeb.getId()!=null)
|
||||||
|
structure = structureRepository.findById(structurePaylaodWeb.getId()).orElse(new Structure());
|
||||||
|
|
||||||
|
if (structurePaylaodWeb.getCommuneId() == null) {
|
||||||
|
throw new BadRequestException("La commune est obligatoire.");
|
||||||
|
}
|
||||||
|
Commune commune = communeRepository.findById(structurePaylaodWeb.getCommuneId())
|
||||||
|
.orElseThrow(() -> new NotFoundException("Commune inexistante"));
|
||||||
|
structure.setCommune(commune);
|
||||||
|
|
||||||
|
structure.setCode(structurePaylaodWeb.getCode());
|
||||||
|
structure.setNom(structurePaylaodWeb.getNom());
|
||||||
|
structure.setAdresse(structurePaylaodWeb.getAdresse());
|
||||||
|
structure.setIfu(structurePaylaodWeb.getIfu());
|
||||||
|
structure.setEmail(structurePaylaodWeb.getEmail());
|
||||||
|
structure.setTel(structurePaylaodWeb.getTel());
|
||||||
|
return structure ;
|
||||||
|
}
|
||||||
|
|
||||||
public Secteur getSecteurFromPayLoadWeb(SecteurPaylaodWeb secteurPaylaodWeb){
|
public Secteur getSecteurFromPayLoadWeb(SecteurPaylaodWeb secteurPaylaodWeb){
|
||||||
Secteur secteur =new Secteur();
|
Secteur secteur =new Secteur();
|
||||||
Optional<Section> optionalSection = Optional.empty();
|
Optional<Section> optionalSection = Optional.empty();
|
||||||
|
if(secteurPaylaodWeb.getId()!=null)
|
||||||
|
secteur = secteurRepository.findById(secteurPaylaodWeb.getId()).orElse(new Secteur());
|
||||||
|
|
||||||
|
|
||||||
if(secteurPaylaodWeb.getSectionId()!=null)
|
if(secteurPaylaodWeb.getSectionId()!=null)
|
||||||
optionalSection=sectionRepository.findById(secteurPaylaodWeb.getSectionId());
|
optionalSection=sectionRepository.findById(secteurPaylaodWeb.getSectionId());
|
||||||
@@ -252,9 +309,40 @@ public class EntityFromPayLoadService {
|
|||||||
return secteur ;
|
return secteur ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SecteurDecoupage getSecteurDecoupageFromPayLoadWeb(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb){
|
||||||
|
SecteurDecoupage secteurDecoupage =new SecteurDecoupage();
|
||||||
|
Optional<Secteur> optionalSecteur = Optional.empty();
|
||||||
|
Optional<Arrondissement> optionalArrondissement = Optional.empty();
|
||||||
|
Optional<Quartier> optionalQuartier = Optional.empty();
|
||||||
|
if(secteurDecoupagePaylaodWeb.getId()!=null)
|
||||||
|
secteurDecoupage = secteurDecoupageRepository.findById(secteurDecoupagePaylaodWeb.getId()).orElse(new SecteurDecoupage());
|
||||||
|
|
||||||
|
|
||||||
|
if(secteurDecoupagePaylaodWeb.getSecteurId()!=null)
|
||||||
|
optionalSecteur=secteurRepository.findById(secteurDecoupagePaylaodWeb.getSecteurId());
|
||||||
|
if(secteurDecoupagePaylaodWeb.getArrondissementCode()!=null)
|
||||||
|
optionalArrondissement=arrondissementRepository.findById(secteurDecoupagePaylaodWeb.getArrondissementId());
|
||||||
|
if(secteurDecoupagePaylaodWeb.getQuartierId()!=null)
|
||||||
|
optionalQuartier=quartierRepository.findById(secteurDecoupagePaylaodWeb.getQuartierId());
|
||||||
|
|
||||||
|
secteurDecoupage.setId(secteurDecoupagePaylaodWeb.getId());
|
||||||
|
secteurDecoupage.setSecteur(optionalSecteur.orElse(null));
|
||||||
|
secteurDecoupage.setArrondissement(optionalArrondissement.orElse(null));
|
||||||
|
secteurDecoupage.setQuartier(optionalQuartier.orElse(null));
|
||||||
|
secteurDecoupage.setDateDebut(secteurDecoupagePaylaodWeb.getDateDebut());
|
||||||
|
secteurDecoupage.setDateFin(secteurDecoupagePaylaodWeb.getDateFin());
|
||||||
|
|
||||||
|
return secteurDecoupage ;
|
||||||
|
}
|
||||||
|
|
||||||
public UniteLogement getUniteLogementFromPayLoadWeb(UniteLogementPaylaodWeb uniteLogementPaylaodWeb){
|
public UniteLogement getUniteLogementFromPayLoadWeb(UniteLogementPaylaodWeb uniteLogementPaylaodWeb){
|
||||||
UniteLogement uniteLogement=new UniteLogement();
|
UniteLogement uniteLogement=new UniteLogement();
|
||||||
Optional<Batiment> optionalBatiment=Optional.empty();
|
Optional<Batiment> optionalBatiment=Optional.empty();
|
||||||
|
if(uniteLogementPaylaodWeb.getId()!=null)
|
||||||
|
uniteLogement = uniteLogementRepository.findById(uniteLogementPaylaodWeb.getId()).orElse(new UniteLogement());
|
||||||
|
|
||||||
|
|
||||||
if(uniteLogementPaylaodWeb.getBatimentId()!=null)
|
if(uniteLogementPaylaodWeb.getBatimentId()!=null)
|
||||||
optionalBatiment=batimentRepository.findById(uniteLogementPaylaodWeb.getBatimentId());
|
optionalBatiment=batimentRepository.findById(uniteLogementPaylaodWeb.getBatimentId());
|
||||||
uniteLogement.setBatiment(optionalBatiment.orElse(null));
|
uniteLogement.setBatiment(optionalBatiment.orElse(null));
|
||||||
@@ -273,6 +361,10 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<Profile> optionalProfile=Optional.empty();
|
Optional<Profile> optionalProfile=Optional.empty();
|
||||||
Optional<User> optionalUser=Optional.empty();
|
Optional<User> optionalUser=Optional.empty();
|
||||||
Optional<Structure> optionalStructure=Optional.empty();
|
Optional<Structure> optionalStructure=Optional.empty();
|
||||||
|
if(fonctionPaylaodWeb.getId()!=null)
|
||||||
|
fonction = fonctionRepository.findById(fonctionPaylaodWeb.getId()).orElse(new Fonction());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(fonctionPaylaodWeb.getSecteurId()!=null)
|
if(fonctionPaylaodWeb.getSecteurId()!=null)
|
||||||
optionalSecteur=secteurRepository.findById(fonctionPaylaodWeb.getSecteurId());
|
optionalSecteur=secteurRepository.findById(fonctionPaylaodWeb.getSecteurId());
|
||||||
@@ -299,6 +391,9 @@ public class EntityFromPayLoadService {
|
|||||||
AvoirFonction avoirFonction =new AvoirFonction();
|
AvoirFonction avoirFonction =new AvoirFonction();
|
||||||
Optional<Fonction> optionalFonction=Optional.empty();
|
Optional<Fonction> optionalFonction=Optional.empty();
|
||||||
Optional<User> optionalUser=Optional.empty();
|
Optional<User> optionalUser=Optional.empty();
|
||||||
|
if(avoirFonctionPaylaodWeb.getId()!=null)
|
||||||
|
avoirFonction = avoirFonctionRepository.findById(avoirFonctionPaylaodWeb.getId()).orElse(new AvoirFonction());
|
||||||
|
|
||||||
|
|
||||||
if(avoirFonctionPaylaodWeb.getFonctionId()!=null)
|
if(avoirFonctionPaylaodWeb.getFonctionId()!=null)
|
||||||
optionalFonction=fonctionRepository.findById(avoirFonctionPaylaodWeb.getFonctionId());
|
optionalFonction=fonctionRepository.findById(avoirFonctionPaylaodWeb.getFonctionId());
|
||||||
@@ -318,10 +413,14 @@ public class EntityFromPayLoadService {
|
|||||||
|
|
||||||
public Profile getProfileFromPayLoadWeb(ProfilePaylaodWeb profilePaylaodWeb){
|
public Profile getProfileFromPayLoadWeb(ProfilePaylaodWeb profilePaylaodWeb){
|
||||||
Profile profile =new Profile();
|
Profile profile =new Profile();
|
||||||
|
if(profilePaylaodWeb.getId()!=null)
|
||||||
|
profile = profileRepository.findById(profilePaylaodWeb.getId()).orElse(new Profile());
|
||||||
|
|
||||||
profile.setDescription(profilePaylaodWeb.getDescription());
|
profile.setDescription(profilePaylaodWeb.getDescription());
|
||||||
profile.setRoles(profilePaylaodWeb.getRoles());
|
profile.setRoles(profilePaylaodWeb.getRoles());
|
||||||
profile.setNom(profilePaylaodWeb.getNom());
|
profile.setNom(profilePaylaodWeb.getNom());
|
||||||
|
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +431,9 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<TypePersonne> optionalTypePersonne=Optional.empty();
|
Optional<TypePersonne> optionalTypePersonne=Optional.empty();
|
||||||
Optional<Profession> optionalProfession=Optional.empty();
|
Optional<Profession> optionalProfession=Optional.empty();
|
||||||
Optional<Commune> optionalCommune=Optional.empty();
|
Optional<Commune> optionalCommune=Optional.empty();
|
||||||
|
if(personnePayLoadWeb.getId()!=null)
|
||||||
|
personne = personneRepository.findById(personnePayLoadWeb.getId()).orElse(new Personne());
|
||||||
|
|
||||||
|
|
||||||
if(personnePayLoadWeb.getSituationMatrimonialeId()!=null)
|
if(personnePayLoadWeb.getSituationMatrimonialeId()!=null)
|
||||||
optionalSituationMatrimoniale=situationMatrimonialeRepository.findById(personnePayLoadWeb.getSituationMatrimonialeId());
|
optionalSituationMatrimoniale=situationMatrimonialeRepository.findById(personnePayLoadWeb.getSituationMatrimonialeId());
|
||||||
@@ -387,6 +489,8 @@ public class EntityFromPayLoadService {
|
|||||||
Optional<UniteLogement> optionalUniteLogement=Optional.empty();
|
Optional<UniteLogement> optionalUniteLogement=Optional.empty();
|
||||||
Optional<Parcelle> optionalParcelle=Optional.empty();
|
Optional<Parcelle> optionalParcelle=Optional.empty();
|
||||||
Optional<Profession> optionalProfession=Optional.empty();
|
Optional<Profession> optionalProfession=Optional.empty();
|
||||||
|
if(enqueteActivitePayLoadWeb.getId()!=null)
|
||||||
|
enqueteActivite = enqueteActiviteRepository.findById(enqueteActivitePayLoadWeb.getId()).orElse(new EnqueteActivite());
|
||||||
|
|
||||||
|
|
||||||
if(enqueteActivitePayLoadWeb.getBatimentId()!=null)
|
if(enqueteActivitePayLoadWeb.getBatimentId()!=null)
|
||||||
@@ -427,4 +531,27 @@ public class EntityFromPayLoadService {
|
|||||||
enqueteActivite.setChiffreAffaire(enqueteActivitePayLoadWeb.getChiffreAffaire());
|
enqueteActivite.setChiffreAffaire(enqueteActivitePayLoadWeb.getChiffreAffaire());
|
||||||
return enqueteActivite ;
|
return enqueteActivite ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User getUserFromPayLoadWeb(UserPaylaodWeb userPaylaodWeb){
|
||||||
|
User user =new User();
|
||||||
|
Optional<Structure> optionalStructure = Optional.empty();
|
||||||
|
if(userPaylaodWeb.getId()!=null)
|
||||||
|
user = userRepository.findById(userPaylaodWeb.getId()).orElse(new User());
|
||||||
|
|
||||||
|
|
||||||
|
if(userPaylaodWeb.getStructureId()!=null)
|
||||||
|
optionalStructure=structureRepository.findById(userPaylaodWeb.getStructureId());
|
||||||
|
|
||||||
|
user.setId(userPaylaodWeb.getId());
|
||||||
|
user.setStructure(optionalStructure.orElse(null));
|
||||||
|
user.setUsername(userPaylaodWeb.getLogin());
|
||||||
|
user.setEmail(userPaylaodWeb.getEmail());
|
||||||
|
user.setNom(userPaylaodWeb.getNom());
|
||||||
|
user.setPrenom(userPaylaodWeb.getPrenom());
|
||||||
|
user.setTel(userPaylaodWeb.getTelephone());
|
||||||
|
user.setActive(false);
|
||||||
|
user.setResetPassword(true);
|
||||||
|
return user ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user