Merge pull request 'reajustement secteur decoupage perimetre' (#258) from features/fiche_refonte into develop
Reviewed-on: #258
This commit was merged in pull request #258.
This commit is contained in:
@@ -41,9 +41,9 @@ public class FonctionController {
|
|||||||
@PreAuthorize("hasAuthority('CREATE_FONCTION')")
|
@PreAuthorize("hasAuthority('CREATE_FONCTION')")
|
||||||
public ResponseEntity<?> createFonction(@RequestBody @Valid @Validated FonctionPaylaodWeb fonctionPaylaodWeb) {
|
public ResponseEntity<?> createFonction(@RequestBody @Valid @Validated FonctionPaylaodWeb fonctionPaylaodWeb) {
|
||||||
try {
|
try {
|
||||||
Fonction fonction = fonctionService.createFonction(fonctionPaylaodWeb);
|
fonctionPaylaodWeb = fonctionService.createFonction(fonctionPaylaodWeb);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, fonction, "Secteur affecté avec succès."),
|
new ApiResponse<>(true, fonctionPaylaodWeb, "Secteur affecté avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -24,17 +24,19 @@ public class FonctionServiceImpl implements FonctionService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fonction createFonction(FonctionPaylaodWeb fonctionPaylaodWeb) throws BadRequestException {
|
public FonctionPaylaodWeb createFonction(FonctionPaylaodWeb fonctionPaylaodWeb) throws BadRequestException {
|
||||||
if (fonctionPaylaodWeb.getId() != null) {
|
if (fonctionPaylaodWeb.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer un nouveau fonction ayant un id non null.");
|
throw new BadRequestException("Impossible de créer un nouveau fonction ayant un id non null.");
|
||||||
}
|
}
|
||||||
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
||||||
|
fonction = fonctionRepository.save(fonction);
|
||||||
|
fonctionPaylaodWeb = fonctionRepository.findFonctionToDtoById(fonction.getId()).orElse(null);
|
||||||
|
|
||||||
return fonctionRepository.save(fonction);
|
return fonctionPaylaodWeb ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fonction updateFonction(Long id, FonctionPaylaodWeb fonctionPaylaodWeb) throws NotFoundException {
|
public FonctionPaylaodWeb updateFonction(Long id, FonctionPaylaodWeb fonctionPaylaodWeb) throws NotFoundException {
|
||||||
if (fonctionPaylaodWeb.getId() == null) {
|
if (fonctionPaylaodWeb.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de mettre à jour un nouveau fonction ayant un id null.");
|
throw new BadRequestException("Impossible de mettre à jour un nouveau fonction ayant un id null.");
|
||||||
}
|
}
|
||||||
@@ -42,8 +44,9 @@ public class FonctionServiceImpl implements FonctionService {
|
|||||||
throw new NotFoundException("Impossible de trouver le fonction spécifié dans notre base de données.");
|
throw new NotFoundException("Impossible de trouver le fonction spécifié dans notre base de données.");
|
||||||
}
|
}
|
||||||
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
Fonction fonction = entityFromPayLoadService.getFonctionFromPayLoadWeb(fonctionPaylaodWeb);
|
||||||
|
fonction = fonctionRepository.save(fonction);
|
||||||
return fonctionRepository.save(fonction);
|
fonctionPaylaodWeb = fonctionRepository.findFonctionToDtoById(fonction.getId()).orElse(null);
|
||||||
|
return fonctionPaylaodWeb ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public interface FonctionService {
|
public interface FonctionService {
|
||||||
|
|
||||||
Fonction createFonction(FonctionPaylaodWeb fonctionPaylaodWeb) throws BadRequestException;
|
FonctionPaylaodWeb createFonction(FonctionPaylaodWeb fonctionPaylaodWeb) throws BadRequestException;
|
||||||
|
|
||||||
Fonction updateFonction(Long id, FonctionPaylaodWeb fonctionPaylaodWeb) throws NotFoundException;
|
FonctionPaylaodWeb updateFonction(Long id, FonctionPaylaodWeb fonctionPaylaodWeb) throws NotFoundException;
|
||||||
|
|
||||||
void deleteFonction(Long id) throws NotFoundException;
|
void deleteFonction(Long id) throws NotFoundException;
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
public interface FonctionRepository extends JpaRepository<Fonction, Long> {
|
public interface FonctionRepository extends JpaRepository<Fonction, Long> {
|
||||||
@@ -40,6 +42,37 @@ public interface FonctionRepository extends JpaRepository<Fonction, Long> {
|
|||||||
""")
|
""")
|
||||||
List<FonctionPaylaodWeb> findAllFonctionToDto();
|
List<FonctionPaylaodWeb> findAllFonctionToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT new io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb(
|
||||||
|
f.id,
|
||||||
|
f.code,
|
||||||
|
f.nom,
|
||||||
|
sec.id,
|
||||||
|
sec.code,
|
||||||
|
sec.nom,
|
||||||
|
se.id,
|
||||||
|
se.nom,
|
||||||
|
se.code,
|
||||||
|
st.id,
|
||||||
|
st.code,
|
||||||
|
st.nom,
|
||||||
|
p.id,
|
||||||
|
p.nom,
|
||||||
|
d.id,
|
||||||
|
d.code,
|
||||||
|
d.nom
|
||||||
|
)
|
||||||
|
FROM Fonction f
|
||||||
|
LEFT JOIN f.secteur sec
|
||||||
|
LEFT JOIN f.section se
|
||||||
|
LEFT JOIN f.structure st
|
||||||
|
LEFT JOIN f.profile p
|
||||||
|
LEFT JOIN f.departement d
|
||||||
|
WHERE f.id = :idFonction
|
||||||
|
""")
|
||||||
|
Optional<FonctionPaylaodWeb> findFonctionToDtoById(@Param("idFonction") Long idFonction);
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
value = """
|
value = """
|
||||||
SELECT DISTINCT new io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb(
|
SELECT DISTINCT new io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb(
|
||||||
|
|||||||
Reference in New Issue
Block a user