-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Histologe] Avancer sur une route GET #3339
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace App\Controller\Api; | ||
|
||
use App\Dto\Api\Response\SignalementResponse; | ||
use App\Factory\Api\SignalementResponseFactory; | ||
use App\Repository\SignalementRepository; | ||
use Nelmio\ApiDocBundle\Annotation\Model; | ||
use OpenApi\Attributes as OA; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\DependencyInjection\Attribute\When; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
#[When('dev')] | ||
#[When('test')] | ||
#[Route('/api')] | ||
class SignalementController extends AbstractController | ||
{ | ||
#[Route('/signalements', name: 'api_signalements', methods: ['GET'])] | ||
#[OA\Get( | ||
path: '/api/signalements', | ||
description: 'Retourne les {{ limit }} derniers signalements', | ||
summary: 'Liste des signalements', | ||
security: [['bearerAuth' => []]], | ||
tags: ['Signalements'], | ||
)] | ||
#[OA\Parameter( | ||
name: 'limit', | ||
description: 'Nombre de signalements à retourner (défaut : 20, max : 100)', | ||
in: 'query', | ||
required: false, | ||
schema: new OA\Schema(type: 'limit', example: '10') | ||
numew marked this conversation as resolved.
Show resolved
Hide resolved
|
||
)] | ||
#[OA\Parameter( | ||
name: 'page', | ||
description: 'Numéro de la page de signalement à retourner (défaut : 1)', | ||
in: 'query', | ||
required: false, | ||
schema: new OA\Schema(type: 'page', example: '2') | ||
)] | ||
#[OA\Response( | ||
response: Response::HTTP_OK, | ||
description: 'Une liste de signalements', | ||
content: new OA\JsonContent( | ||
type: 'array', | ||
items: new OA\Items(ref: new Model(type: SignalementResponse::class)) | ||
) | ||
)] | ||
public function getSignalementList( | ||
SignalementRepository $signalementRepository, | ||
SignalementResponseFactory $signalementResponseFactory, | ||
#[MapQueryParameter] int $limit = 20, | ||
#[MapQueryParameter] int $page = 1, | ||
): JsonResponse { | ||
if ($limit < 1) { | ||
$limit = 1; | ||
} | ||
if ($limit > 100) { | ||
$limit = 100; | ||
} | ||
numew marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ($page < 1) { | ||
$page = 1; | ||
} | ||
$signalements = $signalementRepository->findForAPI(user: $this->getUser(), limit: $limit, page: $page); | ||
$resources = []; | ||
foreach ($signalements as $signalement) { | ||
$resources[] = $signalementResponseFactory->createFromSignalement($signalement); | ||
} | ||
|
||
return new JsonResponse($resources, Response::HTTP_OK); | ||
} | ||
|
||
#[Route('/signalements/{uuid}', name: 'api_signalement_uuid', methods: ['GET'])] | ||
numew marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[OA\Get( | ||
path: '/api/signalements/{uuid}', | ||
description: 'Retourne un signalement récupéré par son UUID', | ||
summary: 'Signalement par UUID', | ||
security: [['bearerAuth' => []]], | ||
tags: ['Signalements'] | ||
)] | ||
#[OA\Response( | ||
response: Response::HTTP_OK, | ||
description: 'Un signalement', | ||
content: new OA\JsonContent(ref: '#/components/schemas/SignalementResponse') | ||
)] | ||
public function getSignalementByUuid( | ||
SignalementRepository $signalementRepository, | ||
SignalementResponseFactory $signalementResponseFactory, | ||
string $uuid, | ||
): JsonResponse { | ||
$signalements = $signalementRepository->findForAPI(user : $this->getUser(), uuid : $uuid); | ||
if (!count($signalements)) { | ||
return new JsonResponse(['message' => 'Signalement introuvable'], Response::HTTP_NOT_FOUND); | ||
} | ||
$resource = $signalementResponseFactory->createFromSignalement($signalements[0]); | ||
|
||
return new JsonResponse($resource, Response::HTTP_OK); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ users: | |
- | ||
email: [email protected] | ||
roles: "[\"ROLE_API_USER\"]" | ||
partner: "Administrateurs Histologe ALL" | ||
partner: "Partenaire 13-01" | ||
statut: 1 | ||
is_generique: 0 | ||
is_mailing_active: 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
use App\Entity\Criticite; | ||
use App\Entity\DesordrePrecision; | ||
|
||
class Desordre | ||
{ | ||
public string $categorie; | ||
public ?string $zone; | ||
public array $details = []; | ||
|
||
public function __construct( | ||
string $categorie, | ||
array $data, | ||
?string $zone = null, | ||
) { | ||
$this->categorie = $categorie; | ||
$this->zone = $zone; | ||
foreach ($data as $label => $detail) { | ||
$details = $label; | ||
if ($detail->getLabel() && ($detail instanceof DesordrePrecision || $detail instanceof Criticite)) { | ||
$details .= ' : '.$detail->getLabel(); | ||
} | ||
$this->details[] = $details; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
class File | ||
{ | ||
public string $titre; | ||
public string $documentType; | ||
public string $url; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
class Geolocalisation | ||
{ | ||
public function __construct(public ?float $latitude, public ?float $longitude) | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
use App\Entity\Intervention as InterventionEntity; | ||
|
||
class Intervention | ||
{ | ||
public string $dateIntervention; | ||
public ?string $type; | ||
public ?string $statut; | ||
public ?Partner $partner; | ||
public ?string $details; | ||
public array $conclusions = []; | ||
public ?bool $occupantPresent; | ||
public ?bool $proprietairePresent; | ||
|
||
public function __construct( | ||
InterventionEntity $intervention, | ||
) { | ||
$this->dateIntervention = $intervention->getScheduledAt()->format(\DATE_ATOM); | ||
$this->type = $intervention->getType()?->label(); | ||
$this->statut = $intervention->getStatus(); | ||
$this->partner = $intervention->getPartner() ? new Partner($intervention->getPartner()) : null; | ||
$this->details = $intervention->getDetails(); // traitement de suppression du html | ||
$this->conclusions = $intervention->getConcludeProcedure() ?? []; | ||
$this->occupantPresent = $intervention->isOccupantPresent(); | ||
$this->proprietairePresent = $intervention->isProprietairePresent(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
use App\Entity\Partner as PartnerEntity; | ||
|
||
class Partner | ||
{ | ||
public string $nom; | ||
public ?string $type; | ||
public array $competences = []; | ||
|
||
public function __construct( | ||
PartnerEntity $partner, | ||
) { | ||
$this->nom = $partner->getNom(); | ||
$this->type = $partner->getType()?->label(); | ||
$this->competences = $partner->getCompetence() ?? []; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Model; | ||
|
||
use App\Entity\Suivi as SuiviEntity; | ||
|
||
class Suivi | ||
{ | ||
public int $id; | ||
public string $dateCreation; | ||
public string $description; | ||
public bool $public; | ||
public int $type; | ||
public string $createdBy; | ||
|
||
public function __construct( | ||
SuiviEntity $suivi, | ||
) { | ||
$this->id = $suivi->getId(); | ||
$this->dateCreation = $suivi->getCreatedAt()->format(\DATE_ATOM); | ||
$this->description = $suivi->getDescription(); // traitement de suppression du html ? comment gérer les bouton/doc qui sont présent en dur dans le contenu ? | ||
$this->public = $suivi->getIsPublic(); | ||
$this->type = $suivi->getType(); | ||
$this->createdBy = $suivi->getCreatedByLabel(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
|
||
namespace App\Dto\Api\Response; | ||
|
||
use App\Dto\Api\Model\Desordre; | ||
use App\Dto\Api\Model\File; | ||
use App\Dto\Api\Model\Geolocalisation; | ||
use App\Dto\Api\Model\Intervention; | ||
use App\Dto\Api\Model\Suivi; | ||
use OpenApi\Attributes as OA; | ||
|
||
class SignalementResponse | ||
{ | ||
// references, dates et statut | ||
public string $uuid; | ||
public string $reference; | ||
public string $dateCreation; | ||
public int $statut; | ||
numew marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public ?string $dateValidation; | ||
public ?string $dateCloture; | ||
public ?string $motifCloture; | ||
public ?string $motifRefus; | ||
public ?bool $abandonProcedureUsager; | ||
// type declarant et details | ||
public ?string $typeDeclarant; | ||
public ?string $precisionTypeSiBailleur; | ||
public ?string $lienDeclarantOccupantSiTiers; | ||
public ?string $details; | ||
// infos logement | ||
public ?string $natureLogement; | ||
public ?string $precisionNatureLogement; | ||
public ?bool $logementSocial; | ||
public ?float $superficie; | ||
public ?bool $pieceUnique; | ||
public ?string $nbPieces; | ||
public ?string $anneeConstruction; | ||
public ?bool $constructionAvant1949; | ||
public ?string $nbNiveaux; | ||
public ?bool $rezDeChaussee; | ||
public ?bool $dernierEtage; | ||
public ?bool $sousSolSansFenetre; | ||
public ?bool $sousCombleSansFenetre; | ||
public ?bool $pieceAVivreSuperieureA9m; | ||
public ?bool $cuisine; | ||
public ?bool $cuisineCollective; | ||
public ?bool $salleDeBain; | ||
public ?bool $salleDeBainCollective; | ||
public ?bool $wc; | ||
public ?bool $wcDansCuisine; | ||
public ?bool $wcCollectif; | ||
public ?bool $hauteurSuperieureA2metres; | ||
public ?bool $dpeExistant; | ||
public ?string $dpeClasseEnergetique; | ||
public Geolocalisation $geoLocalisation; | ||
// infos declarant | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pour faciliter la lecture, je proposerai un objet personne comme sur SISH avec le type personne pour distinguer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je suis pas bien chaud du moment que nos différent type n'ont pas les même donnés (le commun c'est juste nom, prénom, tel1, tel2, mail. mais pas civilité par exemple. Sachant que pour proprio le seul requis et le nom) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vu en stand-up demande une analyse plus approfondi, je partage la classe qui représentent les personnes dans SI-SH There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public ?string $structureDeclarant; | ||
public ?string $nomDeclarant; | ||
public ?string $prenomDeclarant; | ||
public ?string $telephoneDeclarant; | ||
public ?string $telephoneSecondaireDeclarant; | ||
public ?string $mailDeclarant; | ||
public ?bool $estTravailleurSocialPourOccupant; | ||
// infos occupant | ||
public ?string $civiliteOccupant; | ||
public ?string $nomOccupant; | ||
public ?string $prenomOccupant; | ||
public ?string $telephoneOccupant; | ||
public ?string $telephoneSecondaireOccupant; | ||
public ?string $mailOccupant; | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. élément d'objet personne |
||
public ?string $adresseOccupant; | ||
public ?string $codePostalOccupant; | ||
public ?string $villeOccupant; | ||
public ?string $etageOccupant; | ||
public ?string $escalierOccupant; | ||
public ?string $numAppartOccupant; | ||
public ?string $codeInseeOccupant; | ||
public ?string $cleBanAdresseOccupant; | ||
public ?string $adresseAutreOccupant; | ||
public ?string $dateNaissanceOccupant; | ||
public ?string $dateEntreeLogement; | ||
public ?int $nbOccupantsLogement; | ||
public ?bool $enfantsDansLogement; | ||
public ?bool $assuranceContactee; | ||
public ?string $reponseAssurance; | ||
public ?bool $souhaiteQuitterLogement; | ||
public ?bool $souhaiteQuitterLogementApresTravaux; | ||
public ?bool $suiviParTravailleurSocial; | ||
public ?string $revenuFiscalOccupant; | ||
// infos proprietaire | ||
public ?string $typeProprietaire; | ||
public ?string $nomProprietaire; | ||
public ?string $prenomProprietaire; | ||
public ?string $adresseProprietaire; | ||
public ?string $codePostalProprietaire; | ||
public ?string $villeProprietaire; | ||
public ?string $telephoneProprietaire; | ||
public ?string $telephoneSecondaireProprietaire; | ||
public ?string $mailProprietaire; | ||
public ?string $proprietaireRevenuFiscal; | ||
public ?bool $proprietaireBeneficiaireRsa; | ||
public ?bool $proprietaireBeneficiaireFsl; | ||
public ?string $proprietaireDateNaissance; | ||
Comment on lines
+90
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Élément d'objet personne |
||
// infos location | ||
public ?bool $proprietaireAverti; | ||
public ?float $loyer; | ||
public ?bool $bailEnCours; | ||
public ?bool $bailExistant; | ||
public ?bool $etatDesLieuxExistant; | ||
public ?bool $preavisDepartTransmis; | ||
public ?bool $demandeRelogementEffectuee; | ||
public ?bool $loyersPayes; | ||
public ?string $dateEffetBail; | ||
// infos allocataire | ||
public ?bool $allocataire; | ||
public ?string $typeAllocataire; | ||
public ?string $numAllocataire; | ||
public ?string $montantAllocation; | ||
public ?bool $beneficiaireRSA; | ||
public ?bool $beneficiaireFSL; | ||
// désordres | ||
#[OA\Property( | ||
type: 'array', | ||
items: new OA\Items(ref: Desordre::class) | ||
)] | ||
public array $desordres = []; | ||
public ?float $score; | ||
public ?float $scoreBatiment; | ||
public ?float $scoreLogement; | ||
Comment on lines
+126
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Un objet score There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pour le moment j'ai pas ajouté d'object (à part le Geolocalisation) mais je suis pas super chaud de faire plein de petit object, ca me parait aussi bien à plat. Discutable, à discuter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK pour le laisser à plat. Après je sais qu'aucun des partenaires l'exploite malgré qu'on peut l'envoyer chez certain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pour la géolocalisation ça devrait être dans un objet adresse vu ce matin (à mon sens par utile de faire un objet ça peut être deux propriété à plat latitude et longitude) |
||
// tags, qualifications, suivis, affectations, interventions, files | ||
public array $tags = []; | ||
public array $qualifications = []; | ||
#[OA\Property( | ||
type: 'array', | ||
items: new OA\Items(ref: Suivi::class) | ||
)] | ||
public array $suivis = []; | ||
#[OA\Property( | ||
type: 'array', | ||
items: new OA\Items(ref: Intervention::class) | ||
)] | ||
public array $interventions = []; | ||
#[OA\Property( | ||
type: 'array', | ||
items: new OA\Items(ref: File::class) | ||
)] | ||
public array $files = []; | ||
// divers | ||
public ?string $territoireNom; | ||
public ?string $territoireCode; | ||
public bool $signalementImporte; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On part du principe que les signalements sont récupérable à partir du moment ou la DDT valide et affecte au partenaire. Si le partenaire à une clé d'API elle peut récupérer les signalements affectés à un ou plusieurs type de partenaires.
Permettre le filtre par date et plage de date, ça serait la date d'affectation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai effectivement revu le principe pour retourner la liste des signalements affectés au partenaire de l'user API.
Pour les filtres (dates ou autres) est-ce qu'on attends pas un autre ticket ? Il faudrait dans ce cas rajouter la date d'affectation pour le partenaire dans ce qui est retourné.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour l'ajout de filtres, on peut attendre un autre ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3424