<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\System\Api\Dictionary;

// 公开路由（不需要认证）
Route::prefix('system')->group(function () {
    // 获取所有系统配置
    Route::get('/setting', [\App\Http\Controllers\System\Api\Config::class, 'all']);
    Route::get('/setting/group', [\App\Http\Controllers\System\Api\Config::class, 'getByGroup']);
    Route::get('/setting/key', [\App\Http\Controllers\System\Api\Config::class, 'getByKey']);

    // 获取所有字典数据（用于前端缓存）
    Route::get('/dictionary', [Dictionary::class, 'all']);
    Route::get('/dictionary/code', [Dictionary::class, 'getByCode']);
    Route::get('/dictionary/{id}', [Dictionary::class, 'show']);

    // 获取城市数据
    Route::get('/city/tree', [\App\Http\Controllers\System\Api\City::class, 'tree']);
    Route::get('/city/provinces', [\App\Http\Controllers\System\Api\City::class, 'provinces']);
    Route::get('/city/{provinceId}/cities', [\App\Http\Controllers\System\Api\City::class, 'cities']);
    Route::get('/city/{cityId}/districts', [\App\Http\Controllers\System\Api\City::class, 'districts']);
    Route::get('/city/{id}', [\App\Http\Controllers\System\Api\City::class, 'show']);

    // 文件上传
    Route::post('/upload', [\App\Http\Controllers\System\Api\Upload::class, 'upload']);
});
