File manager - Edit - /var/www/html/pcadigital/api/app/Http/Controllers/FollowerController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\TriggerFollowerRequest; use App\Http\Resources\OccurrenceResource; use App\Http\Services\AuthService; use App\Http\Services\FollowerService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; /** * @OA\Tag( * name="Follower", * description="Gerenciamento de seguidores de ocorrência" * ) */ class FollowerController extends Controller { private FollowerService $followerService; private AuthService $authService; public function __construct() { $this->followerService = new FollowerService(); $this->authService = new AuthService(); } /** * @OA\Post( * path="/api/followers/trigger", * summary="Acompanha uma ocorrência", * operationId="TriggerFollower", * tags={"Follower"}, * security={{"bearerAuth":{}}}, * @OA\RequestBody( * required=true * ), * @OA\Response(response=200, description="Seguidor acionado com sucesso"), * @OA\Response(response=401, description="Não autenticado ou sessão inválida"), * @OA\Response(response=422, description="Erro de validação") * ) */ public function triggerFollower(TriggerFollowerRequest $request) { $data = $request->all(); $response = $this->authService->validateSessionUser($request, $data['auth_uuid']); if ($response->status() != JsonResponse::HTTP_OK) { return $response; } $user = $response->json()['data']['user']; $response = $this->followerService->triggerFollower($data, $user); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/followers/{citizen}/occurrences", * summary="Lista ocorrências acompanhadas por um seguidor", * operationId="GetFollowerOccurrences", * tags={"Follower"}, * security={{"bearerAuth":{}}}, * @OA\Parameter( * name="citizen", * in="path", * required=true, * @OA\Schema(type="string"), * description="UUID do cidadão" * ), * @OA\Response( * response=200, * description="Ocorrências retornadas com sucesso" * ), * @OA\Response(response=401, description="Não autenticado ou sessão inválida") * ) */ public function getFollowerOccurrences(Request $request, string $citizen) { $response = $this->authService->validateSessionUser($request, $citizen); if($response->status() != JsonResponse::HTTP_OK) { return $response; } $user = $response->json()['data']['user']; $response = $this->followerService->getFollowerOccurrences($user, $citizen); return OccurrenceResource::collection($response); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings