feat: 添加新的错误码以支持配置版本管理,更新彩票配置以启用手动审核,增强 API 路由以支持玩法和赔率版本化管理
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Play;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Services\Config\EffectivePlayCatalogService;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* GET /api/v1/play/effective — 当前生效的玩法目录 + 赔率 + 封顶(公开,无需登录)。
|
||||
*/
|
||||
final class PlayEffectiveCatalogController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, EffectivePlayCatalogService $catalog): JsonResponse
|
||||
{
|
||||
$currency = $request->query('currency');
|
||||
$c = is_string($currency) && $currency !== '' ? $currency : null;
|
||||
|
||||
try {
|
||||
return ApiResponse::success($catalog->build($c));
|
||||
} catch (ModelNotFoundException) {
|
||||
return ApiResponse::error(
|
||||
'effective config not initialized',
|
||||
ErrorCode::NotFound->value,
|
||||
null,
|
||||
404,
|
||||
);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
if ($e->getMessage() === 'currency') {
|
||||
return ApiResponse::error(
|
||||
'invalid or disabled currency',
|
||||
ErrorCode::ConfigCurrencyInvalid->value,
|
||||
null,
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user