feat: 新增赔率版本和玩法配置版本的删除接口,支持删除草稿版本
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Config;
|
||||
|
||||
use App\Models\AdminUser;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PlayConfigVersion;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Lottery\ConfigVersionStatus;
|
||||
use App\Services\Config\PlayConfigStreamService;
|
||||
|
||||
/** DELETE /api/v1/admin/config/play-versions/{id} */
|
||||
final class PlayConfigVersionDestroyController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, int $id, PlayConfigStreamService $service): JsonResponse
|
||||
{
|
||||
/** @var AdminUser $admin */
|
||||
$admin = $request->lotteryAdmin();
|
||||
|
||||
/** @var PlayConfigVersion $version */
|
||||
$version = PlayConfigVersion::query()->whereKey($id)->firstOrFail();
|
||||
|
||||
if ($version->status === ConfigVersionStatus::Active->value) {
|
||||
return ApiResponse::error(
|
||||
'cannot delete active config version',
|
||||
ErrorCode::ConfigVersionCannotDeleteActive->value,
|
||||
null,
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
$service->deleteVersion($version, $admin, $request);
|
||||
|
||||
return ApiResponse::success(['deleted' => true]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user