'require', 'password|内容' => 'require', ]; Until::check($rule, $input); $info = (new AdminModel())::where(['account' => $input['username'], 'passwd' => $input['password']])->find(); if (empty($info)) { throw new ApiException('账号或密码错误'); } $tokenService = new \app\common\until\Token(); $token = $tokenService->getToken($info['id']); Until::output(['token' => $token,'id' => $info['id']]); } public function logout() { Until::output(['name' => 'tom']); } /** * 显示指定的资源 * * @return \think\Response */ public function read() { $info = (new AdminModel())::where(['id' => $this->userId])->field('account,avatar')->find(); if (empty($info)) { throw new ApiException('无此用户'); } Until::output(['username' => $info['account'],'avatar' => $info['avatar']]); } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } }