異動 Branch Swagger

This commit is contained in:
allen.yan 2025-06-04 15:30:51 +08:00
parent 69e12a08bf
commit e8bdbaf7eb

View File

@ -35,9 +35,8 @@ class BranchControlController extends Controller
* @OA\Property(property="enable", type="boolean", example=true), * @OA\Property(property="enable", type="boolean", example=true),
* @OA\Property( * @OA\Property(
* property="rooms", * property="rooms",
* type="array", * type="object",
* @OA\Items( * additionalProperties=@OA\Schema(
* @OA\Property(property="room_name", type="string", example="pc101"),
* @OA\Property(property="is_online", type="boolean", example=true), * @OA\Property(property="is_online", type="boolean", example=true),
* @OA\Property(property="status", ref="#/components/schemas/RoomStatus"), * @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"), * @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 public function Branches(Request $request): JsonResponse
@ -59,11 +72,11 @@ class BranchControlController extends Controller
'rooms' => $branch->rooms 'rooms' => $branch->rooms
->filter(fn($room) => $room->type === RoomType::PC) ->filter(fn($room) => $room->type === RoomType::PC)
->mapWithKeys(function ($room) { ->mapWithKeys(function ($room) {
$roomName = $room->type->value . $room->name; $roomName = ($room->type?->value ?? '') . $room->name;
return [ return [
$roomName => [ $roomName => [
'is_online' => $room->is_online, 'is_online' => $room->is_online,
'status' => $room->status->value, 'status' => $room->status?->value ?? null,
'started_at' => $room->started_at, 'started_at' => $room->started_at,
'ended_at' => $room->ended_at, 'ended_at' => $room->ended_at,
] ]