first commit
This commit is contained in:
0
src/Controller/.gitignore
vendored
Normal file
0
src/Controller/.gitignore
vendored
Normal file
96
src/Controller/DemandeLogementController.php
Normal file
96
src/Controller/DemandeLogementController.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Dto\DemandeLogementRequestVO;
|
||||
use App\Dto\ErreurReponseVO;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class DemandeLogementController
|
||||
{
|
||||
#[Route('/api/v1/etudiants/{typeid}/{id}/demande-logement', methods: ['POST'])]
|
||||
#[OA\Tag(name: 'Service de demande de logement d\'un étudiant')]
|
||||
#[OA\Post(
|
||||
path: '/api/v1/etudiants/{typeid}/{id}/demande-logement',
|
||||
summary: 'Synchroniser la demande de logement d\'un étudiant',
|
||||
operationId: 'synchroniserDemandeLogement'
|
||||
)]
|
||||
#[OA\Parameter(
|
||||
name: 'typeid',
|
||||
in: 'path',
|
||||
description: 'Type de l\'identifiant de l\'étudiant',
|
||||
required: true,
|
||||
schema: new OA\Schema(type: 'string', enum: ['ine', 'id-pve'])
|
||||
)]
|
||||
#[OA\Parameter(
|
||||
name: 'id',
|
||||
in: 'path',
|
||||
description: 'Id INE / Id PVE',
|
||||
required: true,
|
||||
schema: new OA\Schema(type: 'string')
|
||||
)]
|
||||
#[OA\RequestBody(
|
||||
description: 'Corps de la requête pour la synchronisation de la demande de logement',
|
||||
required: true,
|
||||
content: new OA\MediaType(
|
||||
mediaType: 'application/json',
|
||||
schema: new OA\Schema(ref: new Model(type: DemandeLogementRequestVO::class))
|
||||
)
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 201,
|
||||
description: 'La demande de modification a été prise en compte',
|
||||
content: new OA\JsonContent(type: 'object')
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 400,
|
||||
description: 'La demande ne respecte pas le format attendu',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 401,
|
||||
description: 'Authentification échouée',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 403,
|
||||
description: 'Accès refusé/Interdit - L\'utilisateur n\'a pas les droits nécessaires pour accéder à cette ressource',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 404,
|
||||
description: 'Étudiant ou dossier inconnu du système. La demande ne peut pas être prise en compte',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 429,
|
||||
description: 'La limite du nombre de requêtes/seconde a été dépassée',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 500,
|
||||
description: 'Une erreur interne côté serveur s\'est produite lors du traitement',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
public function demandeLogement($typeid,$id,Request $request): JsonResponse
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
if (!$data) {
|
||||
return new JsonResponse(['error' => 'Invalid request'], 400);
|
||||
}
|
||||
|
||||
if ($typid="id-vpe" && $id % 2 == 0) {
|
||||
$error=new ErreurReponseVO;
|
||||
$error->setStatus(400);
|
||||
$error->setError('IdPVE paire Mock force KO');
|
||||
$error->setPath($request->getUri());
|
||||
return new JsonResponse($error);
|
||||
}
|
||||
|
||||
return new JsonResponse(['status' => 'OK', 'message' => 'IdPVE impaire Mock force OK'], 201);
|
||||
}
|
||||
}
|
85
src/Controller/ProfilEtudiantController.php
Normal file
85
src/Controller/ProfilEtudiantController.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Dto\DemandeLogementRequestVO;
|
||||
use App\Dto\ErreurReponseVO;
|
||||
use App\Dto\ProfilEtudiantRequestVO;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class ProfilEtudiantController
|
||||
{
|
||||
#[Route('/api/v1/notifications/mse/profil-etudiant', name: 'notifier_modification_profil_etudiant', methods: ['POST'])]
|
||||
#[OA\Tag(name: 'Service de notifications')]
|
||||
#[OA\Post(
|
||||
path: '/api/v1/notifications/mse/profil-etudiant',
|
||||
summary: 'Notifier la modification des données de profil d\'un étudiant',
|
||||
operationId: 'notifierModificationProfilEtudiant'
|
||||
)]
|
||||
#[OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\MediaType(
|
||||
mediaType: 'application/json',
|
||||
schema: new OA\Schema(ref: new Model(type: ProfilEtudiantRequestVO::class))
|
||||
)
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 201,
|
||||
description: 'La demande de modification sera traité dans les meilleurs délai',
|
||||
content: new OA\JsonContent(type: 'object')
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 400,
|
||||
description: 'La demande ne respecte pas le format attendu',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 401,
|
||||
description: 'Authentification échouée',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 403,
|
||||
description: 'Accès refusé/Interdit - L\'utilisateur n\'a pas les droits nécessaires pour accéder à cette ressource',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 404,
|
||||
description: 'Étudiant ou dossier inconnu du système. La demande ne peut pas être prise en compte',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 429,
|
||||
description: 'La limite du nombre de requêtes/seconde a été dépassée',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
#[OA\Response(
|
||||
response: 500,
|
||||
description: 'Une erreur interne côté serveur s\'est produite lors du traitement',
|
||||
content: new OA\JsonContent(ref: new Model(type: ErreurReponseVO::class))
|
||||
)]
|
||||
public function profilEtudiant(Request $request): JsonResponse
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!$data || !isset($data['ine'], $data['idPVE'], $data['dateEvenement'])) {
|
||||
return new JsonResponse(['error' => 'Invalid request'], 400);
|
||||
}
|
||||
|
||||
if (!is_numeric($data['idPVE']) || intval($data['idPVE']) != $data['idPVE']) {
|
||||
return new JsonResponse(['error' => 'idPVE doit être un entier'], 400);
|
||||
}
|
||||
|
||||
if ($data['idPVE'] % 2 == 0) {
|
||||
return new JsonResponse(['status' => 'KO', 'message' => 'IdPVE paire Mock force KO'], 404);
|
||||
}
|
||||
|
||||
return new JsonResponse(['status' => 'OK', 'message' => 'IdPVE impaire Mock force OK'], 201);
|
||||
}
|
||||
|
||||
|
||||
}
|
28
src/Dto/DemandeLogementRequestVO.php
Normal file
28
src/Dto/DemandeLogementRequestVO.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace App\Dto;
|
||||
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: "DemandeLogementRequestVO",
|
||||
description: "Représente la demande de logement d'un étudiant",
|
||||
type: "object",
|
||||
required: ["anneeGestion", "demande"]
|
||||
)]
|
||||
class DemandeLogementRequestVO
|
||||
{
|
||||
#[OA\Property(
|
||||
description: "Année de gestion au format 'AAAA'",
|
||||
type: "string",
|
||||
example: "2023"
|
||||
)]
|
||||
public string $anneeGestion;
|
||||
|
||||
#[OA\Property(
|
||||
description: "État de la demande de logement",
|
||||
type: "string",
|
||||
enum: ["V", "N", "O", "A"],
|
||||
example: "V"
|
||||
)]
|
||||
public string $demande;
|
||||
}
|
95
src/Dto/ErreurReponseVO.php
Normal file
95
src/Dto/ErreurReponseVO.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace App\Dto;
|
||||
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: "ErreurReponseVO",
|
||||
description: "Réponse en cas d'erreur",
|
||||
type: "object"
|
||||
)]
|
||||
class ErreurReponseVO
|
||||
{
|
||||
#[OA\Property(
|
||||
description: "Date/Heure de l'erreur au format ISO",
|
||||
type: "string",
|
||||
format: "date-time",
|
||||
example: "2025-01-01T10:00:00Z"
|
||||
)]
|
||||
public string $timestamp;
|
||||
|
||||
#[OA\Property(
|
||||
description: "Statut HTTP",
|
||||
type: "integer",
|
||||
example: 400
|
||||
)]
|
||||
public int $status;
|
||||
|
||||
#[OA\Property(
|
||||
description: "Reason Phrase de l'erreur HTTP renvoyée dans status",
|
||||
type: "string",
|
||||
example: "Bad Request"
|
||||
)]
|
||||
public string $error;
|
||||
|
||||
#[OA\Property(
|
||||
description: "Liste des messages d'erreur",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: MessageVO::class))
|
||||
)]
|
||||
public array $message;
|
||||
|
||||
#[OA\Property(
|
||||
description: "Chemin de l'API",
|
||||
type: "string",
|
||||
example: "/api/v1/etudiants/ine/123/demande-logement"
|
||||
)]
|
||||
public string $path;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->timestamp = (new \DateTime())->format(\DateTimeInterface::ATOM);
|
||||
}
|
||||
|
||||
// Getter methods for each property
|
||||
public function getTimestamp(): string
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
public function setStatus(int $status): self
|
||||
{
|
||||
$this->status=$status;
|
||||
return $this;
|
||||
}
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setError(string $error): self
|
||||
{
|
||||
$this->error=$error;
|
||||
return $this;
|
||||
}
|
||||
public function getError(): array
|
||||
{
|
||||
return [$this->message];
|
||||
}
|
||||
|
||||
public function getMessage(): array
|
||||
{
|
||||
return[$this->error];
|
||||
}
|
||||
|
||||
public function setPath(string $path): self
|
||||
{
|
||||
$this->path=$path;
|
||||
return $this;
|
||||
}
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
26
src/Dto/MessageVO.php
Normal file
26
src/Dto/MessageVO.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace App\Dto;
|
||||
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: "MessageVO",
|
||||
description: "Message d'erreur",
|
||||
type: "object"
|
||||
)]
|
||||
class MessageVO
|
||||
{
|
||||
#[OA\Property(
|
||||
description: "Code de l'erreur ou champ en erreur",
|
||||
type: "string",
|
||||
example: "ERR001"
|
||||
)]
|
||||
public string $code;
|
||||
|
||||
#[OA\Property(
|
||||
description: "Libellé de l'erreur",
|
||||
type: "string",
|
||||
example: "Invalid parameter"
|
||||
)]
|
||||
public string $libelle;
|
||||
}
|
34
src/Dto/ProfilEtudiantRequestVO.php
Normal file
34
src/Dto/ProfilEtudiantRequestVO.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Dto;
|
||||
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: "ProfilEtudiantRequestVO",
|
||||
description: "Représente la demande de modification d'un etudiant",
|
||||
type: 'object',
|
||||
required: ['ine', 'idPVE', 'dateEvenement']
|
||||
)]
|
||||
|
||||
class ProfilEtudiantRequestVO
|
||||
{
|
||||
#[OA\Property(
|
||||
type: 'string',
|
||||
description: 'Identifiant national de l\'étudiant'
|
||||
)]
|
||||
public string $ine;
|
||||
|
||||
#[OA\Property(
|
||||
type: 'string',
|
||||
description: 'Identifiant MSE unique de l\'étudiant'
|
||||
)]
|
||||
public string $idPVE;
|
||||
|
||||
#[OA\Property(
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date heure à laquelle le dernier changement sur l\'étudiant a été fait'
|
||||
)]
|
||||
public string $dateEvenement;
|
||||
}
|
11
src/Kernel.php
Normal file
11
src/Kernel.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
}
|
Reference in New Issue
Block a user