优化/api/game/playStart接口
This commit is contained in:
@@ -71,7 +71,7 @@ class GameController extends OpenController
|
||||
{
|
||||
$userId = (int) ($request->player_id ?? 0);
|
||||
$direction = $request->post('direction');
|
||||
if (!in_array($direction, [0, 1], true)) {
|
||||
if (!in_array($direction, ['0', '1'], true)) {
|
||||
return $this->fail('direction 必须为 0 或 1', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class GameController extends OpenController
|
||||
|
||||
try {
|
||||
$logic = new PlayStartLogic();
|
||||
$data = $logic->run($userId, $direction);
|
||||
$data = $logic->run($userId, (int)$direction);
|
||||
return $this->success($data);
|
||||
} catch (ApiException $e) {
|
||||
return $this->fail($e->getMessage(), ReturnCode::BUSINESS_ERROR);
|
||||
|
||||
@@ -39,36 +39,4 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
$this->logger->error($logs);
|
||||
}
|
||||
|
||||
// public function render(Request $request, Throwable $exception): Response
|
||||
// {
|
||||
// $debug = config('app.debug', true);
|
||||
// $code = $exception->getCode();
|
||||
// $httpCode = ($code >= 400 && $code < 600) ? $code : 500;
|
||||
// // 开启 debug 时始终返回真实错误信息,便于排查;未开启时 500 不暴露详情
|
||||
// $message = $exception->getMessage();
|
||||
// if (!$debug && $httpCode === 500) {
|
||||
// $message = 'Server internal error';
|
||||
// }
|
||||
// $json = [
|
||||
// 'code' => $httpCode,
|
||||
// 'message' => $message,
|
||||
// 'type' => 'failed'
|
||||
// ];
|
||||
// if ($debug) {
|
||||
// $json['request_url'] = $request->method() . ' ' . $request->uri();
|
||||
// $json['timestamp'] = date('Y-m-d H:i:s');
|
||||
// $json['client_ip'] = $request->getRealIp();
|
||||
// $json['request_param'] = $request->all();
|
||||
// $json['exception_handle'] = get_class($exception);
|
||||
// $json['exception_info'] = [
|
||||
// 'code' => $exception->getCode(),
|
||||
// 'message' => $exception->getMessage(),
|
||||
// 'file' => $exception->getFile(),
|
||||
// 'line' => $exception->getLine(),
|
||||
// 'trace' => explode("\n", $exception->getTraceAsString())
|
||||
// ];
|
||||
// }
|
||||
// return new Response(200, ['Content-Type' => 'application/json;charset=utf-8'], json_encode($json));
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user