<?php
/**
 * Created by PhpStorm.
 * User: ywlministrator
 * Date: 2020/7/8
 * Time: 11:05
 */
$app = app();
$languagePath = '';
if(config('app.language_path')) {
    $languagePath = config('app.language_path').'/';
}
$app->router->group([
    'namespace' => 'App\User\Controllers',
    'prefix' => $languagePath.'api',
], function ($router) {

    $router->post('admin/user/admin-login', ['uses' => 'SysAdminUserController@login']);
    $router->group([
        'middleware' => ['admin.auth']
    ], function ($router) {


        // 附件列表
        $router->get('attachment/attachment_list','SysAdminUserController@attachmentList');
        // 上传图片
        $router->post('upload/upload_img','SysAdminUserController@uploadImg');
        //上传文件
        $router->post('upload/upload_file','SysAdminUserController@upload');
        $router->post('attachment/save_attachment','SysAdminUserController@saveAttachment');
        $router->post('attachment/del_attachment','SysAdminUserController@delAttachment');
        $router->post('attachment/batch_del_attachment','SysAdminUserController@batchDelAttachment');


        //后台用户获取用户信息
        $router->get('admin/user/get-admin-user', ['uses' => 'SysAdminUserController@getUser']);
        //后台用户登录
        $router->post('admin/user/admin-logout', ['uses' => 'SysAdminUserController@logout']);

        //获取街道列表
        $router->get('admin/get/company-street-list', ['uses' => 'SysAdminUserController@getCompanyStreetList']);
        //获取后台用户列表
        $router->get('admin/user/get-admin-list', ['uses' => 'SysAdminUserController@getAdminUserList']);  //获取后台用户列表
        //新增后台用户
        $router->put('admin/user/add/admin-user', ['uses' => 'SysAdminUserController@addAdminUser']);
        //编辑后台用户
        $router->post('admin/user/edit/admin-user', ['uses' => 'SysAdminUserController@editAdminUser']);
        //删除用户
        $router->delete('admin/user/del/admin-user', ['uses' => 'SysAdminUserController@setAdminUserStatus']);
        //禁用后台用户
        $router->post('admin/user/ban/admin-user', ['uses' => 'SysAdminUserController@setAdminUserStatus']);

        /*后台用户角色*/

        //获取后台角色列表
        $router->get('admin/role/get-role-list', ['uses' => 'SysAdminUserController@getRoleList']);
        //新增角色
        $router->put('admin/role/add', ['uses' => 'SysAdminUserController@saveRole']);
        //修改角色
        $router->post('admin/role/edit', ['uses' => 'SysAdminUserController@saveRole']);
        //删除角色
        $router->delete('admin/role/del/{id}', ['uses' => 'SysAdminUserController@delRole']);
        //后台角色授权
        $router->post('admin/role/auth', ['uses' => 'SysAdminUserController@roleAuth']);

        /*后台菜单*/

        //获取后台菜单*列表
        $router->get('admin/menu-func/get-menu-func-list', ['uses' => 'SysAdminUserController@getMenuFuncList']);
        //新增菜单
        $router->put('admin/menu-func/add', ['uses' => 'SysAdminUserController@saveMenuFunc']);
        //修改菜单
        $router->post('admin/menu-func/edit', ['uses' => 'SysAdminUserController@saveMenuFunc']);
        //删除角菜单
        $router->delete('admin/menu-func/del/{id}', ['uses' => 'SysAdminUserController@delMenuFunc']);

        $router->post('/admin/user/heartbeat', 'SysAdminUserController@heartbeat');
    });
});
