File manager - Edit - /var/www/html/pcadigital/api/app/Http/Controllers/OccurrenceController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\OccurrenceRequest; use App\Http\Services\AuthService; use App\Http\Services\OccurrenceService; use App\Models\Occurrence; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; /** * @OA\Tag( * name="Occurrence", * description="Gerenciamento de Occurrences" * ) */ class OccurrenceController extends Controller { private OccurrenceService $occurrenceService; private AuthService $authService; public function __construct() { $this->occurrenceService = new OccurrenceService(); $this->authService = new AuthService(); } /** * @OA\Get( * path="/api/occurrence/list", * summary="Lista Occurrences", * operationId="IndexOccurrence", * tags={"Occurrence"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=200, description="Occurrences retornados com sucesso") * ) */ public function index() { $response = $this->occurrenceService->index(); return response()->json($response->data, $response->code); } /** * @OA\Post( * path="/api/occurrence/store", * summary="Cria Occurrence", * operationId="StoreOccurrence", * tags={"Occurrence"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=201, description="Occurrence criada com sucesso"), * @OA\Response(response=422, description="Erro de validação") * ) */ public function store(OccurrenceRequest $request) { $response = $this->occurrenceService->store($request); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/occurrence/{occurrence}", * summary="Mostra Occurrence", * operationId="ShowOccurrence", * tags={"Occurrence"}, * security={{"bearerAuth":{}}}, * @OA\Parameter( * name="occurrence", * in="path", * required=true, * @OA\Schema(type="integer") * ), * @OA\Response(response=200, description="Occurrence retornado com sucesso"), * @OA\Response(response=404, description="Occurrence não encontrada") * ) */ public function show(Occurrence $occurrence) { $response = $this->occurrenceService->show($occurrence); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/occurrence/resolved/{authUuid}", * summary="Lista ocorrências resolvidas por usuário", * operationId="GetAllResolvedOccurrencesByUser", * tags={"Occurrence"}, * security={{"bearerAuth":{}}}, * @OA\Parameter( * name="authUuid", * in="path", * required=true, * @OA\Schema(type="string", format="uuid") * ), * @OA\Response(response=200, description="Ocorrências resolvidas retornadas com sucesso"), * @OA\Response(response=401, description="Não autenticado ou sessão inválida") * ) */ public function getAllResolvedOccurrencesByUser(Request $request, $authUuid) { $response = $this->authService->validateSessionUser($request, $authUuid); if ($response->status() != JsonResponse::HTTP_OK) { return $response; } $response = $this->occurrenceService->getAllResolvedOccurrencesByUser($authUuid); return response()->json($response); } /** * @OA\Get( * path="/api/occurrence/finished", * summary="Lista todas ocorrências finalizadas", * operationId="GetAllFinishedOccurrences", * tags={"Occurrence"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=200, description="Ocorrências finalizadas retornadas com sucesso") * ) */ public function getAllFinished() { $response = $this->occurrenceService->getAllFinished(); return response()->json($response->data, $response->code); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings