getNormalUserById($this->userId); $resultUser = [ 'id' => $this->userId, 'username' => $user['username'], 'sex' => $user['sex'], ]; return show(config('status.success'), 'OK', $resultUser); } public function update() { $username = $this->request->param('username', '', 'trim'); $sex = input('param.sex', 0, 'intval'); // $data = [ 'username' => $username, 'sex' => $sex, ]; $validate = (new UserValidate)->scene('update_user'); if (!$validate->check($data)) { return show(config('status.error'), $validate->getError()); } $user = (new UserBusiness())->update($this->userId, $data); if (!$user) { return show(config('status.error'), '更新失败'); } // 如果用户名被修改,Redis里面的数据也需要同步一下 // todo return show(1, 'OK'); } }