Merge pull request 'features/fiche_refonte' (#220) from features/fiche_refonte into develop
Reviewed-on: #220
This commit was merged in pull request #220.
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
package io.gmss.fiscad.controllers.frontend;
|
||||
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "api/fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Fonctionnalite")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class FonctionnaliteController {
|
||||
|
||||
private final FonctionnaliteService fonctionnaliteService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FonctionnaliteController.class);
|
||||
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
//@PreAuthorize("hasAuthority('CREATE_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> createFonctionnalite(@RequestBody @Valid @Validated FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
|
||||
try {
|
||||
fonctionnalitePayLoadWeb = fonctionnaliteService.createFonctionnalite(fonctionnalitePayLoadWeb);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, fonctionnalitePayLoadWeb, "Fonctionnalite créé 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
// @PreAuthorize("hasAuthority('UPDATE_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> updateFonctionnalite(@PathVariable Long id, @RequestBody FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, fonctionnaliteService.updateFonctionnalite(id,fonctionnalitePayLoadWeb), "Fonctionnalite mise à jour 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
//@PreAuthorize("hasAuthority('DELETE_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> deleteFonctionnalite(@PathVariable Long id) {
|
||||
try {
|
||||
fonctionnaliteService.deleteFonctionnalite(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, "Fonctionnalite supprimé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")
|
||||
// @PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> getAllFonctionnaliteList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteListToDto(), "Liste des caractéristiques 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-profil-id/{profilId}")
|
||||
//@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> getAllFonctionnaliteByProfilList(@PathVariable Long profilId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, fonctionnaliteService.getAllFonctionnaliteByProfilIdToDto(profilId), "Liste des fonctionnalites 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}")
|
||||
//@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
||||
public ResponseEntity<?> getFonctionnaliteById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteByIdToDto(id), "Fonctionnalite trouvé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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package io.gmss.fiscad.controllers.frontend;
|
||||
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.frontend.ModuleService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
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;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "api/module", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "Module")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ModuleController {
|
||||
|
||||
private final ModuleService moduleService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModuleController.class);
|
||||
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
// @PreAuthorize("hasAuthority('CREATE_MODULE')")
|
||||
public ResponseEntity<?> createModule(@RequestBody @Valid @Validated ModulePayloadWeb modulePayLoadWeb) {
|
||||
try {
|
||||
modulePayLoadWeb = moduleService.createModule(modulePayLoadWeb);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modulePayLoadWeb, "Module créé 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
//@PreAuthorize("hasAuthority('UPDATE_MODULE')")
|
||||
public ResponseEntity<?> updateModule(@PathVariable Long id, @RequestBody ModulePayloadWeb modulePayLoadWeb) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, moduleService.updateModule(id,modulePayLoadWeb), "Module mise à jour 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
// @PreAuthorize("hasAuthority('DELETE_MODULE')")
|
||||
public ResponseEntity<?> deleteModule(@PathVariable Long id) {
|
||||
try {
|
||||
moduleService.deleteModule(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, "Module supprimé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")
|
||||
//@PreAuthorize("hasAuthority('READ_MODULE')")
|
||||
public ResponseEntity<?> getAllModuleList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, moduleService.getModuleListToDto(), "Liste des caractéristiques 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-profil-id/{profilId}")
|
||||
//@PreAuthorize("hasAuthority('READ_MODULE')")
|
||||
public ResponseEntity<?> getAllModuleByProfilList(@PathVariable Long profilId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, moduleService.getAllModuleByProfilIdToDto(profilId), "Liste des modules 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}")
|
||||
//@PreAuthorize("hasAuthority('READ_MODULE')")
|
||||
public ResponseEntity<?> getModuleById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, moduleService.getModuleByIdToDto(id), "Module trouvé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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package io.gmss.fiscad.controllers.user;
|
||||
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
|
||||
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "api/profile-module-fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@SecurityRequirement(name = "bearer")
|
||||
@Tag(name = "ProfileModuleFonctionnalite")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ProfileModuleFonctionnaliteController {
|
||||
|
||||
private final ProfileModuleFonctionnaliteService profileModuleFonctionnaliteService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProfileModuleFonctionnaliteController.class);
|
||||
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
//@PreAuthorize("hasAuthority('CREATE_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> createProfileModuleFonctionnalite(@RequestBody @Valid @Validated ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
|
||||
try {
|
||||
modulePayLoadWeb = profileModuleFonctionnaliteService.createProfileModuleFonctionnalite(modulePayLoadWeb);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modulePayLoadWeb, "ProfileModuleFonctionnalite créé 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
//@PreAuthorize("hasAuthority('UPDATE_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> updateProfileModuleFonctionnalite(@PathVariable Long id, @RequestBody ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.updateProfileModuleFonctionnalite(id,modulePayLoadWeb), "ProfileModuleFonctionnalite mise à jour 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
// @PreAuthorize("hasAuthority('DELETE_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> deleteProfileModuleFonctionnalite(@PathVariable Long id) {
|
||||
try {
|
||||
profileModuleFonctionnaliteService.deleteProfileModuleFonctionnalite(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, "ProfileModuleFonctionnalite supprimé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")
|
||||
//@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> getAllProfileModuleFonctionnaliteList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteListToDto(), "Liste des caractéristiques 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-profil-id/{profilId}")
|
||||
// @PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> getAllProfileModuleFonctionnaliteByProfilList(@PathVariable Long profilId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getAllProfileModuleFonctionnaliteByProfilIdToDto(profilId), "Liste des modules 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}")
|
||||
//@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
||||
public ResponseEntity<?> getProfileModuleFonctionnaliteById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteByIdToDto(id), "ProfileModuleFonctionnalite trouvé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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.gmss.fiscad.entities.frontend;
|
||||
|
||||
import io.gmss.fiscad.entities.BaseEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Fonctionnalite extends BaseEntity implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private String lien;
|
||||
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
|
||||
private Boolean actif;
|
||||
@ManyToOne
|
||||
private ModuleApp moduleApp;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.gmss.fiscad.entities.frontend;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.gmss.fiscad.entities.BaseEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModuleApp extends BaseEntity implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private String lien;
|
||||
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
|
||||
private Boolean actif;
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "moduleApp")
|
||||
private List<Fonctionnalite> fonctionnalites;
|
||||
}
|
||||
29
src/main/java/io/gmss/fiscad/entities/user/ProfileModuleFonctionnalite.java
Executable file
29
src/main/java/io/gmss/fiscad/entities/user/ProfileModuleFonctionnalite.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package io.gmss.fiscad.entities.user;
|
||||
|
||||
import io.gmss.fiscad.entities.BaseEntity;
|
||||
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
|
||||
import io.gmss.fiscad.entities.frontend.ModuleApp;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
public class ProfileModuleFonctionnalite extends BaseEntity implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@ManyToOne
|
||||
private Profile profile;
|
||||
@ManyToOne
|
||||
private ModuleApp moduleApp;
|
||||
@ManyToOne
|
||||
private Fonctionnalite fonctionnalite ;
|
||||
private Boolean actif;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package io.gmss.fiscad.implementations.frontend;
|
||||
|
||||
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.frontend.FonctionnaliteRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class FonctionnaliteServiceImpl implements FonctionnaliteService {
|
||||
private final FonctionnaliteRepository fonctionnaliteRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
@Override
|
||||
public FonctionnalitePayloadWeb createFonctionnalite(FonctionnalitePayloadWeb fonctionnalitePayloadWeb) throws BadRequestException {
|
||||
if (fonctionnalitePayloadWeb.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
|
||||
}
|
||||
|
||||
Fonctionnalite fonctionnalite= entityFromPayLoadService.getFonctionnaliteFromPayloadWeb(fonctionnalitePayloadWeb);
|
||||
fonctionnalite = fonctionnaliteRepository.save(fonctionnalite);
|
||||
return fonctionnaliteRepository.findPayloadById(fonctionnalite.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FonctionnalitePayloadWeb updateFonctionnalite(Long id, FonctionnalitePayloadWeb fonctionnalitePayloadWeb) throws NotFoundException {
|
||||
if (fonctionnalitePayloadWeb.getId() == null) {
|
||||
throw new BadRequestException("La fonctionnaliteApp n'existe pas.");
|
||||
}
|
||||
|
||||
if (!fonctionnaliteRepository.existsById(fonctionnalitePayloadWeb.getId())) {
|
||||
throw new NotFoundException("La fonctionnaliteApp n'existe pas");
|
||||
}
|
||||
|
||||
Fonctionnalite fonctionnaliteApp = entityFromPayLoadService.getFonctionnaliteFromPayloadWeb(fonctionnalitePayloadWeb);
|
||||
fonctionnaliteApp =fonctionnaliteRepository.save(fonctionnaliteApp);
|
||||
return fonctionnaliteRepository.findPayloadById(fonctionnaliteApp.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFonctionnalite(Long id) throws NotFoundException {
|
||||
Optional<Fonctionnalite> fonctionnaliteOptional = fonctionnaliteRepository.findById(id);
|
||||
if (fonctionnaliteOptional.isPresent()) {
|
||||
fonctionnaliteRepository.deleteById(fonctionnaliteOptional.get().getId());
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la fonctionnalite à supprimer .");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<FonctionnalitePayloadWeb> getFonctionnaliteListToDto() {
|
||||
return fonctionnaliteRepository.findAllPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<FonctionnalitePayloadWeb> getFonctionnaliteByIdToDto(Long id) {
|
||||
return fonctionnaliteRepository.findPayloadById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FonctionnalitePayloadWeb> getAllFonctionnaliteByProfilIdToDto(Long id) {
|
||||
return fonctionnaliteRepository.findByProfileId(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package io.gmss.fiscad.implementations.frontend;
|
||||
|
||||
import io.gmss.fiscad.entities.frontend.ModuleApp;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.frontend.ModuleService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.frontend.ModuleRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class ModuleServiceImpl implements ModuleService {
|
||||
private final ModuleRepository moduleRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
@Override
|
||||
public ModulePayloadWeb createModule(ModulePayloadWeb modulePayloadWeb) throws BadRequestException {
|
||||
if (modulePayloadWeb.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
|
||||
}
|
||||
|
||||
ModuleApp module= entityFromPayLoadService.getModuleFromPayloadWeb(modulePayloadWeb);
|
||||
module = moduleRepository.save(module);
|
||||
return moduleRepository.findPayloadById(module.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModulePayloadWeb updateModule(Long id, ModulePayloadWeb modulePayloadWeb) throws NotFoundException {
|
||||
if (modulePayloadWeb.getId() == null) {
|
||||
throw new BadRequestException("La moduleApp n'existe pas.");
|
||||
}
|
||||
|
||||
if (!moduleRepository.existsById(modulePayloadWeb.getId())) {
|
||||
throw new NotFoundException("La moduleApp n'existe pas");
|
||||
}
|
||||
|
||||
ModuleApp moduleApp = entityFromPayLoadService.getModuleFromPayloadWeb(modulePayloadWeb);
|
||||
moduleApp =moduleRepository.save(moduleApp);
|
||||
return moduleRepository.findPayloadById(moduleApp.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteModule(Long id) throws NotFoundException {
|
||||
Optional<ModuleApp> moduleOptional = moduleRepository.findById(id);
|
||||
if (moduleOptional.isPresent()) {
|
||||
moduleRepository.deleteById(moduleOptional.get().getId());
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la module à supprimer .");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ModulePayloadWeb> getModuleListToDto() {
|
||||
return moduleRepository.findAllPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModulePayloadWeb> getModuleByIdToDto(Long id) {
|
||||
return moduleRepository.findPayloadById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModulePayloadWeb> getAllModuleByProfilIdToDto(Long id) {
|
||||
return moduleRepository.findPayloadByProfilId(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package io.gmss.fiscad.implementations.user;
|
||||
|
||||
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
|
||||
import io.gmss.fiscad.entities.user.ProfileModuleFonctionnalite;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
|
||||
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.frontend.FonctionnaliteRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.user.ProfileModuleFonctionnaliteRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class ProfileModuleFonctionnaliteServiceImpl implements ProfileModuleFonctionnaliteService {
|
||||
private final ProfileModuleFonctionnaliteRepository profileModuleFonctionnaliteRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
@Override
|
||||
public ProfileModuleFonctionnalitePayloadWeb createProfileModuleFonctionnalite(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws BadRequestException {
|
||||
if (profileModuleFonctionnalitePayloadWeb.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle déclaration NC ayant un id non null.");
|
||||
}
|
||||
|
||||
ProfileModuleFonctionnalite profileModuleFonctionnalite= entityFromPayLoadService.getProfileModuleFonctionnaliteFromPayloadWeb(profileModuleFonctionnalitePayloadWeb);
|
||||
profileModuleFonctionnalite = profileModuleFonctionnaliteRepository.save(profileModuleFonctionnalite);
|
||||
return profileModuleFonctionnaliteRepository.findPayloadById(profileModuleFonctionnalite.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileModuleFonctionnalitePayloadWeb updateProfileModuleFonctionnalite(Long id, ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws NotFoundException {
|
||||
if (profileModuleFonctionnalitePayloadWeb.getId() == null) {
|
||||
throw new BadRequestException("La fonctionnaliteApp n'existe pas.");
|
||||
}
|
||||
|
||||
if (!profileModuleFonctionnaliteRepository.existsById(profileModuleFonctionnalitePayloadWeb.getId())) {
|
||||
throw new NotFoundException("La fonctionnaliteApp n'existe pas");
|
||||
}
|
||||
|
||||
ProfileModuleFonctionnalite profileModuleFonctionnalite = entityFromPayLoadService.getProfileModuleFonctionnaliteFromPayloadWeb(profileModuleFonctionnalitePayloadWeb);
|
||||
profileModuleFonctionnalite =profileModuleFonctionnaliteRepository.save(profileModuleFonctionnalite);
|
||||
return profileModuleFonctionnaliteRepository.findPayloadById(profileModuleFonctionnalite.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProfileModuleFonctionnalite(Long id) throws NotFoundException {
|
||||
Optional<ProfileModuleFonctionnalite> profileModuleFonctionnaliteOptional = profileModuleFonctionnaliteRepository.findById(id);
|
||||
if (profileModuleFonctionnaliteOptional.isPresent()) {
|
||||
profileModuleFonctionnaliteRepository.deleteById(profileModuleFonctionnaliteOptional.get().getId());
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la fonctionnalite à supprimer .");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDto() {
|
||||
return profileModuleFonctionnaliteRepository.findAllPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteByIdToDto(Long id) {
|
||||
return profileModuleFonctionnaliteRepository.findPayloadById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByProfilIdToDto(Long id) {
|
||||
return profileModuleFonctionnaliteRepository.findByProfileId(id);
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/io/gmss/fiscad/interfaces/frontend/FonctionnaliteService.java
Executable file
32
src/main/java/io/gmss/fiscad/interfaces/frontend/FonctionnaliteService.java
Executable file
@@ -0,0 +1,32 @@
|
||||
package io.gmss.fiscad.interfaces.frontend;
|
||||
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface FonctionnaliteService {
|
||||
|
||||
FonctionnalitePayloadWeb createFonctionnalite(FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) throws BadRequestException;
|
||||
|
||||
FonctionnalitePayloadWeb updateFonctionnalite(Long id, FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) throws NotFoundException;
|
||||
|
||||
void deleteFonctionnalite(Long id) throws NotFoundException;
|
||||
|
||||
//Page<FonctionnalitePayloadWeb> getFonctionnaliteListToDtoPageable(Pageable pageable);
|
||||
|
||||
List<FonctionnalitePayloadWeb> getFonctionnaliteListToDto();
|
||||
|
||||
Optional<FonctionnalitePayloadWeb> getFonctionnaliteByIdToDto(Long id);
|
||||
|
||||
//List<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteToDto(Long id);
|
||||
//Page<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteToDtoPageable(Long id,Pageable pageable);
|
||||
|
||||
//List<FonctionnalitePayloadWeb> getAllFonctionnaliteByEnqueteBatimentToDto(Long id);
|
||||
|
||||
List<FonctionnalitePayloadWeb> getAllFonctionnaliteByProfilIdToDto(Long id);
|
||||
}
|
||||
30
src/main/java/io/gmss/fiscad/interfaces/frontend/ModuleService.java
Executable file
30
src/main/java/io/gmss/fiscad/interfaces/frontend/ModuleService.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package io.gmss.fiscad.interfaces.frontend;
|
||||
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ModuleService {
|
||||
|
||||
ModulePayloadWeb createModule(ModulePayloadWeb modulePayLoadWeb) throws BadRequestException;
|
||||
|
||||
ModulePayloadWeb updateModule(Long id, ModulePayloadWeb modulePayLoadWeb) throws NotFoundException;
|
||||
|
||||
void deleteModule(Long id) throws NotFoundException;
|
||||
|
||||
//Page<ModulePayloadWeb> getModuleListToDtoPageable(Pageable pageable);
|
||||
|
||||
List<ModulePayloadWeb> getModuleListToDto();
|
||||
|
||||
Optional<ModulePayloadWeb> getModuleByIdToDto(Long id);
|
||||
|
||||
|
||||
List<ModulePayloadWeb> getAllModuleByProfilIdToDto(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.gmss.fiscad.interfaces.user;
|
||||
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ProfileModuleFonctionnaliteService {
|
||||
|
||||
ProfileModuleFonctionnalitePayloadWeb createProfileModuleFonctionnalite(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws BadRequestException;
|
||||
|
||||
ProfileModuleFonctionnalitePayloadWeb updateProfileModuleFonctionnalite(Long id, ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) throws NotFoundException;
|
||||
|
||||
void deleteProfileModuleFonctionnalite(Long id) throws NotFoundException;
|
||||
|
||||
//Page<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDtoPageable(Pageable pageable);
|
||||
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteListToDto();
|
||||
|
||||
Optional<ProfileModuleFonctionnalitePayloadWeb> getProfileModuleFonctionnaliteByIdToDto(Long id);
|
||||
|
||||
//List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteToDto(Long id);
|
||||
//Page<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteToDtoPageable(Long id,Pageable pageable);
|
||||
|
||||
//List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByEnqueteBatimentToDto(Long id);
|
||||
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> getAllProfileModuleFonctionnaliteByProfilIdToDto(Long id);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FonctionnalitePayloadWeb {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private Long moduleId;
|
||||
private String moduleCode;
|
||||
private String moduleNom;
|
||||
private Boolean actif;
|
||||
private String lien;
|
||||
|
||||
public FonctionnalitePayloadWeb(Long id, String code, String nom, Long moduleId, String moduleCode, String moduleNom, Boolean actif, String lien) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.nom = nom;
|
||||
this.moduleId = moduleId;
|
||||
this.moduleCode = moduleCode;
|
||||
this.moduleNom = moduleNom;
|
||||
this.actif = actif;
|
||||
this.lien = lien;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ModulePayloadWeb {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private Boolean actif;
|
||||
private String lien;
|
||||
|
||||
public ModulePayloadWeb(Long id, String code, String nom, Boolean actif, String lien) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.nom = nom;
|
||||
this.actif = actif;
|
||||
this.lien = lien;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||
|
||||
import io.gmss.fiscad.enums.ProfileApp;
|
||||
import io.gmss.fiscad.enums.UserProfile;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ProfileModuleFonctionnalitePayloadWeb {
|
||||
private Long id;
|
||||
private Long profileId;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private UserProfile profileNom;
|
||||
private String profileDescription;
|
||||
private Long moduleId;
|
||||
private String moduleCode;
|
||||
private String moduleNom;
|
||||
private Long fonctionnaliteId;
|
||||
private String fonctionnaliteCode;
|
||||
private String fonctionnaliteNom;
|
||||
private Boolean actif;
|
||||
|
||||
public ProfileModuleFonctionnalitePayloadWeb(Long id, Long profileId, UserProfile profileNom, String profileDescription, Long moduleId, String moduleCode, String moduleNom, Long fonctionnaliteId, String fonctionnaliteCode, String fonctionnaliteNom, Boolean actif) {
|
||||
this.id = id;
|
||||
this.profileId = profileId;
|
||||
this.profileNom = profileNom;
|
||||
this.profileDescription = profileDescription;
|
||||
this.moduleId = moduleId;
|
||||
this.moduleCode = moduleCode;
|
||||
this.moduleNom = moduleNom;
|
||||
this.fonctionnaliteId = fonctionnaliteId;
|
||||
this.fonctionnaliteCode = fonctionnaliteCode;
|
||||
this.fonctionnaliteNom = fonctionnaliteNom;
|
||||
this.actif = actif;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package io.gmss.fiscad.persistence.repositories.frontend;
|
||||
|
||||
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
|
||||
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
|
||||
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.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface FonctionnaliteRepository extends JpaRepository<Fonctionnalite, Long> {
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join f.moduleApp m
|
||||
where f.id = :id
|
||||
""")
|
||||
Optional<FonctionnalitePayloadWeb> findPayloadById(@Param("id") Long id);
|
||||
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join f.moduleApp m
|
||||
""")
|
||||
List<FonctionnalitePayloadWeb> findAllPayload();
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join f.moduleApp m
|
||||
where m.id = :moduleId
|
||||
""")
|
||||
List<FonctionnalitePayloadWeb> findByModuleId(
|
||||
@Param("moduleId") Long moduleId);
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join f.moduleApp m
|
||||
where m.id = :moduleId
|
||||
and f.actif = :actif
|
||||
""")
|
||||
List<FonctionnalitePayloadWeb> findByModuleIdAndActif(
|
||||
@Param("moduleId") Long moduleId,
|
||||
@Param("actif") Boolean actif);
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join f.moduleApp m
|
||||
where f.code = :code
|
||||
""")
|
||||
Optional<FonctionnalitePayloadWeb> findByCode(
|
||||
@Param("code") String code);
|
||||
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb(
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.moduleApp.id,
|
||||
pmf.moduleApp.code,
|
||||
pmf.moduleApp.nom,
|
||||
f.actif,
|
||||
f.lien
|
||||
)
|
||||
from Fonctionnalite f
|
||||
join ProfileModuleFonctionnalite pmf on pmf.fonctionnalite=f
|
||||
where pmf.profile.id = :profilId
|
||||
""")
|
||||
List<FonctionnalitePayloadWeb> findByProfileId(
|
||||
@Param("profilId") Long moduleId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package io.gmss.fiscad.persistence.repositories.frontend;
|
||||
|
||||
import io.gmss.fiscad.entities.frontend.ModuleApp;
|
||||
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
|
||||
import io.gmss.fiscad.paylaods.response.restoration.PiecePayLoadRestor;
|
||||
import jakarta.transaction.Transactional;
|
||||
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.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ModuleRepository extends JpaRepository<ModuleApp, Long> {
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
m.actif,
|
||||
m.lien
|
||||
)
|
||||
from ModuleApp m
|
||||
where m.id = :id
|
||||
""")
|
||||
Optional<ModulePayloadWeb> findPayloadById(@Param("id") Long id);
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
m.actif,
|
||||
m.lien
|
||||
)
|
||||
from ModuleApp m
|
||||
""")
|
||||
List<ModulePayloadWeb> findAllPayload();
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
m.actif,
|
||||
m.lien
|
||||
)
|
||||
from ModuleApp m
|
||||
where m.actif = :actif
|
||||
""")
|
||||
List<ModulePayloadWeb> findByActif(@Param("actif") Boolean actif);
|
||||
|
||||
|
||||
@Query("""
|
||||
select distinct new io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb(
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
m.actif,
|
||||
m.lien
|
||||
)
|
||||
from ModuleApp m
|
||||
join ProfileModuleFonctionnalite pf on pf.moduleApp=m
|
||||
where pf.profile.id = :Profilid
|
||||
""")
|
||||
List<ModulePayloadWeb> findPayloadByProfilId(@Param("Profilid") Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package io.gmss.fiscad.persistence.repositories.user;
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.metier.Piece;
|
||||
import io.gmss.fiscad.entities.user.ProfileModuleFonctionnalite;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
|
||||
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.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ProfileModuleFonctionnaliteRepository extends JpaRepository<ProfileModuleFonctionnalite, Long> {
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
where pmf.id = :id
|
||||
""")
|
||||
Optional<ProfileModuleFonctionnalitePayloadWeb> findPayloadById(
|
||||
@Param("id") Long id);
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
order by p.nom, m.nom, f.nom
|
||||
""")
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> findAllPayload();
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
""")
|
||||
Page<ProfileModuleFonctionnalitePayloadWeb> findAllPayload(
|
||||
Pageable pageable);
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
where p.id = :profileId
|
||||
order by m.nom, f.nom
|
||||
""")
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> findByProfileId(
|
||||
@Param("profileId") Long profileId);
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
where m.id = :moduleId
|
||||
order by p.nom, f.nom
|
||||
""")
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> findByModuleId(
|
||||
@Param("moduleId") Long moduleId);
|
||||
|
||||
|
||||
@Query("""
|
||||
select new io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb(
|
||||
pmf.id,
|
||||
p.id,
|
||||
p.nom,
|
||||
p.description,
|
||||
m.id,
|
||||
m.code,
|
||||
m.nom,
|
||||
f.id,
|
||||
f.code,
|
||||
f.nom,
|
||||
pmf.actif
|
||||
)
|
||||
from ProfileModuleFonctionnalite pmf
|
||||
join pmf.profile p
|
||||
join pmf.moduleApp m
|
||||
join pmf.fonctionnalite f
|
||||
where p.id = :profileId
|
||||
and pmf.actif = :actif
|
||||
order by m.nom, f.nom
|
||||
""")
|
||||
List<ProfileModuleFonctionnalitePayloadWeb> findByProfileIdAndActif(
|
||||
@Param("profileId") Long profileId,
|
||||
@Param("actif") Boolean actif);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,19 +2,20 @@ package io.gmss.fiscad.service;
|
||||
|
||||
import io.gmss.fiscad.controllers.rfu.metier.ImpositionsTfuController;
|
||||
import io.gmss.fiscad.entities.decoupage.*;
|
||||
import io.gmss.fiscad.entities.frontend.Fonctionnalite;
|
||||
import io.gmss.fiscad.entities.frontend.ModuleApp;
|
||||
import io.gmss.fiscad.entities.infocad.metier.*;
|
||||
import io.gmss.fiscad.entities.infocad.parametre.*;
|
||||
import io.gmss.fiscad.entities.rfu.metier.*;
|
||||
import io.gmss.fiscad.entities.rfu.parametre.*;
|
||||
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.entities.user.*;
|
||||
import io.gmss.fiscad.enums.StatutEnquete;
|
||||
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.frontend.FonctionnaliteRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.frontend.ModuleRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.*;
|
||||
import io.gmss.fiscad.persistence.repositories.infocad.parametre.*;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.*;
|
||||
@@ -23,6 +24,7 @@ import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CaracteristiqueRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.user.ProfileModuleFonctionnaliteRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.user.ProfileRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -75,6 +77,9 @@ public class EntityFromPayLoadService {
|
||||
private final NatureDomaineRepository natureDomaineRepository ;
|
||||
private final TypeDomaineRepository typeDomaineRepository ;
|
||||
private final CommuneCentreAssignationRepository communeCentreAssignationRepository ;
|
||||
private final ModuleRepository moduleRepository ;
|
||||
private final FonctionnaliteRepository fonctionnaliteRepository ;
|
||||
private final ProfileModuleFonctionnaliteRepository profileModuleFonctionnaliteRepository ;
|
||||
|
||||
|
||||
public CaracteristiqueParcelle getCaracteristiqueParcelleFromPayLoadWeb(CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb){
|
||||
@@ -1037,4 +1042,59 @@ public class EntityFromPayLoadService {
|
||||
|
||||
return communeCentreAssignation;
|
||||
}
|
||||
|
||||
public ModuleApp getModuleFromPayloadWeb(ModulePayloadWeb modulePayloadWeb) {
|
||||
ModuleApp moduleApp =new ModuleApp();
|
||||
if(modulePayloadWeb.getId()!=null)
|
||||
moduleApp = moduleRepository.findById(modulePayloadWeb.getId()).orElse(new ModuleApp());
|
||||
moduleApp.setId(modulePayloadWeb.getId());
|
||||
moduleApp.setCode(modulePayloadWeb.getCode());
|
||||
moduleApp.setNom(modulePayloadWeb.getNom());
|
||||
moduleApp.setActif(true);
|
||||
return moduleApp ;
|
||||
}
|
||||
|
||||
public Fonctionnalite getFonctionnaliteFromPayloadWeb(FonctionnalitePayloadWeb fonctionnalitePayloadWeb) {
|
||||
Fonctionnalite fonctionnalite =new Fonctionnalite();
|
||||
if(fonctionnalitePayloadWeb.getId()!=null)
|
||||
fonctionnalite = fonctionnaliteRepository.findById(fonctionnalitePayloadWeb.getId()).orElse(new Fonctionnalite());
|
||||
|
||||
if (fonctionnalitePayloadWeb.getModuleId() != null) {
|
||||
ModuleApp moduleApp = new ModuleApp();
|
||||
moduleApp.setId(fonctionnalitePayloadWeb.getModuleId());
|
||||
fonctionnalite.setModuleApp(moduleApp);
|
||||
}
|
||||
|
||||
fonctionnalite.setId(fonctionnalitePayloadWeb.getId());
|
||||
fonctionnalite.setCode(fonctionnalitePayloadWeb.getCode());
|
||||
fonctionnalite.setNom(fonctionnalitePayloadWeb.getNom());
|
||||
fonctionnalite.setActif(true);
|
||||
return fonctionnalite ;
|
||||
}
|
||||
|
||||
public ProfileModuleFonctionnalite getProfileModuleFonctionnaliteFromPayloadWeb(ProfileModuleFonctionnalitePayloadWeb profileModuleFonctionnalitePayloadWeb) {
|
||||
ProfileModuleFonctionnalite profileModuleFonctionnalite =new ProfileModuleFonctionnalite();
|
||||
if(profileModuleFonctionnalitePayloadWeb.getId()!=null)
|
||||
profileModuleFonctionnalite = profileModuleFonctionnaliteRepository.findById(profileModuleFonctionnalitePayloadWeb.getId()).orElse(new ProfileModuleFonctionnalite());
|
||||
|
||||
if (profileModuleFonctionnalitePayloadWeb.getModuleId() != null) {
|
||||
ModuleApp moduleApp = new ModuleApp();
|
||||
moduleApp.setId(profileModuleFonctionnalitePayloadWeb.getModuleId());
|
||||
profileModuleFonctionnalite.setModuleApp(moduleApp);
|
||||
}
|
||||
|
||||
if (profileModuleFonctionnalitePayloadWeb.getProfileId() != null) {
|
||||
Profile profile = new Profile();
|
||||
profile.setId(profileModuleFonctionnalitePayloadWeb.getProfileId());
|
||||
profileModuleFonctionnalite.setProfile(profile);
|
||||
}
|
||||
|
||||
if (profileModuleFonctionnalitePayloadWeb.getFonctionnaliteId() != null) {
|
||||
Fonctionnalite fonctionnalite = new Fonctionnalite();
|
||||
fonctionnalite.setId(profileModuleFonctionnalitePayloadWeb.getFonctionnaliteId());
|
||||
profileModuleFonctionnalite.setFonctionnalite(fonctionnalite);
|
||||
}
|
||||
profileModuleFonctionnalite.setActif(true);
|
||||
return profileModuleFonctionnalite ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user