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