<?php

namespace App\Controller;

use App\Request\CodeRequest;
use App\Services\CodeService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

class CodeController extends AbstractController
{
    /**
     * 获取手机号验证码
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getPhoneCode(): ResponseInterface
    {
        $request = $this->container->get(CodeRequest::class);
        $request->scene('getPhoneCode')->validateResolved();

        $CodeService = new CodeService();

        $data = fail();

        $scene = $this->request->input('scene');
        switch ($scene) {
            case 1:
                // 登陆
                $data = $CodeService->getLoginPhoneCode();
                break;

            default:
                // code...
                break;
        }

        return $this->response->json($data);
    }
}