jeecgboot/JeecgBoot · error · JeecgBootException

该用户不存在,无法删除!

Error message

该用户不存在,无法删除!

What it means

verifyCreateTimeAndPassword throws when the sysUser argument is null. This is a defensive null-check at the top of the private validation helper invoked by deleteUserByPassword. In practice the caller already loaded the user (step3), so reaching here with null signals the user was deleted between the load and the verify call, or a programming error.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java:937

        
        // 代码逻辑说明: 【QQYUN-11839】删除用户,需要输入被删除用户的密码,这逻辑对吗?不应该是管理员的密码吗---
        this.verifyCreateTimeAndPassword(sysUserData,password);

        //step5 逻辑删除用户
        userService.deleteUser(userId);
        //step6 真实删除用户
        userService.removeLogicDeleted(Collections.singletonList(userId));
    }

    /**
     * 验证创建时间和密码
     * 
     * @param sysUser
     * @param password
     */
    private void verifyCreateTimeAndPassword(SysUser sysUser,String password) {
        if(null == sysUser){
            throw new JeecgBootException("该用户不存在,无法删除!");
        }
        //step1 验证创建时间
        //当前登录用户
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        Date createTime = sysUser.getCreateTime();
        boolean sameDay = DateUtils.isSameDay(createTime, new Date());
        if(!sameDay){
            throw new JeecgBootException("用户不是今天创建的,无法删除!");
        }
        //step2 验证密码
        //获取admin的用户
        SysUser adminUser = userService.getById(user.getId());
        String passwordEncode = PasswordUtil.encrypt(adminUser.getUsername(), password, adminUser.getSalt());
        if(!passwordEncode.equals(adminUser.getPassword())){
            throw new JeecgBootException("您输入的密码不正确,无法删除该用户!");
        }
    }

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Check that the user exists immediately before deletion and handle the not-found case gracefully.
  2. If caused by concurrency, re-fetch and skip if already deleted (idempotent delete).
  3. Validate the userId is correct and the user is not logically deleted before entering the flow.
  4. Log the userId and trace concurrent deletion requests if this recurs.

Example fix

// before
this.verifyCreateTimeAndPassword(sysUserData, password);

// after
if (sysUserData == null) {
    log.warn("用户 {} 不存在或已被删除,跳过删除流程", userId);
    return; // or throw a controller-friendly error
}
this.verifyCreateTimeAndPassword(sysUserData, password);
Defensive patterns

Strategy: validation

Validate before calling

SysUser data = userService.getById(userId);
if (data == null) {
    return Result.error("用户不存在或已被删除");
}

Prevention

When it happens

Trigger: deleteUserByPassword calls verifyCreateTimeAndPassword(sysUserData, password) where sysUserData is null — i.e. userService.getById(userId) returned null because the user no longer exists (race with another deletion, or the id is wrong).

Common situations: Concurrent deletion by another admin/process removed the user between steps; the userId was invalid or already purged; logic-delete flag made getById return null; refactored caller stopped populating the user object.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/36345354eba2352e. Report an issue: GitHub.