<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api',
    'middleware' => ['serializer:array','cors','activity_log','bindings']
], function ($api) {

    $api->group([
        'middleware' => 'api.throttle',
        'limit' => config('api.rate_limits.access.limit'),
        'expires' => config('api.rate_limits.access.expires')
    ], function ($api) {       //游客可以访问的接口

        /*
        |--------------------------------------------------------------
        |  登录
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'login'], function ($api) {
            $api->post('/loginByMobile', 'AuthorizationsController@loginByMobile')->name('login.mobile');
            $api->post('/loginByPassword', 'AuthorizationsController@loginByAccountPassword')->name('login.password');
            $api->post('/forgetPassword', 'AuthorizationsController@forgetPassword')->name('login.forget');
            $api->post('/register', 'AuthorizationsController@register')->name('login.register');
        });

        /*
        |--------------------------------------------------------------
        |  发送短信验证码
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'sms'], function ($api) {
            $api->get('/send', 'SmsController@send')->name('sms.send');
        });



    });
    //需要 token 验证的接口
    $api->group(['middleware' => 'api.auth'], function ($api) {
        /*
        |--------------------------------------------------------------
        |  用户信息相关
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'user'], function ($api) {
            //设置性别
            $api->post('/checksex', 'UserController@checksex')->name('user.checksex');
            //设置资料（初次注册进入时）
            $api->post('/setinfo', 'UserController@setinfo')->name('user.setinfo');

        });


        /*
        |--------------------------------------------------------------
        |  退出登录
        |--------------------------------------------------------------
        */
        $api->put('/logout', 'AuthorizationsController@logout')->name('logout');
    });


});
