<?php

use Webman\Route;

Route::group('/core', function () {

    Route::get('/install', [plugin\saiadmin\app\controller\InstallController::class, 'index']);
    Route::post('/install/install', [plugin\saiadmin\app\controller\InstallController::class, 'install']);

    Route::get('/captcha', [plugin\saiadmin\app\controller\LoginController::class, 'captcha']);
    Route::post('/login', [plugin\saiadmin\app\controller\LoginController::class, 'login']);

    Route::get('/system/user', [plugin\saiadmin\app\controller\SystemController::class, 'userInfo']);
    Route::get("/system/dictAll", [plugin\saiadmin\app\controller\SystemController::class, 'dictAll']);
    Route::get('/system/menu', [plugin\saiadmin\app\controller\SystemController::class, 'menu']);

    Route::get('/system/statistics', [plugin\saiadmin\app\controller\SystemController::class, 'statistics']);
    Route::get('/system/loginChart', [plugin\saiadmin\app\controller\SystemController::class, 'loginChart']);
    Route::get('/system/loginBarChart', [plugin\saiadmin\app\controller\SystemController::class, 'loginBarChart']);
    // 大富翁工作台统计（覆盖默认统计）
    Route::get('/dice/dashboard/statistics', [\app\dice\controller\DiceDashboardController::class, 'statistics']);
    Route::get('/dice/dashboard/rechargeChart', [\app\dice\controller\DiceDashboardController::class, 'rechargeChart']);
    Route::get('/dice/dashboard/rechargeBarChart', [\app\dice\controller\DiceDashboardController::class, 'rechargeBarChart']);
    Route::get('/dice/dashboard/walletRecordList', [\app\dice\controller\DiceDashboardController::class, 'walletRecordList']);
    Route::get('/dice/dashboard/newPlayerList', [\app\dice\controller\DiceDashboardController::class, 'newPlayerList']);
    Route::get('/dice/dashboard/playRecordList', [\app\dice\controller\DiceDashboardController::class, 'playRecordList']);
    Route::get('/system/clearAllCache', [plugin\saiadmin\app\controller\SystemController::class, 'clearAllCache']);

    Route::get("/system/getResourceCategory", [plugin\saiadmin\app\controller\SystemController::class, 'getResourceCategory']);
    Route::get("/system/getResourceList", [plugin\saiadmin\app\controller\SystemController::class, 'getResourceList']);
    Route::post("/system/saveNetworkImage", [plugin\saiadmin\app\controller\SystemController::class, 'saveNetworkImage']);
    Route::post("/system/uploadImage", [plugin\saiadmin\app\controller\SystemController::class, 'uploadImage']);
    Route::post("/system/uploadFile", [plugin\saiadmin\app\controller\SystemController::class, 'uploadFile']);
    Route::post("/system/chunkUpload", [plugin\saiadmin\app\controller\SystemController::class, 'chunkUpload']);
    Route::get("/system/getUserList", [plugin\saiadmin\app\controller\SystemController::class, 'getUserList']);
    Route::get("/system/getLoginLogList", [plugin\saiadmin\app\controller\SystemController::class, 'getLoginLogList']);
    Route::get("/system/getOperationLogList", [plugin\saiadmin\app\controller\SystemController::class, 'getOperationLogList']);

    // 用户管理
    fastRoute("user", \plugin\saiadmin\app\controller\system\SystemUserController::class);
    Route::post("/user/updateInfo", [\plugin\saiadmin\app\controller\system\SystemUserController::class, 'updateInfo']);
    Route::post("/user/modifyPassword", [\plugin\saiadmin\app\controller\system\SystemUserController::class, 'modifyPassword']);
    Route::post("/user/clearCache", [\plugin\saiadmin\app\controller\system\SystemUserController::class, 'clearCache']);
    Route::post("/user/initUserPassword", [\plugin\saiadmin\app\controller\system\SystemUserController::class, 'initUserPassword']);
    Route::post("/user/setHomePage", [\plugin\saiadmin\app\controller\system\SystemUserController::class, 'setHomePage']);

    // 角色管理
    fastRoute('role', \plugin\saiadmin\app\controller\system\SystemRoleController::class);
    Route::get("/role/accessRole", [\plugin\saiadmin\app\controller\system\SystemRoleController::class, 'accessRole']);
    Route::get("/role/getMenuByRole", [\plugin\saiadmin\app\controller\system\SystemRoleController::class, 'getMenuByRole']);
    Route::post("/role/menuPermission", [\plugin\saiadmin\app\controller\system\SystemRoleController::class, 'menuPermission']);

    // 渠道管理
    fastRoute("dept", \plugin\saiadmin\app\controller\system\SystemDeptController::class);
    Route::get("/dept/accessDept", [\plugin\saiadmin\app\controller\system\SystemDeptController::class, 'accessDept']);
    Route::get("/dept/destroyPreview", [\plugin\saiadmin\app\controller\system\SystemDeptController::class, 'destroyPreview']);
    Route::post("/dept/syncChannelConfigs", [\plugin\saiadmin\app\controller\system\SystemDeptController::class, 'syncChannelConfigs']);

    // 菜单管理
    fastRoute('menu', \plugin\saiadmin\app\controller\system\SystemMenuController::class);
    Route::get("/menu/accessMenu", [\plugin\saiadmin\app\controller\system\SystemMenuController::class, 'accessMenu']);
    // 字典类型管理
    fastRoute('dictType', \plugin\saiadmin\app\controller\system\SystemDictTypeController::class);
    // 字典数据管理
    fastRoute('dictData', \plugin\saiadmin\app\controller\system\SystemDictDataController::class);
    // 附件管理
    fastRoute('attachment', \plugin\saiadmin\app\controller\system\SystemAttachmentController::class);
    Route::post("/attachment/move", [\plugin\saiadmin\app\controller\system\SystemAttachmentController::class, 'move']);
    // 附件分类
    fastRoute('category', \plugin\saiadmin\app\controller\system\SystemCategoryController::class);
    // 系统设置
    fastRoute('configGroup', \plugin\saiadmin\app\controller\system\SystemConfigGroupController::class);
    Route::post("/configGroup/email", [\plugin\saiadmin\app\controller\system\SystemConfigGroupController::class, 'email']);
    fastRoute('config', \plugin\saiadmin\app\controller\system\SystemConfigController::class);
    Route::post("/config/batchUpdate", [\plugin\saiadmin\app\controller\system\SystemConfigController::class, 'batchUpdate']);

    // 日志管理
    Route::get("/logs/getLoginLogPageList", [\plugin\saiadmin\app\controller\system\SystemLogController::class, 'getLoginLogPageList']);
    Route::delete("/logs/deleteLoginLog", [\plugin\saiadmin\app\controller\system\SystemLogController::class, 'deleteLoginLog']);
    Route::get("/logs/getOperLogPageList", [\plugin\saiadmin\app\controller\system\SystemLogController::class, 'getOperLogPageList']);
    Route::delete("/logs/deleteOperLog", [\plugin\saiadmin\app\controller\system\SystemLogController::class, 'deleteOperLog']);
    fastRoute("email", \plugin\saiadmin\app\controller\system\SystemMailController::class);

    // 后台操作指南
    Route::get("/adminGuide/read", [\plugin\saiadmin\app\controller\system\SystemAdminGuideController::class, 'read']);
    Route::post("/adminGuide/save", [\plugin\saiadmin\app\controller\system\SystemAdminGuideController::class, 'save']);

    // 服务管理
    Route::get("/server/monitor", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'monitor']);
    Route::get("/server/cache", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'cache']);
    Route::post("/server/clear", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'clear']);

    // 大富翁 Dice 模块
    fastRoute('dice/config/DiceConfig', \app\dice\controller\config\DiceConfigController::class);
    fastRoute('dice/player/DicePlayer', \app\dice\controller\player\DicePlayerController::class);
    Route::put('/dice/player/DicePlayer/updateStatus', [\app\dice\controller\player\DicePlayerController::class, 'updateStatus']);
    Route::get('/dice/player/DicePlayer/getLotteryConfigOptions', [\app\dice\controller\player\DicePlayerController::class, 'getLotteryConfigOptions']);
    Route::get('/dice/player/DicePlayer/getSystemUserOptions', [\app\dice\controller\player\DicePlayerController::class, 'getSystemUserOptions']);
    Route::get('/dice/player/DicePlayer/getSystemUserTreeOptions', [\app\dice\controller\player\DicePlayerController::class, 'getSystemUserTreeOptions']);
    Route::get('/dice/player/DicePlayer/getGameUrl', [\app\dice\controller\player\DicePlayerController::class, 'getGameUrl']);
    fastRoute('dice/play_record/DicePlayRecord', \app\dice\controller\play_record\DicePlayRecordController::class);
    Route::get('/dice/play_record/DicePlayRecord/getPlayerOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getPlayerOptions']);
    Route::get('/dice/play_record/DicePlayRecord/getLotteryConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getLotteryConfigOptions']);
    fastRoute('dice/player_wallet_record/DicePlayerWalletRecord', \app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class);
    Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerOptions']);
    Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerWalletBefore']);
    Route::post('/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'adminOperate']);
    fastRoute('dice/player_ticket_record/DicePlayerTicketRecord', \app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class);
    Route::get('/dice/player_ticket_record/DicePlayerTicketRecord/getPlayerOptions', [\app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class, 'getPlayerOptions']);
    fastRoute('dice/reward/DiceReward', \app\dice\controller\reward\DiceRewardController::class);
    Route::get('/dice/reward/DiceReward/weightRatioList', [\app\dice\controller\reward\DiceRewardController::class, 'weightRatioList']);
    Route::get('/dice/reward/DiceReward/weightRatioListWithDirection', [\app\dice\controller\reward\DiceRewardController::class, 'weightRatioListWithDirection']);
    Route::post('/dice/reward/DiceReward/batchUpdateWeights', [\app\dice\controller\reward\DiceRewardController::class, 'batchUpdateWeights']);
    Route::post('/dice/reward/DiceReward/batchUpdateWeightsByDirection', [\app\dice\controller\reward\DiceRewardController::class, 'batchUpdateWeightsByDirection']);
    Route::post('/dice/reward/DiceReward/startWeightTest', [\app\dice\controller\reward\DiceRewardController::class, 'startWeightTest']);
    Route::get('/dice/reward/DiceReward/getTestProgress', [\app\dice\controller\reward\DiceRewardController::class, 'getTestProgress']);
    fastRoute('dice/reward_config/DiceRewardConfig', \app\dice\controller\reward_config\DiceRewardConfigController::class);
    Route::get('/dice/reward_config/DiceRewardConfig/weightRatioList', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'weightRatioList']);
    Route::post('/dice/reward_config/DiceRewardConfig/batchUpdateWeights', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'batchUpdateWeights']);
    Route::post('/dice/reward_config/DiceRewardConfig/saveBigwinWeightsByGrid', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'saveBigwinWeightsByGrid']);
    Route::post('/dice/reward_config/DiceRewardConfig/batchUpdate', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'batchUpdate']);
    Route::post('/dice/reward_config/DiceRewardConfig/generateIndexByRules', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'generateIndexByRules']);
    Route::post('/dice/reward_config/DiceRewardConfig/createRewardReference', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'createRewardReference']);
    Route::post('/dice/reward_config/DiceRewardConfig/createRewardReferencePreview', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'createRewardReferencePreview']);
    Route::post('/dice/reward_config/DiceRewardConfig/runWeightTest', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'runWeightTest']);
    fastRoute('dice/game/DiceGame', \app\dice\controller\game\DiceGameController::class);
    fastRoute('dice/ante_config/DiceAnteConfig', \app\dice\controller\ante_config\DiceAnteConfigController::class);
    Route::get('/dice/ante_config/DiceAnteConfig/getOptions', [\app\dice\controller\ante_config\DiceAnteConfigController::class, 'getOptions']);
    fastRoute('dice/lottery_pool_config/DiceLotteryPoolConfig', \app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class);
    Route::get('/dice/lottery_pool_config/DiceLotteryPoolConfig/getOptions', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'getOptions']);
    Route::get('/dice/lottery_pool_config/DiceLotteryPoolConfig/getCurrentPool', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'getCurrentPool']);
    Route::post('/dice/lottery_pool_config/DiceLotteryPoolConfig/updateCurrentPool', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'updateCurrentPool']);
    Route::post('/dice/lottery_pool_config/DiceLotteryPoolConfig/resetProfitAmount', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'resetProfitAmount']);
    fastRoute('dice/reward_config_record/DiceRewardConfigRecord', \app\dice\controller\reward_config_record\DiceRewardConfigRecordController::class);
    Route::post('/dice/reward_config_record/DiceRewardConfigRecord/importFromRecord', [\app\dice\controller\reward_config_record\DiceRewardConfigRecordController::class, 'importFromRecord']);
    fastRoute('dice/play_record_test/DicePlayRecordTest', \app\dice\controller\play_record_test\DicePlayRecordTestController::class);
    Route::post('/dice/play_record_test/DicePlayRecordTest/clearAll', [\app\dice\controller\play_record_test\DicePlayRecordTestController::class, 'clearAll']);

    // 数据表维护
    Route::get("/database/index", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'index']);
    Route::get("/database/recycle", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'recycle']);
    Route::delete("/database/delete", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'delete']);
    Route::post("/database/recovery", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'recovery']);
    Route::get("/database/dataSource", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'source']);
    Route::get("/database/detailed", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'detailed']);
    Route::post("/database/optimize", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'optimize']);
    Route::post("/database/fragment", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'fragment']);

});

Route::group('/tool', function () {

    // 定时任务
    fastRoute('crontab', \plugin\saiadmin\app\controller\tool\CrontabController::class);
    Route::post("/crontab/run", [\plugin\saiadmin\app\controller\tool\CrontabController::class, 'run']);
    Route::get("/crontab/logPageList", [\plugin\saiadmin\app\controller\tool\CrontabController::class, 'logPageList']);
    Route::delete('/crontab/deleteCrontabLog', [\plugin\saiadmin\app\controller\tool\CrontabController::class, 'deleteCrontabLog']);

    // 代码生成
    fastRoute('code', \plugin\saiadmin\app\controller\tool\GenerateTablesController::class);
    Route::get("/code/getTableColumns", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'getTableColumns']);
    Route::get("/code/preview", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'preview']);
    Route::post("/code/loadTable", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'loadTable']);
    Route::post("/code/generate", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'generate']);
    Route::post("/code/generateFile", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'generateFile']);
    Route::post("/code/sync", [\plugin\saiadmin\app\controller\tool\GenerateTablesController::class, 'sync']);
});

Route::disableDefaultRoute('saiadmin');