From e8bdbaf7ebc6e531b7ece08f3a32e2ca36c4d984 Mon Sep 17 00:00:00 2001 From: "allen.yan" Date: Wed, 4 Jun 2025 15:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=B0=E5=8B=95=20Branch=20Swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/BranchControlController.php | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/BranchControlController.php b/app/Http/Controllers/BranchControlController.php index 9ee59de..d41dbac 100644 --- a/app/Http/Controllers/BranchControlController.php +++ b/app/Http/Controllers/BranchControlController.php @@ -35,9 +35,8 @@ class BranchControlController extends Controller * @OA\Property(property="enable", type="boolean", example=true), * @OA\Property( * property="rooms", - * type="array", - * @OA\Items( - * @OA\Property(property="room_name", type="string", example="pc101"), + * type="object", + * additionalProperties=@OA\Schema( * @OA\Property(property="is_online", type="boolean", example=true), * @OA\Property(property="status", ref="#/components/schemas/RoomStatus"), * @OA\Property(property="started_at", type="string", format="date-time", example="2025-06-04 10:00:00Z"), @@ -47,6 +46,20 @@ class BranchControlController extends Controller * )) * ) * ), + * @OA\Response( + * response=401, + * description="Unauthorized", + * @OA\JsonContent( + * allOf={ + * @OA\Schema(ref="#/components/schemas/ApiResponse"), + * @OA\Schema( + * @OA\Property(property="code", type="string", example="UNAUTHORIZED"), + * @OA\Property(property="message", type="string", example="Unauthorized"), + * @OA\Property(property="data", type="null") + * ) + * } + * ) + * ), * ) */ public function Branches(Request $request): JsonResponse @@ -59,11 +72,11 @@ class BranchControlController extends Controller 'rooms' => $branch->rooms ->filter(fn($room) => $room->type === RoomType::PC) ->mapWithKeys(function ($room) { - $roomName = $room->type->value . $room->name; + $roomName = ($room->type?->value ?? '') . $room->name; return [ $roomName => [ 'is_online' => $room->is_online, - 'status' => $room->status->value, + 'status' => $room->status?->value ?? null, 'started_at' => $room->started_at, 'ended_at' => $room->ended_at, ]