Compare commits
2 Commits
08b68f9e08
...
a10253b2e8
| Author | SHA1 | Date | |
|---|---|---|---|
| a10253b2e8 | |||
| 2c0aad4d51 |
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -35,11 +36,11 @@ public class SecteurDecoupageController {
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||
try {
|
||||
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
|
||||
secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
|
||||
new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
@@ -59,10 +60,10 @@ public class SecteurDecoupageController {
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
|
||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
||||
try {
|
||||
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
|
||||
);
|
||||
} 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}")
|
||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -15,6 +15,8 @@ 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;
|
||||
@@ -113,10 +115,10 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/validate-user-account")
|
||||
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
||||
@PostMapping("/validate-user-account/{userName}")
|
||||
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
|
||||
try {
|
||||
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
|
||||
User user = userService.validateUserAccount(userName);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
|
||||
HttpStatus.OK
|
||||
@@ -230,17 +232,11 @@ public class UserController {
|
||||
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
|
||||
public ResponseEntity<?> getAll() {
|
||||
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.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);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
@@ -258,20 +254,65 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-by-structure")
|
||||
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
if (userPrincipal.getUser().getStructure() != null) {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
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<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/page/all-by-structure/{structureId}")
|
||||
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
|
||||
@@ -6,9 +6,12 @@ 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;
|
||||
@@ -23,26 +26,33 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||
private final SecteurService secteurService;
|
||||
private final ParcelleRepository parcelleRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
|
||||
if (secteurDecoupage.getId() != null) {
|
||||
public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
|
||||
if (secteurDecoupagePaylaodWeb.getId() != 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
|
||||
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
|
||||
if (secteurDecoupage.getId() == null) {
|
||||
public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
|
||||
if (secteurDecoupagePaylaodWeb.getId() == 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é.");
|
||||
}
|
||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||
|
||||
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
||||
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,13 +66,28 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) {
|
||||
return secteurDecoupageRepository.findAll(pageable);
|
||||
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
|
||||
return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SecteurDecoupage> getSecteurDecoupageList() {
|
||||
return secteurDecoupageRepository.findAll();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ 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);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ public class UserServiceImpl implements UserService {
|
||||
user.setPassword(passwordEncoder.encode(userPaylaodWeb.getPassword()));
|
||||
userRepository.save(user);
|
||||
|
||||
|
||||
return userPaylaodWeb;
|
||||
return userRepository.findUserToDtoById(userPaylaodWeb.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -220,17 +219,14 @@ public class UserServiceImpl implements UserService {
|
||||
return optionalUserPaylaodWeb.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User assignStructureToUser(Structure structure) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User validateUserAccount(String username, UserRole userRole) {
|
||||
public User validateUserAccount(String username) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ 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;
|
||||
@@ -12,15 +14,20 @@ import java.util.Optional;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ 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);
|
||||
@@ -38,15 +39,16 @@ 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, UserRole userRole);
|
||||
User validateUserAccount(String username);
|
||||
|
||||
UserListByStructureResponse getListUserByStructure(Long structureId);
|
||||
|
||||
@@ -54,5 +56,11 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,148 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -62,6 +62,24 @@ 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,9 +1,6 @@
|
||||
package io.gmss.fiscad.service;
|
||||
|
||||
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.decoupage.*;
|
||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
||||
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.User;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.*;
|
||||
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.decoupage.*;
|
||||
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;
|
||||
@@ -60,6 +54,8 @@ public class EntityFromPayLoadService {
|
||||
private final UserRepository userRepository;
|
||||
private final ProfileRepository profileRepository;
|
||||
private final SectionRepository sectionRepository;
|
||||
private final ArrondissementRepository arrondissementRepository;
|
||||
private final QuartierRepository quartierRepository;
|
||||
|
||||
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
|
||||
CaracteristiqueParcelle caracteristiqueParcelle=new CaracteristiqueParcelle();
|
||||
@@ -270,6 +266,30 @@ 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.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();
|
||||
@@ -451,6 +471,8 @@ public class EntityFromPayLoadService {
|
||||
User user =new User();
|
||||
Optional<Structure> optionalStructure = Optional.empty();
|
||||
|
||||
System.out.println(userPaylaodWeb.getStructureId());
|
||||
|
||||
if(userPaylaodWeb.getStructureId()!=null)
|
||||
optionalStructure=structureRepository.findById(userPaylaodWeb.getStructureId());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user