reajustement secteur decoupage perimetre #276

Merged
judaur2005 merged 1 commits from features/fiche_refonte into develop 2026-07-28 16:10:49 +00:00
6 changed files with 60 additions and 2 deletions
Showing only changes of commit cb885cfd93 - Show all commits

View File

@@ -389,6 +389,33 @@ public class UserController {
}
@GetMapping("/all-by-fonction/{fonctionId}")
@PreAuthorize("hasAuthority('READ_USER')")
public ResponseEntity<?> getAllByFonction(@PathVariable Long fonctionId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getUsersByFonctionId(fonctionId), "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}")
@PreAuthorize("hasAuthority('READ_USER')")
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {

View File

@@ -378,6 +378,11 @@ public class UserServiceImpl implements UserService {
return !isTokenExpired(tokenDate);
}
@Override
public List<UserPaylaodWeb> getUsersByFonctionId(Long fonctionId) {
return userRepository.findAllUserByFonctionToDto(fonctionId);
}
/**
* Calcule la date d'expiration du token en ajoutant 24h à sa date de génération.
@@ -402,9 +407,7 @@ public class UserServiceImpl implements UserService {
if (dateToken == null) {
return true;
}
LocalDateTime dateExpiration = calculerDateExpiration(dateToken);
return LocalDateTime.now().isAfter(dateExpiration);
}

View File

@@ -66,4 +66,6 @@ public interface UserService {
Boolean validationTokenResetPassword(String token);
List<UserPaylaodWeb> getUsersByFonctionId(Long fonctionId);
}

View File

@@ -20,4 +20,5 @@ public class ProfilePaylaodWeb {
private UserProfile nom ;
private String description;
private Set<Role> roles;
}

View File

@@ -3,7 +3,9 @@ package io.gmss.fiscad.persistence.repositories.user;
import io.gmss.fiscad.entities.user.Role;
import io.gmss.fiscad.enums.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Optional;
public interface RoleRepository extends JpaRepository<Role, Long> {
@@ -14,4 +16,5 @@ public interface RoleRepository extends JpaRepository<Role, Long> {
boolean existsByNom(UserRole userRole);
Role getRolesByNom(UserRole userRole);
}

View File

@@ -159,4 +159,26 @@ public interface UserRepository extends JpaRepository<User, Long> {
WHERE st.id = :structureId
""")
Page<UserPaylaodWeb> findAllUserByStructureToDtoPageable(@Param("structureId") Long structureId, Pageable pageable);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb(
u.id,
u.nom,
u.prenom,
u.tel,
u.username,
u.email,
st.id,
st.code,
st.nom,
u.active,
u.resetPassword
)
FROM AvoirFonction af
JOIN af.user u
LEFT JOIN u.structure st
WHERE af.fonction.id = :fonctionId
""")
List<UserPaylaodWeb> findAllUserByFonctionToDto(@Param("fonctionId") Long fonctionId);
}