适配多租户
This commit is contained in:
@@ -5,6 +5,7 @@ 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;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,7 +19,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
* - 其他通过 MyBatis-Plus 内置 CRUD 产生的 SQL 仍然会自动带上 tenant_id 条件。
|
||||
* </p>
|
||||
*
|
||||
* @author 系统生成
|
||||
* @author
|
||||
* @since 2025-08-07
|
||||
*/
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
@@ -36,5 +37,13 @@ public interface UserMapper extends BaseMapper<User> {
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Select("SELECT * FROM user WHERE token = #{token} LIMIT 1")
|
||||
User selectByTokenIgnoreTenant(@Param("token") String token);
|
||||
|
||||
/**
|
||||
* 根据用户ID更新用户信息(登录时更新token用),不走多租户拦截器。
|
||||
* 此方法用于登录场景,需要跨租户更新用户token,因此不添加 tenant_id 条件。
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Update("UPDATE user SET token = #{user.token} WHERE user_id = #{user.userId}")
|
||||
int updateByIdIgnoreTenant(@Param("user") User user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user