mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	fix 修复 多租户相同账号登录失败问题
This commit is contained in:
		@@ -216,6 +216,9 @@ public class SysLoginService {
 | 
			
		||||
            log.info("登录用户:{} 已被停用.", username);
 | 
			
		||||
            throw new UserException("user.blocked", username);
 | 
			
		||||
        }
 | 
			
		||||
        if (TenantHelper.isEnable()) {
 | 
			
		||||
            return userMapper.selectTenantUserByUserName(username, tenantId);
 | 
			
		||||
        }
 | 
			
		||||
        return userMapper.selectUserByUserName(username);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -231,6 +234,9 @@ public class SysLoginService {
 | 
			
		||||
            log.info("登录用户:{} 已被停用.", phonenumber);
 | 
			
		||||
            throw new UserException("user.blocked", phonenumber);
 | 
			
		||||
        }
 | 
			
		||||
        if (TenantHelper.isEnable()) {
 | 
			
		||||
            return userMapper.selectTenantUserByPhonenumber(phonenumber, tenantId);
 | 
			
		||||
        }
 | 
			
		||||
        return userMapper.selectUserByPhonenumber(phonenumber);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,13 @@
 | 
			
		||||
package com.ruoyi.system.mapper;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.ruoyi.common.mybatis.annotation.DataColumn;
 | 
			
		||||
import com.ruoyi.common.mybatis.annotation.DataPermission;
 | 
			
		||||
import com.ruoyi.system.domain.SysUser;
 | 
			
		||||
import com.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
 | 
			
		||||
import com.ruoyi.system.domain.SysUser;
 | 
			
		||||
import com.ruoyi.system.domain.vo.SysUserVo;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
@@ -77,6 +78,26 @@ public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, Sy
 | 
			
		||||
     */
 | 
			
		||||
    SysUserVo selectUserByPhonenumber(String phonenumber);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过用户名查询用户(不走租户插件)
 | 
			
		||||
     *
 | 
			
		||||
     * @param userName 用户名
 | 
			
		||||
     * @param tenantId 租户id
 | 
			
		||||
     * @return 用户对象信息
 | 
			
		||||
     */
 | 
			
		||||
    @InterceptorIgnore(tenantLine = "true")
 | 
			
		||||
    SysUserVo selectTenantUserByUserName(String userName, String tenantId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过手机号查询用户(不走租户插件)
 | 
			
		||||
     *
 | 
			
		||||
     * @param phonenumber 手机号
 | 
			
		||||
     * @param tenantId    租户id
 | 
			
		||||
     * @return 用户对象信息
 | 
			
		||||
     */
 | 
			
		||||
    @InterceptorIgnore(tenantLine = "true")
 | 
			
		||||
    SysUserVo selectTenantUserByPhonenumber(String phonenumber, String tenantId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过用户ID查询用户
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -102,6 +102,16 @@
 | 
			
		||||
        where u.del_flag = '0' and u.phonenumber = #{phonenumber}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectTenantUserByUserName" parameterType="String" resultMap="SysUserResult">
 | 
			
		||||
        <include refid="selectUserVo"/>
 | 
			
		||||
        where u.del_flag = '0' and u.user_name = #{userName} and u.tenant_id = #{tenantId}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectTenantUserByPhonenumber" parameterType="String" resultMap="SysUserResult">
 | 
			
		||||
        <include refid="selectUserVo"/>
 | 
			
		||||
        where u.del_flag = '0' and u.phonenumber = #{phonenumber} and u.tenant_id = #{tenantId}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
 | 
			
		||||
        <include refid="selectUserVo"/>
 | 
			
		||||
        where u.del_flag = '0' and u.user_id = #{userId}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user