mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	fix 修复 管理租户被修改导致无法登录超管账号问题
This commit is contained in:
		@@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.ruoyi.common.core.constant.Constants;
 | 
			
		||||
import com.ruoyi.common.core.constant.GlobalConstants;
 | 
			
		||||
import com.ruoyi.common.core.constant.TenantConstants;
 | 
			
		||||
import com.ruoyi.common.core.domain.dto.RoleDTO;
 | 
			
		||||
import com.ruoyi.common.core.domain.model.LoginUser;
 | 
			
		||||
import com.ruoyi.common.core.domain.model.XcxLoginUser;
 | 
			
		||||
@@ -325,6 +326,9 @@ public class SysLoginService {
 | 
			
		||||
        if (!TenantHelper.isEnable()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        SysTenantVo tenant = tenantService.queryByTenantId(tenantId);
 | 
			
		||||
        if (ObjectUtil.isNull(tenant)) {
 | 
			
		||||
            log.info("登录租户:{} 不存在.", tenantId);
 | 
			
		||||
 
 | 
			
		||||
@@ -104,6 +104,7 @@ public class SysTenantController extends BaseController {
 | 
			
		||||
    @RepeatSubmit()
 | 
			
		||||
    @PutMapping()
 | 
			
		||||
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) {
 | 
			
		||||
        sysTenantService.checkTenantAllowed(bo.getTenantId());
 | 
			
		||||
        if (!sysTenantService.checkCompanyNameUnique(bo)) {
 | 
			
		||||
            throw new ServiceException("修改租户'" + bo.getCompanyName() + "'失败,公司名称已存在");
 | 
			
		||||
        }
 | 
			
		||||
@@ -118,6 +119,7 @@ public class SysTenantController extends BaseController {
 | 
			
		||||
    @Log(title = "租户", businessType = BusinessType.UPDATE)
 | 
			
		||||
    @PutMapping("/changeStatus")
 | 
			
		||||
    public R<Void> changeStatus(@RequestBody SysTenantBo bo) {
 | 
			
		||||
        sysTenantService.checkTenantAllowed(bo.getTenantId());
 | 
			
		||||
        return toAjax(sysTenantService.updateTenantStatus(bo));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,11 @@ public interface ISysTenantService {
 | 
			
		||||
     */
 | 
			
		||||
    int updateTenantStatus(SysTenantBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验租户是否允许操作
 | 
			
		||||
     */
 | 
			
		||||
    void checkTenantAllowed(String tenantId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验并批量删除租户信息
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -271,6 +271,18 @@ public class SysTenantServiceImpl implements ISysTenantService {
 | 
			
		||||
        return baseMapper.updateById(tenant);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验租户是否允许操作
 | 
			
		||||
     *
 | 
			
		||||
     * @param tenantId 租户ID
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkTenantAllowed(String tenantId) {
 | 
			
		||||
        if (ObjectUtil.isNotNull(tenantId) && TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
 | 
			
		||||
            throw new ServiceException("不允许操作管理租户");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除租户
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user