request->only(['username', 'password'], 'post'); // 验证数据 if (empty($params['username']) || empty($params['password'])) { return $this->error(400, '用户名和密码不能为空'); } try { $result = $authService->login($params['username'], $params['password']); return $this->success(200, '登录成功', $result); } catch (\Exception $e) { return $this->error(400, $e->getMessage()); } } /* 退出登录(已完成) */ public function logout() { Session::clear(); return $this->success(200, '退出成功'); } }