<?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!
|
*/
Route::post('auth/login', 'App\Http\Controllers\Auth\Index@login');

Route::prefix('auth')->middleware(['auth:api'])->group(function ($router) {
	Route::post('logout', [App\Http\Controllers\Auth\Index::class, 'logout']);
	Route::post('refresh', [App\Http\Controllers\Auth\Index::class, 'refresh']);
	Route::get('me', [App\Http\Controllers\Auth\User::class, 'index']);
});


Route::prefix('system')->middleware(['auth:api'])->group(function ($router) {
	Route::get('index/version', [App\Http\Controllers\System\Index::class, 'version']);
	Route::get('log', [App\Http\Controllers\System\Index::class, 'log']);
	Route::get('setting', [App\Http\Controllers\System\Setting::class, 'index']);
});

Route::prefix('user')->middleware(['auth:api'])->group(function ($router) {
	/* 前端菜单 */
	Route::controller(App\Http\Controllers\Auth\Permission::class)->group(function () {
		Route::get('menu', 'index');
		Route::get('menu/my', 'my');
		Route::post('menu', 'add');
		Route::put('menu', 'edit');
	});

	/* 部门路由 */
	Route::controller(App\Http\Controllers\Auth\Department::class)->group(function () {
		Route::get('department', 'index');
		Route::post('department', 'add');
		Route::put('department', 'edit');
	});

	/* 用户路由 */
	Route::controller(App\Http\Controllers\Auth\User::class)->group(function () {
		Route::get('index', 'index');
		Route::get('info', 'info');
	});
});
