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

This commit is contained in:
2026-02-03 16:08:13 +01:00
parent fc6ff679f0
commit 2c0aad4d51
12 changed files with 444 additions and 58 deletions

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class SecteurDecoupageController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
try { try {
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage); secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."), new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class SecteurDecoupageController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."), new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -152,11 +153,58 @@ public class SecteurDecoupageController {
} }
} }
@GetMapping("/by-secteur-id/{secteurId}")
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurId(@PathVariable Long secteurId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId), "Liste des secteurDecoupages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-secteur-decoupage-id/{secteurId}")
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurIdPaged(@PathVariable Long secteurId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId,pageable), "Liste des secteurDecoupages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) { public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."), new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -15,6 +15,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -113,10 +115,10 @@ public class UserController {
} }
} }
@PostMapping("/validate-user-account") @PostMapping("/validate-user-account/{userName}")
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
try { try {
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole()); User user = userService.validateUserAccount(userName);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."), new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -230,17 +232,11 @@ public class UserController {
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) { public ResponseEntity<?> getAll() {
try { try {
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'êtes pas authorisés à accéder à la liste des utilisateurs"),
HttpStatus.OK
);
}
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."), new ApiResponse<>(true, userService.getListUserToDto(), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK); HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
@@ -258,20 +254,65 @@ public class UserController {
} }
} }
@GetMapping("/all-by-structure") @GetMapping("/all-paged")
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) { public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
if (userPrincipal.getUser().getStructure() != null) { Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
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 {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."), new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} else {
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/all-by-structure/{structureId}")
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."), new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);

View File

@@ -6,9 +6,12 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur; import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository; import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -23,26 +26,33 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
private final SecteurDecoupageRepository secteurDecoupageRepository; private final SecteurDecoupageRepository secteurDecoupageRepository;
private final SecteurService secteurService; private final SecteurService secteurService;
private final ParcelleRepository parcelleRepository; private final ParcelleRepository parcelleRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@Override @Override
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException { public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
if (secteurDecoupage.getId() != null) { if (secteurDecoupagePaylaodWeb.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
} }
return secteurDecoupageRepository.save(secteurDecoupage); SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
} }
@Override @Override
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException { public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
if (secteurDecoupage.getId() == null) { if (secteurDecoupagePaylaodWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
} }
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) { if (!secteurDecoupageRepository.existsById(secteurDecoupagePaylaodWeb.getId())) {
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié."); throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
} }
return secteurDecoupageRepository.save(secteurDecoupage);
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
} }
@Override @Override
@@ -56,13 +66,28 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
} }
@Override @Override
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) { public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
return secteurDecoupageRepository.findAll(pageable); return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
} }
@Override @Override
public List<SecteurDecoupage> getSecteurDecoupageList() { public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList() {
return secteurDecoupageRepository.findAll(); return secteurDecoupageRepository.findAllSecteurDecoupageToDto();
}
@Override
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long secteurId, Pageable pageable) {
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDtoPageable(secteurId,pageable);
}
@Override
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId) {
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDto(sectionId);
}
@Override
public Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id) {
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(id);
} }

View File

@@ -50,7 +50,6 @@ public class SecteurServiceImpl implements SecteurService {
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
} }
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb); Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
secteur = secteurRepository.save(secteur); secteur = secteurRepository.save(secteur);
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null); return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
} }

View File

@@ -59,8 +59,7 @@ public class UserServiceImpl implements UserService {
user.setPassword(passwordEncoder.encode(userPaylaodWeb.getPassword())); user.setPassword(passwordEncoder.encode(userPaylaodWeb.getPassword()));
userRepository.save(user); userRepository.save(user);
return userRepository.findUserToDtoById(userPaylaodWeb.getId()).orElse(null);
return userPaylaodWeb;
} }
@Override @Override
@@ -220,17 +219,14 @@ public class UserServiceImpl implements UserService {
return optionalUserPaylaodWeb.orElse(null); return optionalUserPaylaodWeb.orElse(null);
} }
@Override
public User assignStructureToUser(Structure structure) {
return null;
}
@Override @Override
public User validateUserAccount(String username, UserRole userRole) { public User validateUserAccount(String username) {
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException( User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
String.format("L'utilisateur %s n'existe pas.", username) String.format("L'utilisateur %s n'existe pas.", username)
)); ));
user.setResetPassword(false); user.setResetPassword(false);
user.setActive(true);
return userRepository.save(user); return userRepository.save(user);
} }
@@ -265,4 +261,34 @@ 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);
}
} }

View File

@@ -3,6 +3,8 @@ package io.gmss.fiscad.interfaces.decoupage;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage; import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur; import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -12,15 +14,20 @@ import java.util.Optional;
public interface SecteurDecoupageService { public interface SecteurDecoupageService {
SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException; SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteur) throws BadRequestException;
SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException; SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteur) throws NotFoundException;
void deleteSecteurDecoupage(Long id) throws NotFoundException; void deleteSecteurDecoupage(Long id) throws NotFoundException;
Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable); Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable);
List<SecteurDecoupage> getSecteurDecoupageList(); List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList();
Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId,Pageable pageable);
List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId);
Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id);
Optional<SecteurDecoupage> getSecteurDecoupageById(Long id); Optional<SecteurDecoupage> getSecteurDecoupageById(Long id);

