package com.ruoyi.framework.config;

import org.springframework.web.servlet.HandlerInterceptor;

//@Component
//@RequiredArgsConstructor
public class TenantInterceptor implements HandlerInterceptor {

//    private final TenantDataSourceService tenantDataSourceService;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//        // 从请求头、JWT、Session 等获取租户ID
//        String tenantId = request.getHeader("X-Tenant-Id");
//        if (tenantId == null || tenantId.isEmpty()) {
//            throw new RuntimeException("缺少租户标识");
//        }
//
//        TenantContext.setTenantId(tenantId);
//        // 通知 dynamic-datasource 切换数据源
//        tenantDataSourceService.switchToTenant(tenantId);
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
//        // 清理资源
//        tenantDataSourceService.clearDataSource();
//        TenantContext.clear();
//    }
}
