多租户代码框架

This commit is contained in:
zhonghua1
2025-12-16 23:34:07 +08:00
parent 5453026309
commit 406f7d692b
36 changed files with 956 additions and 39 deletions

View File

@@ -1,17 +1,40 @@
package com.rj.mapper.sys;
import com.rj.entity.sys.User;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rj.entity.sys.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 用户表 Mapper 接口
* </p>
*
* <p>
* 说明:
* - 登录认证/根据 token 查询用户时,需要跨租户查询用户信息,因此这些方法通过
* {@link InterceptorIgnore} 显式跳过多租户拦截器,不在 SQL 中追加 tenant_id 条件。
* - 其他通过 MyBatis-Plus 内置 CRUD 产生的 SQL 仍然会自动带上 tenant_id 条件。
* </p>
*
* @author 系统生成
* @since 2025-08-07
*/
public interface UserMapper extends BaseMapper<User> {
/**
* 根据用户名查询用户(登录用),不走多租户拦截器。
*/
@InterceptorIgnore(tenantLine = "true")
@Select("SELECT * FROM user WHERE user_name = #{userName} LIMIT 1")
User selectByUserNameIgnoreTenant(@Param("userName") String userName);
/**
* 根据 token 查询用户token 验证、获取当前用户信息),不走多租户拦截器。
*/
@InterceptorIgnore(tenantLine = "true")
@Select("SELECT * FROM user WHERE token = #{token} LIMIT 1")
User selectByTokenIgnoreTenant(@Param("token") String token);
}