service = UserService::getInstance(); $this->insertField = [ 'account', 'nick_name', 'password', 'role_id' ]; $this->updateField = [ 'id', 'account', 'nick_name', 'role_id' ]; $this->notRequest = ['qr_code', 'avatar', 'email', 'status']; } /** * 修改密码 * @Method POST * @return JsonResponse * @throws Exception */ public function changePassword(): JsonResponse { $this->insertField = ['old_password', 'new_password', 'confirm_password']; $params = $this->checkRequiredFields(request()->post()); if ($params['old_password'] === $params['new_password']) { return jerr('新密码不能与旧密码相同'); } elseif ($params['new_password'] !== $params['confirm_password']) { return jerr('新密码与确认密码不一致'); } return jok( $this->service->changePassword($params['old_password'], $params['new_password']), '重置密码成功' ); } /** * 重置密码 * @Method POST * @return JsonResponse * @throws Exception */ public function resetPassword(): JsonResponse { $this->insertField = ['id', 'password', 'new_password']; $params = $this->checkRequiredFields(request()->post()); return jok( $this->service->resetPassword($params['id'], $params['password'], $params['new_password']), '重置密码成功' ); } /** * 获取当前用户信息 * @Method GET * @return JsonResponse * @throws Exception */ public function myInfo(): JsonResponse { return jok( $this->service->myInfo(), '获取成功' ); } /** * 获取当前用户信息 * @Method GET * @return JsonResponse * @throws Exception */ public function userStats(): JsonResponse { return jok( $this->service->userStats(), '获取成功' ); } }