Compare commits
78 Commits
features/c
...
b58316bb88
| Author | SHA1 | Date | |
|---|---|---|---|
| b58316bb88 | |||
| 08b68f9e08 | |||
| 209d1cd777 | |||
| be487d6a03 | |||
| 1eb3aeeda0 | |||
| 3be64e7f44 | |||
| 03a661cdc0 | |||
| b3c288628c | |||
| a68ec444cc | |||
| d45e01ac85 | |||
| 58f517bf31 | |||
| 9bb0cc5c75 | |||
| 7f18f22efb | |||
| 3a68fd2ce4 | |||
| af3218412f | |||
| fa7421c35b | |||
| f35670c72e | |||
| 5cb9497163 | |||
| a77c0e854d | |||
| 15cac660bc | |||
| e75eff4e20 | |||
| 0feec2982f | |||
| 40d078c653 | |||
| b5ab0772a0 | |||
| 31dd11d017 | |||
| f293f65650 | |||
| 6dfd12fae8 | |||
| cfd1104c28 | |||
| a4ad0a4556 | |||
| 7d64390bae | |||
| 411a6c0c2d | |||
| 4876d8ab14 | |||
| bed73b2b16 | |||
| 2bfb298054 | |||
| 5a0814a0ba | |||
| 54ef33d1ab | |||
| 126254ea94 | |||
| 3fd779854f | |||
| f9e4681af4 | |||
| de2928414b | |||
| 84089d3639 | |||
| 9d6d278d78 | |||
| 02b0a937b4 | |||
| c8b0457195 | |||
| c0096457fb | |||
| b6062ba4d1 | |||
| 8dc8c974d3 | |||
| 9cc74a9a38 | |||
| 957416df9e | |||
| 8e6168d4ee | |||
| 8d8af75108 | |||
| c1a8ce86a6 | |||
| 555f13508e | |||
| 14feb49dcd | |||
| d92a2b2503 | |||
| 39de1c48c0 | |||
| 5ccfdb6a3f | |||
| f9e2b32118 | |||
| 87b3bfbe83 | |||
| 3ebb1cf165 | |||
| 62f25ea726 | |||
| c84176b8d3 | |||
| 6125fcbd0b | |||
| 61f4dd513f | |||
| 211af6103a | |||
| 5e9f437497 | |||
| d27b622db8 | |||
| 69af57f876 | |||
| c80b40082c | |||
| 56f78e77f3 | |||
| 4a88af6487 | |||
| 0c7dc082fd | |||
| 966b0af1c2 | |||
| 3f5d7e980c | |||
| 58aa088ac3 | |||
| 87be4e4483 | |||
| 033b430051 | |||
| b8dbc7f625 |
@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Arrondissement")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
public class ArrondissementController {
|
||||
|
||||
private final ArrondissementService arrondissementService;
|
||||
@@ -175,7 +175,7 @@ public class ArrondissementController {
|
||||
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementById(id).orElse(null), "Arrondissement trouvé avec succès."),
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
@@ -199,31 +199,7 @@ public class ArrondissementController {
|
||||
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
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."),
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Commune")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
public class CommuneController {
|
||||
|
||||
private final CommuneService communeService;
|
||||
@@ -185,31 +185,7 @@ public class CommuneController {
|
||||
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
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."),
|
||||
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Département")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
public class DepartementController {
|
||||
|
||||
private final DepartementService departementService;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Nationalité")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
public class NationaliteController {
|
||||
|
||||
private final NationaliteService nationaliteService;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Quartier")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||
public class QuartierController {
|
||||
|
||||
private final QuartierService quartierService;
|
||||
@@ -158,7 +158,7 @@ public class QuartierController {
|
||||
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.getQuartierById(id).orElse(null), "Quartier trouvé avec succès."),
|
||||
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
@@ -182,31 +182,7 @@ public class QuartierController {
|
||||
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
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."),
|
||||
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -36,11 +35,11 @@ public class SecteurDecoupageController {
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
||||
try {
|
||||
secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
|
||||
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
|
||||
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
@@ -60,10 +59,10 @@ public class SecteurDecoupageController {
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
|
||||
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
@@ -153,58 +152,11 @@ 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}")
|
||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class StructureController {
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
||||
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated StructurePaylaodWeb structurePaylaodWeb) {
|
||||
try {
|
||||
structurePaylaodWeb = structureService.createStructure(structurePaylaodWeb);
|
||||
return new ResponseEntity<>(
|
||||
@@ -211,7 +211,7 @@ public class StructureController {
|
||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structureService.getStructureById(id), "Structure trouvé avec succès."),
|
||||
new ApiResponse<>(true, structureService.getStructureByIdToDto(id), "Structure trouvé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -116,5 +116,18 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -115,10 +113,10 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/validate-user-account/{userName}")
|
||||
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
|
||||
@PostMapping("/validate-user-account")
|
||||
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
||||
try {
|
||||
User user = userService.validateUserAccount(userName);
|
||||
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
|
||||
HttpStatus.OK
|
||||
@@ -232,11 +230,17 @@ public class UserController {
|
||||
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<?> getAll() {
|
||||
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
|
||||
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<>(
|
||||
new ApiResponse<>(true, userService.getListUserToDto(), "Liste des utilisateurs chargée avec succès."),
|
||||
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
@@ -254,65 +258,20 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
@GetMapping("/all-by-structure")
|
||||
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserToDto(pageable), "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("/all-by-structure/{structureId}")
|
||||
public ResponseEntity<?> getAllByStructure(@PathVariable Long structureId) {
|
||||
try {
|
||||
|
||||
if (userPrincipal.getUser().getStructure() != null) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
|
||||
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "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);
|
||||
|
||||
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
|
||||
new ApiResponse<>(false, "Impossible de trouver la structure indiqué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);
|
||||
|
||||
@@ -30,11 +30,11 @@ import java.util.Set;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//@SQLDelete(sql =
|
||||
// "UPDATE structure " +
|
||||
// "SET deleted = true " +
|
||||
// "WHERE id = ?")
|
||||
//@Where(clause = " deleted = false")
|
||||
@SQLDelete(sql =
|
||||
"UPDATE structure " +
|
||||
"SET deleted = true " +
|
||||
"WHERE id = ?")
|
||||
@Where(clause = " deleted = false")
|
||||
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public class Structure extends BaseEntity implements Serializable {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Structure extends BaseEntity implements Serializable {
|
||||
private String tel;
|
||||
private String email;
|
||||
private String adresse;
|
||||
//@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
|
||||
@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
|
||||
@ManyToOne
|
||||
private Commune commune;
|
||||
|
||||
@@ -61,17 +61,4 @@ public class Structure extends BaseEntity implements Serializable {
|
||||
)
|
||||
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,7 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -56,28 +55,27 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable) {
|
||||
return arrondissementRepository.findAllArrondissementToDtoPageable(pageable);
|
||||
public Page<Arrondissement> getArrondissementList(Pageable pageable) {
|
||||
return arrondissementRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArrondissementPaylaodWeb> getArrondissementList() {
|
||||
return arrondissementRepository.findAllArrondissementToDto();
|
||||
public List<Arrondissement> getArrondissementList() {
|
||||
return arrondissementRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId) {
|
||||
return arrondissementRepository.findAllArrondissementByCommuneToDto(communeId);
|
||||
public Optional<Arrondissement> getArrondissementById(Long id) {
|
||||
return arrondissementRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId, Pageable pageable) {
|
||||
return arrondissementRepository.findAllArrondissementByCommuneToDtoPageable(communeId,pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id) {
|
||||
return arrondissementRepository.findArrondissementToDtoById(id);
|
||||
public List<Arrondissement> getArrondissementByComune(Long communeId) {
|
||||
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
|
||||
if (communeOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
|
||||
}
|
||||
return arrondissementRepository.findAllByCommune(communeOptional.get());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -57,28 +55,27 @@ public class CommuneServiceImpl implements CommuneService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CommunePaylaodWeb> getCommuneList(Pageable pageable) {
|
||||
return communeRepository.findAllCommuneToDtoPageable(pageable);
|
||||
public Page<Commune> getCommuneList(Pageable pageable) {
|
||||
return communeRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Commune> getCommuneList() {
|
||||
return communeRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CommunePaylaodWeb> getCommuneList() {
|
||||
return communeRepository.findAllCommuneToDto();
|
||||
public List<Commune> getCommunesByDepartement(Long departementId) {
|
||||
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
|
||||
if (departementOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié.");
|
||||
}
|
||||
return communeRepository.findAllByDepartement(departementOptional.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId) {
|
||||
return communeRepository.findAllCommuneByDepartementToDto(departementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId, Pageable pageable) {
|
||||
return communeRepository.findAllCommuneByDepartementToDtoPageable(departementId,pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<CommunePaylaodWeb> getCommuneById(Long id) {
|
||||
return communeRepository.findCommuneToDtoById(id);
|
||||
public Optional<Commune> getCommuneById(Long id) {
|
||||
return communeRepository.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.gmss.fiscad.entities.decoupage.Departement;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.DepartementRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -52,20 +51,20 @@ public class DepartementServiceImpl implements DepartementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable) {
|
||||
return departementRepository.findAllDepartementToDtoPageable(pageable);
|
||||
public Page<Departement> getDepartementList(Pageable pageable) {
|
||||
return departementRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartementPaylaodWeb> getDepartementList() {
|
||||
return departementRepository.findAllDepartementToDto();
|
||||
public List<Departement> getDepartementList() {
|
||||
return departementRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<DepartementPaylaodWeb> getDepartementById(Long id) {
|
||||
public Optional<Departement> getDepartementById(Long id) {
|
||||
if (departementRepository.existsById(id)) {
|
||||
return departementRepository.findDepartementToDtoById(id);
|
||||
return departementRepository.findById(id);
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -56,28 +55,31 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable) {
|
||||
return quartierRepository.findAllQuartierToDtoPageable(pageable);
|
||||
public Page<Quartier> getQuartierList(Pageable pageable) {
|
||||
return quartierRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartierPaylaodWeb> getQuartierList() {
|
||||
return quartierRepository.findAllQuartierToDto();
|
||||
public List<Quartier> getQuartierList() {
|
||||
return quartierRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId) {
|
||||
return quartierRepository.findAllQuartierByArrondissementToDto(arrondissementId);
|
||||
public Optional<Quartier> getQuartierById(Long id) {
|
||||
if (quartierRepository.existsById(id)) {
|
||||
return quartierRepository.findById(id);
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId, Pageable pageable) {
|
||||
return quartierRepository.findAllQuartierByArrondissementToDtoPageable(arrondissementId,pageable);
|
||||
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
|
||||
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
|
||||
if (arrondissementOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
|
||||
}
|
||||
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<QuartierPaylaodWeb> getQuartierById(Long id) {
|
||||
return quartierRepository.findQuartierToDtoById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,9 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -26,33 +23,26 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||
private final SecteurService secteurService;
|
||||
private final ParcelleRepository parcelleRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
|
||||
if (secteurDecoupagePaylaodWeb.getId() != null) {
|
||||
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
|
||||
if (secteurDecoupage.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
||||
}
|
||||
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
||||
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
|
||||
if (secteurDecoupagePaylaodWeb.getId() == null) {
|
||||
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
|
||||
if (secteurDecoupage.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
||||
}
|
||||
if (!secteurDecoupageRepository.existsById(secteurDecoupagePaylaodWeb.getId())) {
|
||||
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
||||
}
|
||||
|
||||
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
||||
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
||||
|
||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,28 +56,13 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
|
||||
return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
|
||||
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) {
|
||||
return secteurDecoupageRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList() {
|
||||
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);
|
||||
public List<SecteurDecoupage> getSecteurDecoupageList() {
|
||||
return secteurDecoupageRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ public class SecteurServiceImpl implements SecteurService {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
||||
}
|
||||
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
||||
|
||||
secteur = secteurRepository.save(secteur);
|
||||
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.BlocService;
|
||||
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.service.StringService;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -78,7 +77,7 @@ public class BlocServiceImpl implements BlocService {
|
||||
}
|
||||
}
|
||||
|
||||
Optional<StructurePaylaodWeb> structureOptional = structureService.getStructureById(structure_id);
|
||||
Optional<Structure> structureOptional = structureService.getStructureById(structure_id);
|
||||
if (structureOptional.isPresent()) {
|
||||
builder.append(structureOptional.get().getCode());
|
||||
builder.append(bloc.getArrondissement().getCode());
|
||||
@@ -134,7 +133,10 @@ public class BlocServiceImpl implements BlocService {
|
||||
|
||||
@Override
|
||||
public List<Bloc> getBlocsByArrondissement(Long idArrondissement) {
|
||||
return blocRepository.findAllByArrondissement_Id(idArrondissement);
|
||||
Arrondissement arrondissement = arrondissementService.getArrondissementById(idArrondissement).orElseThrow(() -> {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement");
|
||||
});
|
||||
return blocRepository.findAllByArrondissement(arrondissement);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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.exceptions.BadRequestException;
|
||||
@@ -24,34 +23,64 @@ public class StructureServiceImpl implements StructureService {
|
||||
private final StructureRepository structureRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
|
||||
// @Override
|
||||
// public StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException {
|
||||
// if (structure.getId() != null) {
|
||||
// throw new BadRequestException("Impossible de créer une structure ayant un id non null.");
|
||||
// }
|
||||
// StringBuilder builder = new StringBuilder();
|
||||
// builder.append("C");
|
||||
// builder.append(structureRepository.getLastRecordId() + 1);
|
||||
// structure.setCode(builder.toString());
|
||||
// return structureRepository.save(structure);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Structure updateStructure(Long id, Structure structure) throws NotFoundException {
|
||||
//
|
||||
// System.out.println("structure = " + structure);
|
||||
//
|
||||
// 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.");
|
||||
// }
|
||||
// try {
|
||||
// structureRepository.save(structure);
|
||||
//
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// Structure structure1 = structureRepository.getById(structure.getId());
|
||||
//
|
||||
// return structure1;
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
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);
|
||||
structureRepository.save(structure);
|
||||
return structureRepository.findStructureToDtoById(structure.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructurePaylaodWeb updateStructure(Long id, StructurePaylaodWeb structurePaylaodWeb) throws NotFoundException {
|
||||
if (structurePaylaodWeb.getId() == null) {
|
||||
throw new BadRequestException("ID obligatoire pour une mise à jour.");
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau centre ayant un id null.");
|
||||
}
|
||||
|
||||
System.out.println(structurePaylaodWeb.getId());
|
||||
Optional<Structure> optionalStructure = structureRepository.findById(structurePaylaodWeb.getId());
|
||||
if(optionalStructure.isEmpty()){
|
||||
throw new NotFoundException("Structure inexistante.");
|
||||
if (!structureRepository.existsById(structurePaylaodWeb.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le centre spécifiée.");
|
||||
}
|
||||
|
||||
Structure structure = entityFromPayLoadService.getStructureFromPayLoadWeb(structurePaylaodWeb);
|
||||
structureRepository.save(structure);
|
||||
|
||||
return structureRepository
|
||||
.findStructureToDtoById(structure.getId())
|
||||
.orElse(null);
|
||||
Structure structure= entityFromPayLoadService.getStructureFromPayLoadWeb(structurePaylaodWeb);
|
||||
structure = structureRepository.save(structure);
|
||||
// structureRepository.findStructureToDtoById(structure.getId()).orElse(null);
|
||||
return structureRepository.findStructureToDtoById(structure.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,9 +114,16 @@ public class StructureServiceImpl implements StructureService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StructurePaylaodWeb> getStructureById(Long id) {
|
||||
public Optional<StructurePaylaodWeb> getStructureByIdToDto(Long id) {
|
||||
return structureRepository.findStructureToDtoById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<Structure> getStructureById(Long id) {
|
||||
if (structureRepository.existsById(id)) {
|
||||
return structureRepository.findById(id);
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans la base de données.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ public class UserServiceImpl implements UserService {
|
||||
user.setPassword(passwordEncoder.encode(userPaylaodWeb.getPassword()));
|
||||
userRepository.save(user);
|
||||
|
||||
return userRepository.findUserToDtoById(userPaylaodWeb.getId()).orElse(null);
|
||||
|
||||
return userPaylaodWeb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,14 +220,17 @@ public class UserServiceImpl implements UserService {
|
||||
return optionalUserPaylaodWeb.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User assignStructureToUser(Structure structure) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User validateUserAccount(String username) {
|
||||
public User validateUserAccount(String username, UserRole userRole) {
|
||||
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
|
||||
String.format("L'utilisateur %s n'existe pas.", username)
|
||||
));
|
||||
user.setResetPassword(false);
|
||||
user.setActive(true);
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
@@ -261,34 +265,4 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UserPaylaodWeb> getUserByToDto(String username) {
|
||||
return userRepository.findUserToDtoByUserName(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UserPaylaodWeb> getUserByIdToDto(Long id) {
|
||||
return userRepository.findUserToDtoById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserPaylaodWeb> getListUserToDto() {
|
||||
return userRepository.findAllUserToDto();
|
||||
}
|
||||
|
||||
@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,7 +3,6 @@ package io.gmss.fiscad.interfaces.decoupage;
|
||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -18,11 +17,11 @@ public interface ArrondissementService {
|
||||
|
||||
void deleteArrondissement(Long id) throws NotFoundException;
|
||||
|
||||
Page<Arrondissement> getArrondissementList(Pageable pageable);
|
||||
|
||||
Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable);
|
||||
List<ArrondissementPaylaodWeb> getArrondissementList();
|
||||
List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId);
|
||||
Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long structureId,Pageable pageable);
|
||||
List<Arrondissement> getArrondissementList();
|
||||
|
||||
Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id);
|
||||
Optional<Arrondissement> getArrondissementById(Long id);
|
||||
|
||||
List<Arrondissement> getArrondissementByComune(Long communeId);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.gmss.fiscad.interfaces.decoupage;
|
||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -18,12 +17,11 @@ public interface CommuneService {
|
||||
|
||||
void deleteCommune(Long id) throws NotFoundException;
|
||||
|
||||
Page<CommunePaylaodWeb> getCommuneList(Pageable pageable);
|
||||
Page<Commune> getCommuneList(Pageable pageable);
|
||||
|
||||
List<CommunePaylaodWeb> getCommuneList();
|
||||
List<Commune> getCommuneList();
|
||||
|
||||
List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId);
|
||||
Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId,Pageable pageable);
|
||||
List<Commune> getCommunesByDepartement(Long departementId);
|
||||
|
||||
Optional<CommunePaylaodWeb> getCommuneById(Long id) ;
|
||||
Optional<Commune> getCommuneById(Long id);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.gmss.fiscad.interfaces.decoupage;
|
||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -18,9 +17,9 @@ public interface DepartementService {
|
||||
|
||||
void deleteDepartement(Long id) throws NotFoundException;
|
||||
|
||||
Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable);
|
||||
Page<Departement> getDepartementList(Pageable pageable);
|
||||
|
||||
List<DepartementPaylaodWeb> getDepartementList();
|
||||
List<Departement> getDepartementList();
|
||||
|
||||
Optional<DepartementPaylaodWeb> getDepartementById(Long id);
|
||||
Optional<Departement> getDepartementById(Long id);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.gmss.fiscad.interfaces.decoupage;
|
||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -18,11 +17,11 @@ public interface QuartierService {
|
||||
|
||||
void deleteQuartier(Long id) throws NotFoundException;
|
||||
|
||||
Page<Quartier> getQuartierList(Pageable pageable);
|
||||
|
||||
Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable);
|
||||
List<QuartierPaylaodWeb> getQuartierList();
|
||||
List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId);
|
||||
Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId,Pageable pageable);
|
||||
List<Quartier> getQuartierList();
|
||||
|
||||
Optional<QuartierPaylaodWeb> getQuartierById(Long id);
|
||||
Optional<Quartier> getQuartierById(Long id);
|
||||
|
||||
List<Quartier> getQuartierByArrondissement(Long arrondissementId);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.gmss.fiscad.interfaces.decoupage;
|
||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
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 org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -14,20 +12,15 @@ import java.util.Optional;
|
||||
|
||||
public interface SecteurDecoupageService {
|
||||
|
||||
SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteur) throws BadRequestException;
|
||||
SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException;
|
||||
|
||||
SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteur) throws NotFoundException;
|
||||
SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException;
|
||||
|
||||
void deleteSecteurDecoupage(Long id) throws NotFoundException;
|
||||
|
||||
Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable);
|
||||
Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable);
|
||||
|
||||
List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList();
|
||||
|
||||
Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId,Pageable pageable);
|
||||
List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId);
|
||||
|
||||
Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id);
|
||||
List<SecteurDecoupage> getSecteurDecoupageList();
|
||||
|
||||
Optional<SecteurDecoupage> getSecteurDecoupageById(Long id);
|
||||
|
||||
|
||||
@@ -12,6 +12,16 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface StructureService {
|
||||
|
||||
// Structure createStructure(Structure structure) throws BadRequestException;
|
||||
//
|
||||
// Structure updateStructure(Long id, Structure structure) throws NotFoundException;
|
||||
//
|
||||
// void deleteStructure(Long id) throws NotFoundException;
|
||||
//
|
||||
// Page<Structure> getStructureList(Pageable pageable);
|
||||
//
|
||||
// List<Structure> getStructureList();
|
||||
StructurePaylaodWeb createStructure(StructurePaylaodWeb structurePaylaodWeb) throws BadRequestException;
|
||||
|
||||
StructurePaylaodWeb updateStructure(Long id, StructurePaylaodWeb structurePaylaodWeb) throws NotFoundException;
|
||||
@@ -20,15 +30,13 @@ public interface StructureService {
|
||||
|
||||
Page<StructurePaylaodWeb> getStructureList(Pageable pageable);
|
||||
List<StructurePaylaodWeb> getStructureList();
|
||||
List<StructurePaylaodWeb> getStructureListByCommuneId(Long structureId);
|
||||
Page<StructurePaylaodWeb> getStructureListByCommuneId(Long structureId,Pageable pageable);
|
||||
|
||||
List<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId);
|
||||
|
||||
Page<StructurePaylaodWeb> getStructureListByCommuneId(Long communeId,Pageable pageable);
|
||||
|
||||
Optional<StructurePaylaodWeb> getStructureById(Long id);
|
||||
Optional<StructurePaylaodWeb> getStructureByIdToDto(Long id);
|
||||
|
||||
|
||||
//List<StructureResponse> getStructuresByArrondissement(Long arrondissementID);
|
||||
|
||||
|
||||
Optional<Structure> getStructureById(Long id);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserService {
|
||||
UserPaylaodWeb createUser(UserPaylaodWeb userPaylaodWeb);
|
||||
@@ -39,16 +38,15 @@ public interface UserService {
|
||||
|
||||
User getUserById(Long id);
|
||||
|
||||
|
||||
User getUserByUsername(String username);
|
||||
|
||||
|
||||
User activateOrNotUser(Long id);
|
||||
|
||||
UserPaylaodWeb resetPassword(String username, String password);
|
||||
|
||||
User assignStructureToUser(Structure structure);
|
||||
|
||||
User validateUserAccount(String username);
|
||||
User validateUserAccount(String username, UserRole userRole);
|
||||
|
||||
UserListByStructureResponse getListUserByStructure(Long structureId);
|
||||
|
||||
@@ -56,11 +54,5 @@ public interface UserService {
|
||||
|
||||
UserResponse getUserResponseFromUser(User user);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,12 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
|
||||
import io.gmss.fiscad.paylaods.response.synchronisation.ArrondissementSyncResponse;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
|
||||
List<Arrondissement> findAllByCommune(Commune commune);
|
||||
@@ -38,94 +33,4 @@ public interface ArrondissementRepository extends JpaRepository<Arrondissement,
|
||||
" where sa.structure_id = ?1 )T " +
|
||||
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
|
||||
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom,
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom
|
||||
)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
""")
|
||||
List<ArrondissementPaylaodWeb> findAllArrondissementToDto();
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom,
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom
|
||||
)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
WHERE arr.id = :arrondissementId
|
||||
""")
|
||||
Optional<ArrondissementPaylaodWeb> findArrondissementToDtoById(@Param("arrondissementId") Long arrondissementId);
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom,
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom
|
||||
)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT arr.id)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
"""
|
||||
)
|
||||
Page<ArrondissementPaylaodWeb> findAllArrondissementToDtoPageable(Pageable pageable);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom,
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom
|
||||
)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
WHERE arr.commune.id = :communeId
|
||||
""")
|
||||
List<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDto(@Param("communeId") Long communeId);
|
||||
|
||||
|
||||
@Query(value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom,
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom
|
||||
)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
WHERE arr.commune.id = :communeId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT arr.id)
|
||||
FROM Arrondissement arr
|
||||
LEFT JOIN arr.commune com
|
||||
WHERE arr.commune.id = :communeId
|
||||
""")
|
||||
Page<ArrondissementPaylaodWeb> findAllArrondissementByCommuneToDtoPageable(@Param("communeId") Long communeId, Pageable pageable);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,17 +2,12 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.CommuneEnqResponse;
|
||||
import io.gmss.fiscad.paylaods.response.synchronisation.CommuneSyncResponse;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
||||
|
||||
@@ -20,7 +15,7 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
||||
List<CommuneSyncResponse> getCommuneResponse();
|
||||
|
||||
|
||||
List<Commune> findAllByDepartement_Id(Long departementId);
|
||||
List<Commune> findAllByDepartement(Departement departement);
|
||||
|
||||
@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" +
|
||||
@@ -42,95 +37,4 @@ public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
||||
" group by T.id,T.code, T.libelle,T.longitude,T.latitude",nativeQuery = true)
|
||||
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
|
||||
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom,
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
""")
|
||||
List<CommunePaylaodWeb> findAllCommuneToDto();
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom,
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
WHERE com.id = :idCommune
|
||||
""")
|
||||
Optional<CommunePaylaodWeb> findCommuneToDtoById(@Param("idCommune") Long idCommune);
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom,
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT com.id)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
"""
|
||||
)
|
||||
Page<CommunePaylaodWeb> findAllCommuneToDtoPageable(Pageable pageable);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom,
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
WHERE com.departement.id = :departementId
|
||||
""")
|
||||
List<CommunePaylaodWeb> findAllCommuneByDepartementToDto(@Param("departementId") Long departementId);
|
||||
|
||||
|
||||
@Query(value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb(
|
||||
com.id,
|
||||
com.code,
|
||||
com.nom,
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
WHERE com.departement.id = :departementId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT com.id)
|
||||
FROM Commune com
|
||||
LEFT JOIN com.departement dep
|
||||
WHERE com.departement.id = :departementId
|
||||
""")
|
||||
Page<CommunePaylaodWeb> findAllCommuneByDepartementToDtoPageable(@Param("departementId") Long departementId, Pageable pageable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.synchronisation.DepartementSyncResponse;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public interface DepartementRepository extends JpaRepository<Departement, Long> {
|
||||
@@ -19,44 +14,4 @@ public interface DepartementRepository extends JpaRepository<Departement, Long>
|
||||
" where departement.deleted is false ", nativeQuery = true)
|
||||
List<DepartementSyncResponse> getDepartementResponse();
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Departement dep
|
||||
""")
|
||||
List<DepartementPaylaodWeb> findAllDepartementToDto();
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Departement dep
|
||||
WHERE dep.id = :idDepartement
|
||||
""")
|
||||
Optional<DepartementPaylaodWeb> findDepartementToDtoById(@Param("idDepartement") Long idDepartement);
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb(
|
||||
dep.id,
|
||||
dep.code,
|
||||
dep.nom
|
||||
)
|
||||
FROM Departement dep
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT dep.id)
|
||||
FROM Departement dep
|
||||
"""
|
||||
)
|
||||
Page<DepartementPaylaodWeb> findAllDepartementToDtoPageable(Pageable pageable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,11 @@ package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.synchronisation.QuartierSyncResponse;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
||||
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
|
||||
@@ -28,94 +23,5 @@ public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
||||
" where q.deleted is false ", nativeQuery = true)
|
||||
List<QuartierSyncResponse> getAdminQuartierResponse();
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||
qua.id,
|
||||
qua.code,
|
||||
qua.nom,
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom
|
||||
)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
""")
|
||||
List<QuartierPaylaodWeb> findAllQuartierToDto();
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||
qua.id,
|
||||
qua.code,
|
||||
qua.nom,
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom
|
||||
)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
WHERE qua.id = :idQuartier
|
||||
""")
|
||||
Optional<QuartierPaylaodWeb> findQuartierToDtoById(@Param("idQuartier") Long idQuartier);
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||
qua.id,
|
||||
qua.code,
|
||||
qua.nom,
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom
|
||||
)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT qua.id)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
"""
|
||||
)
|
||||
Page<QuartierPaylaodWeb> findAllQuartierToDtoPageable(Pageable pageable);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||
qua.id,
|
||||
qua.code,
|
||||
qua.nom,
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom
|
||||
)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
WHERE qua.arrondissement.id = :arrondissementId
|
||||
""")
|
||||
List<QuartierPaylaodWeb> findAllQuartierByArrondissementToDto(@Param("arrondissementId") Long arrondissementId);
|
||||
|
||||
|
||||
@Query(value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb(
|
||||
qua.id,
|
||||
qua.code,
|
||||
qua.nom,
|
||||
arr.id,
|
||||
arr.code,
|
||||
arr.nom
|
||||
)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
WHERE qua.arrondissement.id = :arrondissementId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT qua.id)
|
||||
FROM Quartier qua
|
||||
LEFT JOIN qua.arrondissement arr
|
||||
WHERE qua.arrondissement.id = :arrondissementId
|
||||
""")
|
||||
Page<QuartierPaylaodWeb> findAllQuartierByArrondissementToDtoPageable(@Param("arrondissementId") Long arrondissementId, Pageable pageable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,148 +1,7 @@
|
||||
package io.gmss.fiscad.persistence.repositories.decoupage;
|
||||
|
||||
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.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
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,7 +36,6 @@ public interface BlocRepository extends JpaRepository<Bloc, Long> {
|
||||
List<BlocsParStructureResponse> getBlocsParStructureResponse(Long structure_id);
|
||||
|
||||
List<Bloc> findAllByArrondissement(Arrondissement arrondissement);
|
||||
List<Bloc> findAllByArrondissement_Id(Long arrondissementId);
|
||||
|
||||
@Query(value = "select structure_id as id from arrondissements_structures " +
|
||||
" where arrondissement_id = ?1" +
|
||||
|
||||
@@ -62,24 +62,6 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
""")
|
||||
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(
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package io.gmss.fiscad.service;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.*;
|
||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||
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.Parcelle;
|
||||
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
||||
@@ -12,18 +15,17 @@ import io.gmss.fiscad.entities.user.AvoirFonction;
|
||||
import io.gmss.fiscad.entities.user.Fonction;
|
||||
import io.gmss.fiscad.entities.user.Profile;
|
||||
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.persistence.repositories.decoupage.*;
|
||||
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
||||
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.ParcelleRepository;
|
||||
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.rfu.metier.*;
|
||||
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.UserRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -58,22 +60,9 @@ public class EntityFromPayLoadService {
|
||||
private final UserRepository userRepository;
|
||||
private final ProfileRepository profileRepository;
|
||||
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){
|
||||
CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle();
|
||||
if(caracteristiqueParcellePayloadWeb.getId()!=null)
|
||||
caracteristiqueParcelle = caracteristiqueParcelleRepository.findById(caracteristiqueParcellePayloadWeb.getId()).orElse(new CaracteristiqueParcelle());
|
||||
|
||||
Optional<Enquete> optionalEnquete=Optional.empty();
|
||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||
|
||||
@@ -92,9 +81,6 @@ public class EntityFromPayLoadService {
|
||||
|
||||
public CaracteristiqueBatiment getCaracteristiqueBatimentFromPayLoadWeb(CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb){
|
||||
CaracteristiqueBatiment caracteristiqueBatiment=new CaracteristiqueBatiment();
|
||||
if(caracteristiqueBatimentPayloadWeb.getId()!=null)
|
||||
caracteristiqueBatiment = caracteristiqueBatimentRepository.findById(caracteristiqueBatimentPayloadWeb.getId()).orElse(new CaracteristiqueBatiment());
|
||||
|
||||
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||
|
||||
@@ -119,10 +105,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
||||
Optional<Caracteristique> optionalCaracteristique=Optional.empty();
|
||||
|
||||
if(caracteristiqueUniteLogementPayloadWeb.getId()!=null)
|
||||
caracteristiqueUniteLogement = caracteristiqueUniteLogementRepository.findById(caracteristiqueUniteLogementPayloadWeb.getId()).orElse(new CaracteristiqueUniteLogement());
|
||||
|
||||
|
||||
if(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId()!=null)
|
||||
optionalEnqueteUniteLogement=enqueteUniteLogementRepository.findById(caracteristiqueUniteLogementPayloadWeb.getEnqueteUniteLogementId());
|
||||
|
||||
@@ -145,9 +127,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<SourceDroit> optionalSourceDroit=Optional.empty();
|
||||
Optional<ModeAcquisition> optionalModeAcquisition=Optional.empty();
|
||||
Optional<Personne> optionalPersonne=Optional.empty();
|
||||
if(piecePayLoadWeb.getId()!=null)
|
||||
piece = pieceRepository.findById(piecePayLoadWeb.getId()).orElse(new Piece());
|
||||
|
||||
|
||||
if(piecePayLoadWeb.getEnqueteId()!=null)
|
||||
optionalEnquete=enqueteRepository.findById(piecePayLoadWeb.getEnqueteId());
|
||||
@@ -181,10 +160,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<Enquete> optionalEnquete=Optional.empty();
|
||||
Optional<Personne> optionalPersonne=Optional.empty();
|
||||
Optional<Structure> optionalStructure=Optional.empty();
|
||||
if(declarationNcPayloadWeb.getId()!=null)
|
||||
declarationNc = declarationNcRepository.findById(declarationNcPayloadWeb.getId()).orElse(new DeclarationNc());
|
||||
|
||||
|
||||
if(declarationNcPayloadWeb.getEnqueteId()!=null)
|
||||
optionalEnquete=enqueteRepository.findById(declarationNcPayloadWeb.getEnqueteId());
|
||||
if(declarationNcPayloadWeb.getPersonneId()!=null)
|
||||
@@ -202,13 +177,11 @@ public class EntityFromPayLoadService {
|
||||
|
||||
public Upload getUploadFromPayLoadWeb(UploadPayLoadWeb uploadPayLoadWeb){
|
||||
Upload upload=new Upload();
|
||||
//Optional<Enquete> optionalEnquete=Optional.empty() ;
|
||||
//Optional<Enquete> optionalEnquete=Optional.empty();
|
||||
Optional<DeclarationNc> optionalDeclarationNc=Optional.empty();
|
||||
Optional<Personne> optionalPersonne=Optional.empty();
|
||||
Optional<EnqueteBatiment> optionalEnqueteBatiment=Optional.empty();
|
||||
Optional<EnqueteUniteLogement> optionalEnqueteUniteLogement=Optional.empty();
|
||||
if(uploadPayLoadWeb.getId()!=null)
|
||||
upload = uploadRepository.findById(uploadPayLoadWeb.getId()).orElse(new Upload());
|
||||
|
||||
// if(uploadPayLoadWeb.getEnqueteId()!=null)
|
||||
// optionalEnquete=enqueteRepository.findById(uploadPayLoadWeb.getEnqueteId());
|
||||
@@ -237,9 +210,6 @@ public class EntityFromPayLoadService {
|
||||
public Batiment getBatimentFromPayLoadWeb(BatimentPaylaodWeb batimentPaylaodWeb){
|
||||
Batiment batiment=new Batiment();
|
||||
Optional<Parcelle> optionalParcelle=Optional.empty();
|
||||
if(batimentPaylaodWeb.getId()!=null)
|
||||
batiment = batimentRepository.findById(batimentPaylaodWeb.getId()).orElse(new Batiment());
|
||||
|
||||
|
||||
if(batimentPaylaodWeb.getParcelleId()!=null)
|
||||
optionalParcelle=parcelleRepository.findById(batimentPaylaodWeb.getParcelleId());
|
||||
@@ -257,9 +227,6 @@ public class EntityFromPayLoadService {
|
||||
public Section getSectionFromPayLoadWeb(SectionPaylaodWeb sectionPaylaodWeb){
|
||||
Section section =new Section();
|
||||
Optional<Structure> optionalStructure = Optional.empty();
|
||||
if(sectionPaylaodWeb.getId()!=null)
|
||||
section = sectionRepository.findById(sectionPaylaodWeb.getId()).orElse(new Section());
|
||||
|
||||
|
||||
if(sectionPaylaodWeb.getStructureId()!=null)
|
||||
optionalStructure=structureRepository.findById(sectionPaylaodWeb.getStructureId());
|
||||
@@ -273,16 +240,13 @@ public class EntityFromPayLoadService {
|
||||
|
||||
public Structure getStructureFromPayLoadWeb(StructurePaylaodWeb structurePaylaodWeb){
|
||||
Structure structure =new Structure();
|
||||
if(structurePaylaodWeb.getId()!=null)
|
||||
structure = structureRepository.findById(structurePaylaodWeb.getId()).orElse(new Structure());
|
||||
Optional<Commune> optionalCommune = Optional.empty();
|
||||
|
||||
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);
|
||||
if(structurePaylaodWeb.getCommuneId()!=null)
|
||||
optionalCommune=communeRepository.findById(structurePaylaodWeb.getCommuneId());
|
||||
|
||||
structure.setId(structurePaylaodWeb.getId());
|
||||
structure.setCommune(optionalCommune.orElse(null));
|
||||
structure.setCode(structurePaylaodWeb.getCode());
|
||||
structure.setNom(structurePaylaodWeb.getNom());
|
||||
structure.setAdresse(structurePaylaodWeb.getAdresse());
|
||||
@@ -295,9 +259,6 @@ public class EntityFromPayLoadService {
|
||||
public Secteur getSecteurFromPayLoadWeb(SecteurPaylaodWeb secteurPaylaodWeb){
|
||||
Secteur secteur =new Secteur();
|
||||
Optional<Section> optionalSection = Optional.empty();
|
||||
if(secteurPaylaodWeb.getId()!=null)
|
||||
secteur = secteurRepository.findById(secteurPaylaodWeb.getId()).orElse(new Secteur());
|
||||
|
||||
|
||||
if(secteurPaylaodWeb.getSectionId()!=null)
|
||||
optionalSection=sectionRepository.findById(secteurPaylaodWeb.getSectionId());
|
||||
@@ -309,40 +270,9 @@ public class EntityFromPayLoadService {
|
||||
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){
|
||||
UniteLogement uniteLogement=new UniteLogement();
|
||||
Optional<Batiment> optionalBatiment=Optional.empty();
|
||||
if(uniteLogementPaylaodWeb.getId()!=null)
|
||||
uniteLogement = uniteLogementRepository.findById(uniteLogementPaylaodWeb.getId()).orElse(new UniteLogement());
|
||||
|
||||
|
||||
if(uniteLogementPaylaodWeb.getBatimentId()!=null)
|
||||
optionalBatiment=batimentRepository.findById(uniteLogementPaylaodWeb.getBatimentId());
|
||||
uniteLogement.setBatiment(optionalBatiment.orElse(null));
|
||||
@@ -361,10 +291,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<Profile> optionalProfile=Optional.empty();
|
||||
Optional<User> optionalUser=Optional.empty();
|
||||
Optional<Structure> optionalStructure=Optional.empty();
|
||||
if(fonctionPaylaodWeb.getId()!=null)
|
||||
fonction = fonctionRepository.findById(fonctionPaylaodWeb.getId()).orElse(new Fonction());
|
||||
|
||||
|
||||
|
||||
if(fonctionPaylaodWeb.getSecteurId()!=null)
|
||||
optionalSecteur=secteurRepository.findById(fonctionPaylaodWeb.getSecteurId());
|
||||
@@ -391,9 +317,6 @@ public class EntityFromPayLoadService {
|
||||
AvoirFonction avoirFonction =new AvoirFonction();
|
||||
Optional<Fonction> optionalFonction=Optional.empty();
|
||||
Optional<User> optionalUser=Optional.empty();
|
||||
if(avoirFonctionPaylaodWeb.getId()!=null)
|
||||
avoirFonction = avoirFonctionRepository.findById(avoirFonctionPaylaodWeb.getId()).orElse(new AvoirFonction());
|
||||
|
||||
|
||||
if(avoirFonctionPaylaodWeb.getFonctionId()!=null)
|
||||
optionalFonction=fonctionRepository.findById(avoirFonctionPaylaodWeb.getFonctionId());
|
||||
@@ -413,14 +336,10 @@ public class EntityFromPayLoadService {
|
||||
|
||||
public Profile getProfileFromPayLoadWeb(ProfilePaylaodWeb profilePaylaodWeb){
|
||||
Profile profile =new Profile();
|
||||
if(profilePaylaodWeb.getId()!=null)
|
||||
profile = profileRepository.findById(profilePaylaodWeb.getId()).orElse(new Profile());
|
||||
|
||||
profile.setDescription(profilePaylaodWeb.getDescription());
|
||||
profile.setRoles(profilePaylaodWeb.getRoles());
|
||||
profile.setNom(profilePaylaodWeb.getNom());
|
||||
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
@@ -431,9 +350,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<TypePersonne> optionalTypePersonne=Optional.empty();
|
||||
Optional<Profession> optionalProfession=Optional.empty();
|
||||
Optional<Commune> optionalCommune=Optional.empty();
|
||||
if(personnePayLoadWeb.getId()!=null)
|
||||
personne = personneRepository.findById(personnePayLoadWeb.getId()).orElse(new Personne());
|
||||
|
||||
|
||||
if(personnePayLoadWeb.getSituationMatrimonialeId()!=null)
|
||||
optionalSituationMatrimoniale=situationMatrimonialeRepository.findById(personnePayLoadWeb.getSituationMatrimonialeId());
|
||||
@@ -489,8 +405,6 @@ public class EntityFromPayLoadService {
|
||||
Optional<UniteLogement> optionalUniteLogement=Optional.empty();
|
||||
Optional<Parcelle> optionalParcelle=Optional.empty();
|
||||
Optional<Profession> optionalProfession=Optional.empty();
|
||||
if(enqueteActivitePayLoadWeb.getId()!=null)
|
||||
enqueteActivite = enqueteActiviteRepository.findById(enqueteActivitePayLoadWeb.getId()).orElse(new EnqueteActivite());
|
||||
|
||||
|
||||
if(enqueteActivitePayLoadWeb.getBatimentId()!=null)
|
||||
@@ -536,9 +450,6 @@ public class EntityFromPayLoadService {
|
||||
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());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
spring.profiles.active=${SPRING_PROFILES_ACTIVE}
|
||||
#spring.profiles.active=abomey
|
||||
# spring.profiles.active=test
|
||||
#spring.profiles.active=test
|
||||
spring.jpa.properties.hibernate.id.new_generator_mappings=false
|
||||
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
|
||||
spring.jpa.open-in-view=false
|
||||
|
||||
Reference in New Issue
Block a user