<?php

namespace App\Http\Controllers\Client;

use App\Http\Controllers\Controller;
use App\Services\Client\CoachService;
use Illuminate\Http\Request;

class CoachController extends Controller
{
    protected CoachService $service;

    public function __construct(CoachService $service)
    {
        $this->service = $service;
    }

    /**
     * [技师管理] 获取技师列表
     *
     * 根据经纬度获取技师列表
     *
     * @return \Illuminate\Http\JsonResponse
     *
     * @OA\Get(
     *     path="/api/coaches",
     *     summary="获取技师列表",
     *     description="根据经纬度获取技师列表",
     *     tags={"Coaches"},
     *
     *     @OA\Parameter(
     *         name="latitude",
     *         in="query",
     *         required=true,
     *
     *         @OA\Schema(type="number", format="float"),
     *         description="纬度"
     *     ),
     *
     *     @OA\Parameter(
     *         name="longitude",
     *         in="query",
     *         required=true,
     *
     *         @OA\Schema(type="number", format="float"),
     *         description="经度"
     *     ),
     *
     *     @OA\Response(
     *         response=200,
     *         description="成功获取技师列表"
     *     )
     * )
     */
    public function list(Request $request)
    {
        $latitude = $request->input('latitude');
        $longitude = $request->input('longitude');

        return $this->service->getCoachList($latitude, $longitude);
    }

    /**
     * [技师管理] 获取技师详情
     *
     * 根据ID获取技师的详细信息
     *
     * @param  int  $id
     * @return \Illuminate\Http\JsonResponse
     *
     * @OA\Get(
     *     path="/api/coaches/{id}",
     *     summary="获取技师详情",
     *     description="根据ID获取技师的详细信息",
     *     tags={"Coaches"},
     *
     *     @OA\Parameter(
     *         name="id",
     *         in="path",
     *         required=true,
     *
     *         @OA\Schema(type="integer"),
     *         description="技师ID"
     *     ),
     *
     *     @OA\Parameter(
     *         name="latitude",
     *         in="query",
     *         required=false,
     *
     *         @OA\Schema(type="number", format="float"),
     *         description="纬度"
     *     ),
     *
     *     @OA\Parameter(
     *         name="longitude",
     *         in="query",
     *         required=false,
     *
     *         @OA\Schema(type="number", format="float"),
     *         description="经度"
     *     ),
     *
     *     @OA\Response(
     *         response=200,
     *         description="成功获取技师详情"
     *     )
     * )
     */
    public function detail(Request $request, $id)
    {
        $latitude = $request->input('latitude');
        $longitude = $request->input('longitude');

        return $this->service->getCoachDetail($id, $latitude, $longitude);
    }
}
