<?php

namespace App\Http\Controllers\Api\V1\Admin\Draw;

use App\Models\Draw;
use App\Support\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Support\AdminDrawApiPresenter;
use App\Services\Draw\DrawHallSnapshotBuilder;

/**
 * GET /api/v1/admin/draws/{draw} — 当期状态明细（后台查看 DB 为准 + 大厅展示态预览）。
 */
final class AdminDrawShowController extends Controller
{
    public function __construct(
        private readonly DrawHallSnapshotBuilder $hallPreview,
    ) {}

    public function __invoke(Request $request, Draw $draw): JsonResponse
    {
        $admin = $request->lotteryAdmin();
        abort_if($admin === null, 401);

        return ApiResponse::success(
            AdminDrawApiPresenter::show($draw, $admin, $this->hallPreview),
        );
    }
}
