<?php

use Illuminate\Support\Facades\Route;
use Modules\WechatPlatform\Http\Controllers\CommonController;
use Modules\WechatPlatform\Http\Controllers\WechatSubscribeController;
use Modules\WechatPlatform\Http\KFMessageController;
use Modules\WechatPlatform\Http\Controllers\WechatKeywordsController;

Route::prefix('wechatPlatform')->group(function(){
    Route::prefix('kfMessage')->middleware('roleCheck:optimizer')->group(function(){
        Route::get('list', [KFMessageController::class, 'list']);
        Route::post('add', [KFMessageController::class, 'add']);
        Route::post('stop', [KFMessageController::class, 'stop']);
        Route::post('delete', [KFMessageController::class, 'delete']);
        Route::post('updateContent', [KFMessageController::class, 'updateContent']);
        Route::post('updateGZH', [KFMessageController::class, 'updateGZH']);
    });

    // 关键字列表
    Route::prefix('keyword')->group(function () {
        // 获取关键词设置
        Route::any('getConfig/{miniprogramId}',[WechatKeywordsController::class,'getConfig'])->withoutMiddleware(config('catch.route.middlewares'));
        // 关键词全局设置
        Route::post('setConfig/{miniprogramId}',[WechatKeywordsController::class,'setConfig'])->withoutMiddleware(config('catch.route.middlewares'));
        // 列表
        Route::any("list",[WechatKeywordsController::class,'list']);
        // 添加
        Route::post('add',[WechatKeywordsController::class,'add']);
        // 编辑
        Route::post('edit/{id}',[WechatKeywordsController::class,'edit']);
        // 详情
        Route::any('detail/{id}',[WechatKeywordsController::class,'detail']);
        // 删除
        Route::any('del',[WechatKeywordsController::class,'del']);
        // 配置公众号
        Route::post('allocation/{id}',[WechatKeywordsController::class,'allocation']);
        // 关键字公众号配置选择项
        Route::any("auth_list/{id}",[WechatKeywordsController::class,'authList']);
    });

    // 公共部分
    Route::prefix('common')->group(function (){
        // 获取小程序页面链接
        Route::post('get_play_url',[CommonController::class,'getPlayPageUrl'])->withoutMiddleware(config('catch.route.middlewares'));
    });

    // 被关注回复
    Route::prefix('subscribe')->group(function (){
        // 获取全局设置
        Route::any('getConfig/{miniprogramId}',[WechatSubscribeController::class,'getConfig'])->withoutMiddleware(config('catch.route.middlewares'));
        // 保存全局设置
        Route::post('setConfig/{miniprogramId}',[WechatSubscribeController::class,'setConfig'])->withoutMiddleware(config('catch.route.middlewares'));
        // 列表
        Route::any("list",[WechatSubscribeController::class,'list']);
        // 添加
        Route::post('add',[WechatSubscribeController::class,'add']);
        // 编辑
        Route::post('edit/{id}',[WechatSubscribeController::class,'edit']);
        // 详情
        Route::any('detail/{id}',[WechatSubscribeController::class,'detail']);
        // 删除
        Route::any('del',[WechatSubscribeController::class,'del']);
        // 配置公众号
        Route::post('allocation/{id}',[WechatSubscribeController::class,'allocation']);
        // 公众号配置选择项
        Route::any("auth_list/{id}",[WechatSubscribeController::class,'authList']);
    });

});
