123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- namespace App\Http\Controllers\Client;
- use App\Http\Controllers\Controller;
- use App\Services\Client\CoachService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- /**
- * @group 用户端
- *
- * 技师相关的API接口
- */
- class CoachController extends Controller
- {
- protected CoachService $service;
- public function __construct(CoachService $service)
- {
- $this->service = $service;
- }
- /**
- * [技师]获取附近技师列表
- *
- * 根据经纬度获取技师列表
- *
- * @authenticated
- *
- * @queryParam latitude float required 纬度. Example: 39.9042
- * @queryParam longitude float required 经度. Example: 116.4074
- *
- * @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->success($this->service->getNearCoachList(Auth::user()->id, $latitude, $longitude));
- }
- /**
- * [技师]获取技师详情
- *
- * 根据ID获取技师的详细信息
- *
- * @authenticated
- *
- * @urlParam id int required 技师ID. Example: 6
- *
- * @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->success($this->service->getCoachDetail($id, $latitude, $longitude));
- }
- /**
- * [技师]获取可预约时间段
- *
- * @description 获取指定技师的可预约时间段列表,包含日期、星期、时间段等信息
- *
- * @queryParam coach_id int required 技师ID Example: 6
- * @queryParam date string 日期(格式:Y-m-d) Example: 2024-03-22
- *
- * @response {
- * "data": {
- * "date": "2024-03-22",
- * "day_of_week": "星期五",
- * "is_today": false,
- * "time_slots": [
- * {
- * "start_time": "09:00",
- * "end_time": "09:30",
- * "is_available": true,
- * "duration": 30
- * }
- * ],
- * "total_slots": 1,
- * "updated_at": "2024-03-22 10:00:00"
- * }
- * }
- * @response 404 {
- * "message": "技师不存在"
- * }
- * @response 400 {
- * "message": "技师状态异常"
- * }
- * @response 400 {
- * "message": "不能查询过去的日期"
- * }
- * @response 400 {
- * "message": "只能查询未来30天内的时间段"
- * }
- */
- public function getSchedule(Request $request)
- {
- // 验证参数
- $validated = $request->validate([
- 'coach_id' => 'required|integer|exists:coach_users,id',
- 'date' => 'nullable|date_format:Y-m-d',
- ]);
- // 调用service获取技师可预约时间段
- return $this->success($this->service->getSchedule($validated['coach_id'], $validated['date'] ?? null));
- }
- }
|