<?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;
    }

    /**
     * [技师管理] 获取技师列表
     *
     * 根据经纬度获取技师列表
     *
     * @authenticated
     *
     * @queryParam latitude float required 纬度. Example: 34.0522
     * @queryParam longitude float required 经度. Example: -118.2437
     *
     * @response {
     *   "code": 200,
     *   "message": "获取成功",
     *   "data": [
     *     {
     *       "id": 1,
     *       "name": "技师A",
     *       "latitude": 34.0522,
     *       "longitude": -118.2437
     *     }
     *   ]
     * }
     */
    public function list(Request $request)
    {
        $latitude = $request->input('latitude');
        $longitude = $request->input('longitude');

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

    /**
     * [技师管理] 获取技师详情
     *
     * 根据ID获取技师的详细信息
     *
     * @authenticated
     *
     * @urlParam id int required 技师ID. Example: 1
     *
     * @queryParam latitude float 纬度. Example: 34.0522
     * @queryParam longitude float 经度. Example: -118.2437
     *
     * @response {
     *   "code": 200,
     *   "message": "获取成功",
     *   "data": {
     *     "id": 1,
     *     "name": "技师A",
     *     "latitude": 34.0522,
     *     "longitude": -118.2437,
     *     "details": "详细信息"
     *   }
     * }
     */
    public function detail(Request $request, $id)
    {
        $latitude = $request->input('latitude');
        $longitude = $request->input('longitude');

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