<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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',['limit'=>60, 'expire' => 1, 'namespace'=>'App\Http\Controllers'], function ($api) {
    $api->get('web','AdminController@web');
    //管理员登陆退出
    $api->group(['prefix'=>'auth', 'name'=> 'auth.'],function ($api) {
        $api->post('login', 'AuthController@login')->name('login');
        $api->get('me', 'AuthController@me')->name('me');
        $api->post('editPassword', 'AuthController@editPassword')->name('editPassword');
        $api->post('logout', 'AuthController@logout')->name('logout');
    });
    //管理员
    $api->group(['prefix'=>'admin', 'name'=> 'admin.', 'middleware'=> 'check.token'],function ($api) { //, 'middleware'=> 'check.token'
        $api->post('/create', 'AdminController@create')->name('create');
        $api->get('/show', 'AdminController@show')->name('show');
        $api->get('/index', 'AdminController@index')->name('index');
        $api->post('/update', 'AdminController@update')->name('update');
        $api->post('/destroy', 'AdminController@destroy')->name('destroy');
        $api->post('/uploadImg', 'AdminController@uploadImg')->name('uploadImg');
        $api->post('/setStatus', 'AdminController@setStatus')->name('setStatus');
    });
    //角色
    $api->group(['prefix'=>'role', 'name'=> 'role.', 'middleware'=> 'check.token'],function ($api) {
        $api->post('/create', 'RoleController@create')->name('create');
        $api->get('/show', 'RoleController@show')->name('show');
        $api->get('/index', 'RoleController@index')->name('index');
        $api->post('/update', 'RoleController@update')->name('update');
        $api->get('/all', 'RoleController@all')->name('all');
        $api->post('/destroy', 'RoleController@destroy')->name('destroy');
    });
    //后台站点
    $api->group(['prefix'=>'site', 'name'=> 'site.', 'middleware'=> 'check.token'],function ($api) {
        $api->post('/create', 'SiteController@create')->name('create');
        $api->get('/show', 'SiteController@show')->name('show');
        $api->get('/index', 'SiteController@index')->name('index');
        $api->post('/update', 'SiteController@update')->name('update');
        $api->post('/destroy', 'SiteController@destroy')->name('destroy');
        $api->post('/uploadImg', 'SiteController@uploadImg')->name('uploadImg');
        $api->get('/all', 'SiteController@all')->name('all');
    });
});


