<?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', ['namespace' => 'App\Http\Controllers\V1'], function ($api) {

    $api->group(['middleware' => ['api.throttle','switch_lang']], function ($api) {
        //语言切换
        $api->any('/changeLocale', 'HomeController@language');
    });

    //测试数据接口
    $api->group(['prefix'=>'test'], function($api){
        //创建 球员比赛成绩
        $api->any('create_holes', 'TestController@createHoles');
        //创建 球员比赛成绩
        $api->any('create_game_user_scores', 'TestController@createGameUserScores');
        //创建比赛，添加球员，生成比赛分数
        $api->any('create_game_all_data', 'TestController@createGameAllData');
        //同步比赛人数
        $api->any('add_members', 'TestController@addMembers');
        //清空测试数据
        $api->any('clear_table', 'TestController@clearTable');
        //测试
        $api->any('index', 'TestController@index');

    });


    //不需要登录的接口
    $api->group([
        'middleware' => ['api.throttle','switch_lang','lang'],
        'limit' => config('api.rate_limits.access.limit'),
        'expires' => config('api.rate_limits.access.expires')
    ], function ($api) {
        //手机验证码
        $api->any('send_sms_code', ['uses' => 'SmsController@send']);
        //邮箱验证码
        $api->any('send_email_code', ['uses' => 'SmsController@sendEmailCode']);
        //国际区号手机前缀
        $api->any('user/mobile_prefix', 'UserController@mobilePrefix')->name('user.mobile_prefix');
        //系统头像库
        $api->any('user/system_avatar', 'UserController@systemAvatar')->name('user.system_avatar');
        //获取第一用户信息
        $api->any('test/get_first_user_info', 'TestController@getFirstUserInfo');
        /**
         * 注册和登录
         */
        $api->group(['prefix' => 'auth'], function ($api) {
            //手机（注册/登录）
            $api->any('enter_by_mobile', 'AuthController@interByMobile');
            //邮箱（注册/登录）
            $api->any('enter_by_email', 'AuthController@interByEmail');
            //账号登录（手机号/邮箱 + 密码）create_group
            $api->any('login', 'AuthController@login');
            //退出
            $api->any('logout',  'AuthController@logout');
            //三方登录跳转
            $api->any('auth_redirect',  'AuthController@authRedirect');
            //三方登录验证
            $api->any('auth_login',  'AuthController@authLogin');
            //facebook 登录
            $api->any('facebook_login',  'AuthController@facebookLogin');
            //苹果 登录
            $api->any('apple_login',  'AuthController@appleLogin');
            //短信验证码登录
            $api->any('login_by_code', 'AuthController@loginByCode');
            //忘记密码
            $api->any('forget_password', 'AuthController@forgetPassword');
        });


        /*
        |--------------------------------------------------------------
        |  文档接口
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'home'], function ($api) {
            $api->any('document', 'HomeController@document')->name('home.document');
        });

        /*
          |--------------------------------------------------------------
          |  获取oss上传配置
          |--------------------------------------------------------------
          */
        $api->group(['prefix' => 'upload-config'], function ($api) {
            $api->any('/config', 'UploadConfigController@config')->name('upload.config');
        });

        $api->group(['prefix' => 'team'], function ($api) {
            //球队详情
            $api->any('detail', ['uses' => 'TeamController@detail']);
            //获取球队相册
            $api->any('get_photos', ['uses' => 'TeamController@getPhotos']);
        });

        $api->group(['prefix' => 'game'], function ($api) {
            //比赛信息  todayGames
            $api->any('info', 'GameController@info');
            //球洞信息
            $api->any('holes', 'GameController@holes');
            //正在进行的比赛球员成绩
            $api->any('ongoing_game_scores', 'GameController@ongoingGameScores')->name('user.ongoing_game_scores');
        });

        /*
       |--------------------------------------------------------------
       |  公共相关
       |--------------------------------------------------------------
       */
        $api->group(['prefix' => 'home'], function ($api) {
            //用户详情
            $api->any('user_detail', 'HomeController@userDetail')->name('home.user_detail');
            //用户动态
            $api->any('user_feeds', 'HomeController@userFeeds')->name('home.user_feeds');
            $api->any('share_info', 'HomeController@shareInfo')->name('home.share_info');
        });

        $api->group(['prefix' => 'feeds'], function ($api) {
            //动态详情
            $api->any('detail', 'FeedsController@detail')->name('feeds.detail');
            //动态列表
            $api->any('list', 'FeedsController@feedList')->name('feeds.list');
        });
    });


    //需要 token 验证的接口
    $api->group(['middleware' => ['api.auth','switch_lang','lang'],
        'limit' => config('api.rate_limits.access.limit'),
        'expires' => config('api.rate_limits.access.expires')], function ($api) {
        /*
      |--------------------------------------------------------------
      |  球队相关
      |--------------------------------------------------------------
      */
        $api->group(['prefix' => 'team'], function ($api) {
            //创建球队
            $api->any('create', ['uses' => 'TeamController@store']);
            //更新球队
            $api->any('update/{id}', ['uses' => 'TeamController@update']);
            //修改背景图
            $api->any('background', ['uses' => 'TeamController@background']);
            //添加球员
            $api->any('add_member', ['uses' => 'TeamController@addMember']);
            //球队成员
            $api->any('members', ['uses' => 'TeamController@members']);
            //我的球队
            $api->any('my_teams', ['uses' => 'TeamController@myTeams']);
            //退出球队
            $api->any('exit_team', ['uses' => 'TeamController@exitTeam']);
            //删除队员
            $api->any('del_member', ['uses' => 'TeamController@delMember']);
            //搜索队员
            $api->any('search_member', ['uses' => 'TeamController@searchMember']);
            //搜索球队
            $api->any('search_teams', ['uses' => 'TeamController@searchTeams']);
            //申请加入球队
            $api->any('apply_join', ['uses' => 'TeamController@applyJoin']);
            //邀请加入球队
            $api->any('invite_join', ['uses' => 'TeamController@inviteJoin']);
            //同意/拒绝 加入
            $api->any('join', ['uses' => 'TeamController@join']);
            //解散球队
            $api->any('dismiss', ['uses' => 'TeamController@dismiss']);
            //发布公告
            $api->any('publish_notice', ['uses' => 'TeamController@publishNotice']);
            //获取公告
            $api->any('get_notice', ['uses' => 'TeamController@getNotice']);
            //相册上传
            $api->any('publish_photo', ['uses' => 'TeamController@publishPhotos']);
            //删除球队相册
            $api->any('del_photo', ['uses' => 'TeamController@delPhoto']);
            //球队比赛
            $api->any('games', ['uses' => 'TeamController@games']);

        });

        /*
       |--------------------------------------------------------------
       |  比赛活动
       |--------------------------------------------------------------
       */
        $api->group(['prefix' => 'game'], function ($api) {
            //创建比赛
            $api->any('create', 'GameController@store');
            //修改比赛场地
            $api->any('change_course', 'GameController@changeCourse');
            //比赛规模
            $api->any('game_types', 'GameController@gameTypes');
            //修改比赛
            $api->any('update/{id}', 'GameController@update');
            //今日赛事
            $api->any('today_games', 'GameController@todayGames');
            //我的活动
            $api->any('my_games', 'GameController@myGames');
            //历史球员
            $api->any('history_players', 'GameController@historyPlayers');
            //搜索球友
            $api->any('search_players', 'GameController@searchPlayers');
            //拉入比赛
            $api->any('pull_game', 'GameController@pullGame');
            //批量添加球员
            $api->any('batch_add_players', 'GameController@batchAddPlayers');
            //结束比赛
            $api->any('end_game', 'GameController@endGame');
            //设置比赛
            $api->any('set_game_auth', 'GameController@setGameAuth');
            //取消比赛
            $api->any('cancel', 'GameController@cancel');
            //启动比赛
            $api->any('begin', 'GameController@begin');
            //删除球员
            $api->any('del_player', 'GameController@delPlayer');
            //未开始的比赛
            $api->any('not_begin', 'GameController@notBegin');
            //正在进行
            $api->any('underway', 'GameController@underway');
            //球洞信息
            //$api->any('holes', 'GameController@holes');
            //设置分数
            $api->any('set_score', 'GameController@setScore');
            //指定球洞多人分数
            $api->any('hole_scores', 'GameController@holeScores');
            //设置Tee 台
            $api->any('tee', 'GameController@tee');
            //报名比赛
            $api->any('entered_for', 'GameController@enteredFor');
            //退出比赛
            $api->any('quit_game', 'GameController@quitGame');
            //已提交的报名
            $api->any('had_submit', 'GameController@hadSubmit');
            //审核比赛报名
            $api->any('auth_entered', 'GameController@authEntered');
            //围观比赛
            $api->any('look_game', 'GameController@lookGame');
            //比赛围观者
            $api->any('onlookers', 'GameController@onlookers');
            //删除围观者
            $api->any('del_looker', 'GameController@delLooker');
            //比赛码邀请
            $api->any('invite_by_game_code', 'GameController@inviteByGameCode');
            //围观或加入比赛
            $api->any('join_or_refuse', 'GameController@joinOrRefuse');
            //软件内好友
            $api->any('soft_friends', 'GameController@softFriends');
            //添加虚拟球手
            $api->any('add_fictitious', 'GameController@addFictitious');
            //精彩时刻
            $api->any('wonderful_moment', 'GameController@wonderfulMoment');
            //修改人数限制
            $api->any('change_scale_limit', 'GameController@changeScaleLimit');
            //添加虚拟球手
            $api->any('add_fictitious', 'GameController@addFictitious');
            //本场比赛全部球员
            $api->any('get_game_users', 'GameController@getGameUsers');
            //指定球员成绩榜
            $api->any('show_score', 'GameController@showScore');
            //全部球员成绩榜（指定比赛）
            $api->any('all_player_scores', 'GameController@allPlayerScores');
            ///历史打球记录
            $api->any('history_games', 'GameController@historyGames');
            //球员指定比赛的成绩
            $api->any('game_score', 'GameController@gameScore');
            //打过的球场
            $api->any('history_courses', 'GameController@historyCourses');
            //球场比赛统计
            $api->any('course_games', 'GameController@courseGames');
            //月份最佳总杆列表
            $api->any('month_best_par', 'GameController@monthBestPar');
            //历史最佳总杆
            $api->any('history_best_par', 'GameController@historyBestPar');
            //判断用户是否已加入比赛（比赛添加好友时）
            $api->any('is_had_join', 'GameController@isHadJoin');
            //检查当前比赛球员是否正参加其他比赛
            $api->any('check_game', 'GameController@checkGame');
            //邀请加入比赛（发送通知消息）
            $api->any('invite_join_game', 'GameController@inviteJoinGame');
        });


        /*
       |--------------------------------------------------------------
       |  球场会员
       |--------------------------------------------------------------
       */
        $api->group(['prefix' => 'course'], function ($api) {
            //添加球场会员
            $api->any('add_course_user', 'CourseController@addCourseUser')->name('course.add_course_user');
            //球场会员列表
            $api->any('user_courses', 'CourseController@userCourses')->name('course.user_courses');
            //球场列表
            $api->any('course_list', 'CourseController@courseList')->name('course.list');
            //附近球场
            $api->any('nearby', 'CourseController@nearby')->name('course.nearby');
            //设置会员主场
            $api->any('set_main_course', 'CourseController@setMainCourse');
        });


        /*
        |--------------------------------------------------------------
        |  个人中心
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'user'], function ($api) {
            //用户信息
            $api->any('userinfo', 'UserController@userinfo')->name('user.userinfo');
            //修改手机号
            $api->any('update_mobile', 'UserController@updateMobile')->name('user.update_mobile');
            //修改密码
            $api->any('update_password', 'UserController@updatePassword')->name('user.update_password');
            //修改背景图
            $api->any('background', 'UserController@background')->name('user.background');
            //绑定或解绑 手机
            $api->any('bind_mobile', 'UserController@bindMobile')->name('user.bind_mobile');
            //绑定或解绑 邮箱
            $api->any('bind_email', 'UserController@bindEmail')->name('user.bindEmail');
            //绑定或解绑 微信
            $api->any('bind_wx', 'UserController@bindWx')->name('user.bind_wx');
            //绑定或解绑 Facebook
            $api->any('bind_facebook', 'UserController@bindFacebook')->name('user.bind_facebook');
            //绑定或解绑 Apple
            $api->any('bind_apple', 'UserController@bindApple')->name('user.bind_apple');
            //加入移除 黑名单
            $api->any('black', 'UserController@black')->name('user.black');
            //黑名单列表
            $api->any('black_list', 'UserController@blackList')->name('user.black_list');
            //我关注的
            $api->any('my_like_users', 'UserController@myLikeUsers')->name('user.my_like_users');
            //我的粉丝
            $api->any('my_fans', 'UserController@myFans')->name('user.my_fans');
            //关注或取消关注
            $api->any('follow', 'UserController@follow')->name('user.follow');
            //我的好友
            $api->any('my_friends', 'UserController@myFriends')->name('user.my_friends');
            //加删好友
            $api->any('handle_friend', 'UserController@handleFriend')->name('user.handle_friend');
            //修改个人资料
            $api->any('update_user_info/{id}', 'UserController@updateUserInfo')->name('user.update_user_info');
            //账号认证
            $api->any('identify', 'UserController@identify')->name('user.identify');
            //账号认证状态
            $api->any('identify_status', 'UserController@identifyStatus')->name('user.identify_status');
            //问题反馈
            $api->any('feedback', 'UserController@feedback')->name('user.feedback');
            //注销账号
            $api->any('del_account', 'UserController@delAccount')->name('user.del_account');
            //提示音选择
            $api->any('jpush_voice', 'UserController@chooseJpushVoice');

        });

        /*
        |--------------------------------------------------------------
        |  动态相关
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'feeds'], function ($api) {
            //发布动态
            $api->any('release', 'FeedsController@release')->name('feeds.release');
            //动态详情
            //$api->any('detail', 'FeedsController@detail')->name('feeds.detail');
            //动态点赞
            $api->any('like', 'FeedsController@like')->name('feeds.like');
            //动态删除
            $api->any('del', 'FeedsController@del')->name('feeds.del');
            //动态评论
            $api->any('comment', 'FeedsController@comment')->name('feeds.comment');
            //动态评论/回复
            $api->any('commentReply', 'FeedsController@commentReply')->name('feeds.commentReply');
            //动态举报
            $api->any('report', 'FeedsController@report')->name('feeds.report');
            //我的动态
            $api->any('my_feeds', 'FeedsController@myFeeds')->name('feeds.my_feeds');
            //转发  好友列表
            $api->any('get_friends', 'FeedsController@getFriends')->name('feeds.get_friends');
            //动态转发
            $api->any('feeds_forward', 'FeedsController@feedsForward')->name('feeds.feeds_forward');
        });

        /*
        |--------------------------------------------------------------
        |  消息相关
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'message'], function ($api) {
            //消息列表未读数量
            $api->any('index', 'MessageController@index')->name('message.index');
            //获取我的通知列表
            $api->any('get_my_list', 'MessageController@getMyList')->name('message.get_my_list');
            //获取我的通知详细
            $api->any('get_my_list_detail', 'MessageController@getMyListDetail')->name('message.get_my_list_detail');
            //获取点赞消息列表
            $api->any('get_like_list', 'MessageController@getLikeList')->name('message.get_like_list');
            //获取评论/回复列表
            $api->any('get_comment_list', 'MessageController@getCommentList')->name('message.get_comment_list');

            //聊天举报
            $api->any('report', 'MessageController@report')->name('message.report');
        });



        /*
        |--------------------------------------------------------------
        |  好友相关
        |--------------------------------------------------------------
        */
        $api->group(['prefix' => 'friend'], function ($api) {
            //好友列表
            $api->any('friends_list', 'FriendController@friendsList')->name('message.friends_list');
            //搜索用户
            $api->any('search_user', 'FriendController@searchUser')->name('message.search_user');
            //申请添加好友
            $api->any('apply_friend', 'FriendController@applyFriend')->name('message.apply_friend');
            //好友操作  拉黑、删除、取消拉黑
            $api->any('friend_action', 'FriendController@friendAction')->name('message.friend_action');
            //好友通过
            $api->any('friend_pass', 'FriendController@friendPass')->name('message.friend_pass');
        });

       /*
       |--------------------------------------------------------------
       |  群聊相关
       |--------------------------------------------------------------
       */
        $api->group(['prefix' => 'chat_team'], function ($api) {
            //创建群聊
            $api->any('create_group', 'ChatTeamController@createGroup')->name('message.create_group');
            //获取用户群聊列表
            $api->any('get_user_group', 'ChatTeamController@getUserGroup')->name('message.get_user_group');
            //获取群聊详细信息
            $api->any('get_group_info', 'ChatTeamController@getGroupInfo')->name('message.get_group_info');
            //修改群聊名称
            $api->any('update_group_name', 'ChatTeamController@updateGroupName')->name('message.update_group_name');
            //退出群聊 (成员)
            $api->any('quit_group', 'ChatTeamController@quitGroup')->name('message.quit_group');
            //添加群成员
            $api->any('add_group_users', 'ChatTeamController@addGroupUsers')->name('message.add_group_users');
            //删除群成员
            $api->any('del_group_users', 'ChatTeamController@delGroupUsers')->name('message.del_group_users');
            //群主转让
            $api->any('change_group_owner', 'ChatTeamController@changeGroupOwner')->name('message.change_group_owner');
            //解散群
            $api->any('destroy_group', 'ChatTeamController@destroyGroup')->name('message.destroy_group');
        });

    });

    //语言切换
    $api->any('/changeLocale', 'HomeController@language');
    //腾讯IM操作回调
    $api->any('/tencent_notify', 'TencentController@notify')->name('notify');
    // 通用配置
    $api->any('base/config', ['as' => 'base.config', 'uses' => 'BaseConfigController@index', ]);
    // 上传附件
    $api->any('attachment/upload', ['as' => 'attachment.upload', 'uses' => 'AttachmentController@upload',]);
    // 删除附件
    $api->any('attachment/delete/{md5}', [ 'as' => 'attachment.delete','uses' => 'AttachmentController@delete', ]);
    //上传头像
    $api->any('auth/avatar', ['as' => 'auth.avatar', 'uses' => 'AuthController@avatar',]);
    // test
    $api->any('test', [ 'as' => 'test','uses' => 'TestController@index', ]);



});
