<?php

use App\Http\Controllers\Client\AccountController;
use App\Http\Controllers\Client\CoachController;
use App\Http\Controllers\Client\CoachLocationController;
use App\Http\Controllers\Client\ProjectController;
use App\Http\Controllers\Client\UserController;
use App\Http\Controllers\ScribeController;
use Illuminate\Support\Facades\Route;

// API文档相关
Route::get('scribe/update-token/{mobile}', [ScribeController::class, 'updateAuthToken']);

// 无需认证的公开路由
Route::prefix('account')->group(function () {
    // 发送验证码
    Route::post('send-code', [AccountController::class, 'sendVerifyCode']);
    // 手机号登录
    Route::post('login', [AccountController::class, 'login']);
    // 微信登录
    Route::post('wx-login', [AccountController::class, 'wxLogin']);
});

// 需要认证的路由组
Route::middleware('auth:sanctum')->group(function () {
    // 账号相关
    Route::prefix('account')->group(function () {
        // 退出登录
        Route::post('logout', [AccountController::class, 'logout']);
        // 注销账号
        Route::delete('/', [AccountController::class, 'destroy']);
    });

    // 用户相关
    Route::prefix('user')->group(function () {
        // 获取用户信息
        Route::get('/', [UserController::class, 'show']);
        // 更新用户信息
        Route::put('/', [UserController::class, 'update']);

        // 获取钱包信息
        Route::get('wallet', [UserController::class, 'wallet']);
        // 提现
        Route::post('withdraw', [UserController::class, 'withdraw']);

        // 用户反馈
        // Route::post('feedback', [UserController::class, 'feedback']);
        // 申请成为技师
        Route::post('apply-coach', [UserController::class, 'applyCoach']);
    });

    Route::prefix('project')->group(function () {
        Route::get('/', [ProjectController::class, 'index']); // 获取项目列表
        Route::get('/{id}/detail', [ProjectController::class, 'detail']); // 获取项目详情
        Route::get('/coach-list', [ProjectController::class, 'coachProjectList']); // 获取技师开通的项目列表
    });

    Route::prefix('coach')->group(function () {
        Route::prefix('location')->group(function () {
            Route::get('/', [CoachLocationController::class, 'index']); // 获取所有技师定位
            Route::post('/', [CoachLocationController::class, 'store']); // 创建新的技师定位
            Route::delete('/{id}', [CoachLocationController::class, 'destroy']);    // 删除技师定位
        });
        Route::get('/', [CoachController::class, 'list']); // 获取技师列表
        Route::get('/{id}', [CoachController::class, 'detail']); // 获取技师详情

    });

});
