<?php

namespace App\Http\Controllers\Api\V1\Documents;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\DocumentTemplate\IndexRequest;
use App\Services\DocumentTemplateService;
use Illuminate\Http\JsonResponse;

class DocumentTemplateController extends Controller
{
    public function __construct(private DocumentTemplateService $service) {}

    /**
     * 양식 목록 조회
     * GET /v1/document-templates
     */
    public function index(IndexRequest $request): JsonResponse
    {
        return ApiResponse::handle(function () use ($request) {
            return $this->service->list($request->validated());
        }, __('message.fetched'));
    }

    /**
     * 양식 상세 조회
     * GET /v1/document-templates/{id}
     */
    public function show(int $id): JsonResponse
    {
        return ApiResponse::handle(function () use ($id) {
            return $this->service->show($id);
        }, __('message.fetched'));
    }
}
