&$value) { $config[$value->name] = $value->value; } if (!$config['open_api']) { $this->response('API is not open yet.', [], 500); } // 是否允许游客上传 $token = $this->request->header('token', $this->param('token')); if (!$this->config['allowed_tourist_upload']) { $token && $this->auth($token); } else { $this->auth($token); } } /** * 上传 */ public function index() { Db::startTrans(); try { $data = (new \app\common\controller\Upload)->exec(); Db::commit(); } catch (Exception $e) { Db::rollback(); return $this->response($e->getMessage(), [], 500); } catch (ErrorException $e) { Db::rollback(); return $this->response($e->getMessage(), [], 500); } catch (\Throwable $e) { Db::rollback(); return $this->response($e->getMessage(), [], 500); } return $this->response('success', $data); } }