View File

@@ -12,6 +12,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
import java.util.Optional;
public interface UserService { public interface UserService {
UserPaylaodWeb createUser(UserPaylaodWeb userPaylaodWeb); UserPaylaodWeb createUser(UserPaylaodWeb userPaylaodWeb);
@@ -38,15 +39,16 @@ public interface UserService {
User getUserById(Long id); User getUserById(Long id);
User getUserByUsername(String username); User getUserByUsername(String username);
User activateOrNotUser(Long id); User activateOrNotUser(Long id);
UserPaylaodWeb resetPassword(String username, String password); UserPaylaodWeb resetPassword(String username, String password);
User assignStructureToUser(Structure structure);
User validateUserAccount(String username, UserRole userRole); User validateUserAccount(String username);
UserListByStructureResponse getListUserByStructure(Long structureId); UserListByStructureResponse getListUserByStructure(Long structureId);
@@ -54,5 +56,11 @@ public interface UserService {
UserResponse getUserResponseFromUser(User user); 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);
} }

View File

@@ -0,0 +1,51 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import java.time.LocalDate;
@Data
public class SecteurDecoupagePaylaodWeb {
private Long id;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebut;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFin;
private Long secteurId;
private String secteurCode;
private String secteurNom;
private Long arrondissementId;
private String arrondissementCode;
private String arrondissementNom;
private Long quartierId;
private String quartierCode;
private String quartierNom;
public SecteurDecoupagePaylaodWeb(Long id, LocalDate dateDebut, LocalDate dateFin, Long secteurId, String secteurCode, String secteurNom, Long arrondissementId, String arrondissementCode, String arrondissementNom, Long quartierId, String quartierCode, String quartierNom) {
this.id = id;
this.dateDebut = dateDebut;
this.dateFin = dateFin;
this.secteurId = secteurId;
this.secteurCode = secteurCode;
this.secteurNom = secteurNom;
this.arrondissementId = arrondissementId;
this.arrondissementCode = arrondissementCode;
this.arrondissementNom = arrondissementNom;
this.quartierId = quartierId;
this.quartierCode = quartierCode;
this.quartierNom = quartierNom;
}
}

View File

@@ -1,7 +1,148 @@
package io.gmss.fiscad.persistence.repositories.decoupage; package io.gmss.fiscad.persistence.repositories.decoupage;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage; import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface SecteurDecoupageRepository extends JpaRepository<SecteurDecoupage, Long> { public interface SecteurDecoupageRepository extends JpaRepository<SecteurDecoupage, Long> {
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
sd.id,
sd.dateDebut,
sd.dateFin,
sect.id,
sect.code,
sect.nom,
a.id,
a.code,
a.nom,
q.id,
q.code,
q.nom
)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
""")
List<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageToDto();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
sd.id,
sd.dateDebut,
sd.dateFin,
sect.id,
sect.code,
sect.nom,
a.id,
a.code,
a.nom,
q.id,
q.code,
q.nom
)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
WHERE sd.id = :idSecteurDecoupage
""")
Optional<SecteurDecoupagePaylaodWeb> findSecteurDecoupageToDtoById(@Param("idSecteurDecoupage") Long idSecteurDecoupage);
@Query(
value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
sd.id,
sd.dateDebut,
sd.dateFin,
sect.id,
sect.code,
sect.nom,
a.id,
a.code,
a.nom,
q.id,
q.code,
q.nom
)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
""",
countQuery = """
SELECT COUNT(DISTINCT sd.id)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
"""
)
Page<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageToDtoPageable(Pageable pageable);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
sd.id,
sd.dateDebut,
sd.dateFin,
sect.id,
sect.code,
sect.nom,
a.id,
a.code,
a.nom,
q.id,
q.code,
q.nom
)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
WHERE sd.secteur.id = :secteurId
""")
List<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageBySecteurToDto(@Param("secteurId") Long secteurId);
@Query(value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb(
sd.id,
sd.dateDebut,
sd.dateFin,
sect.id,
sect.code,
sect.nom,
a.id,
a.code,
a.nom,
q.id,
q.code,
q.nom
)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
WHERE sd.secteur.id = :secteurId
""",
countQuery = """
SELECT COUNT(DISTINCT sd.id)
FROM SecteurDecoupage sd
LEFT JOIN sd.secteur sect
LEFT JOIN sd.arrondissement a
LEFT JOIN sd.quartier q
WHERE sd.secteur.id = :secteurId
""")
Page<SecteurDecoupagePaylaodWeb> findAllSecteurDecoupageBySecteurToDtoPageable(@Param("secteurId") Long secteurId, Pageable pageable);
} }

View File

@@ -62,6 +62,24 @@ public interface UserRepository extends JpaRepository<User, Long> {
""") """)
Optional<UserPaylaodWeb> findUserToDtoById(@Param("idUser") Long idUser); Optional<UserPaylaodWeb> findUserToDtoById(@Param("idUser") Long idUser);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
u.id,
u.nom,
u.prenom,
u.tel,
u.username,
u.email,
st.id,
st.code,
st.nom
)
FROM User u
LEFT JOIN u.structure st
WHERE u.username = :userName
""")
Optional<UserPaylaodWeb> findUserToDtoByUserName(@Param("userName") String userName);
@Query( @Query(
value = """ value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb( SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(

View File

@@ -1,9 +1,6 @@
package io.gmss.fiscad.service; package io.gmss.fiscad.service;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.*;
import io.gmss.fiscad.entities.decoupage.Nationalite;
import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.decoupage.Section;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Piece; import io.gmss.fiscad.entities.infocad.metier.Piece;
@@ -16,10 +13,7 @@ import io.gmss.fiscad.entities.user.Fonction;
import io.gmss.fiscad.entities.user.Profile; import io.gmss.fiscad.entities.user.Profile;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.paylaods.request.crudweb.*; import io.gmss.fiscad.paylaods.request.crudweb.*;
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository; import io.gmss.fiscad.persistence.repositories.decoupage.*;
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
import io.gmss.fiscad.persistence.repositories.decoupage.SectionRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.PieceRepository;
@@ -60,6 +54,8 @@ public class EntityFromPayLoadService {
private final UserRepository userRepository; private final UserRepository userRepository;
private final ProfileRepository profileRepository; private final ProfileRepository profileRepository;
private final SectionRepository sectionRepository; private final SectionRepository sectionRepository;
private final ArrondissementRepository arrondissementRepository;
private final QuartierRepository quartierRepository;
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){ public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle(); CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle();
@@ -270,6 +266,30 @@ public class EntityFromPayLoadService {
return secteur ; return secteur ;
} }
public SecteurDecoupage getSecteurDecoupageFromPayLoadWeb(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb){
SecteurDecoupage secteurDecoupage =new SecteurDecoupage();
Optional<Secteur> optionalSecteur = Optional.empty();
Optional<Arrondissement> optionalArrondissement = Optional.empty();
Optional<Quartier> optionalQuartier = Optional.empty();
if(secteurDecoupagePaylaodWeb.getSecteurId()!=null)
optionalSecteur=secteurRepository.findById(secteurDecoupagePaylaodWeb.getSecteurId());
if(secteurDecoupagePaylaodWeb.getArrondissementCode()!=null)
optionalArrondissement=arrondissementRepository.findById(secteurDecoupagePaylaodWeb.getArrondissementId());
if(secteurDecoupagePaylaodWeb.getQuartierId()!=null)
optionalQuartier=quartierRepository.findById(secteurDecoupagePaylaodWeb.getQuartierId());
secteurDecoupage.setId(secteurDecoupagePaylaodWeb.getId());
secteurDecoupage.setSecteur(optionalSecteur.orElse(null));
secteurDecoupage.setArrondissement(optionalArrondissement.orElse(null));
secteurDecoupage.setQuartier(optionalQuartier.orElse(null));
secteurDecoupage.setDateDebut(secteurDecoupagePaylaodWeb.getDateDebut());
secteurDecoupage.setDateFin(secteurDecoupagePaylaodWeb.getDateFin());
return secteurDecoupage ;
}
public UniteLogement getUniteLogementFromPayLoadWeb(UniteLogementPaylaodWeb uniteLogementPaylaodWeb){ public UniteLogement getUniteLogementFromPayLoadWeb(UniteLogementPaylaodWeb uniteLogementPaylaodWeb){
UniteLogement uniteLogement=new UniteLogement(); UniteLogement uniteLogement=new UniteLogement();
Optional<Batiment> optionalBatiment=Optional.empty(); Optional<Batiment> optionalBatiment=Optional.empty();
@@ -451,6 +471,8 @@ public class EntityFromPayLoadService {
User user =new User(); User user =new User();
Optional<Structure> optionalStructure = Optional.empty(); Optional<Structure> optionalStructure = Optional.empty();
System.out.println(userPaylaodWeb.getStructureId());
if(userPaylaodWeb.getStructureId()!=null) if(userPaylaodWeb.getStructureId()!=null)
optionalStructure=structureRepository.findById(userPaylaodWeb.getStructureId()); optionalStructure=structureRepository.findById(userPaylaodWeb.getStructureId());

View File

@@ -1,6 +1,6 @@
spring.profiles.active=${SPRING_PROFILES_ACTIVE} spring.profiles.active=${SPRING_PROFILES_ACTIVE}
#spring.profiles.active=abomey #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.id.new_generator_mappings=false
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.open-in-view=false spring.jpa.open-in-view=false