<?php

use App\Admin\Controllers\DistAppearanceTemplateController;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Dcat\Admin\Admin;

Admin::routes();

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'namespace'  => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
], function (Router $router) {
    //主页
    $router->get('/', 'HomeController@index');
    //产品
    $router->get('base-product/parameter', 'BaseProductController@parameter');
    $router->resource('base-product', 'BaseProductController');
    //分类
    $router->resource('product-category', 'BaseProductCategoryController');
    //参数
    $router->resource('product-parameter', 'BaseProductParameterController');
    //视频分类
    $router->resource('video-category', 'BaseVideoCategoryController');
    //视频管理
    $router->resource('base-video', 'BaseVideoController');
    //分销商管理
    $router->resource('dist-admin-distributor', 'DistAdminDistributorController');
    //分销商用户管理
    $router->resource('dist-admin-user', 'DistAdminUserController');
    //分销商站点
    $router->resource('dist-site', 'DistSiteController');
    //询价管理
    $router->resource('dist-inquiry', 'DistInquiryController');
    //外观管理
    $router->resource('dist-appearance', 'DistAppearanceController');
    //模板管理
    $router->any('dist-template/ace', [DistAppearanceTemplateController::class, 'ace']);
    //模板变量
    $router->resource('dist-template-var', 'DistAppearanceVariableController');

    $router->resource('messages', 'DistMessageController');

    // 定义切换语言的路由
    $router->get('language-switch','LanguageController@index');

    // 不需要登录的路由
    $router->get('captcha','CaptchaController@generate');

    //api接口
    $router->get('api/dist', 'ApiController@dist');

    //产品导入
    $router->get('import-product', 'ImportProductController@index');
    $router->get('import-product/{id}', 'ImportProductController@show');

    //产品审核
    $router->get('dist-product-audit', 'DistProductAuditController@index');
    $router->get('dist-product-audit/{id}', 'DistProductAuditController@show');
});

/*
 * 重写上传路由，修改tinymce上传路径
 */
$attributes = [
    'prefix'     => admin_base_path('dcat-api'),
    'middleware' => config('admin.route.middleware'),
    'as'         => 'dcat-api.',
];
app('router')->group($attributes, function ($router) {
    $router->post('editor-md/upload', function () {exit;})->name('editor-md.upload');
    $router->post('tinymce/upload', 'App\Http\Controllers\TinymceController@upload')->name('tinymce.upload');
});
