package com.qiaoba.module.tenant.runner;

import com.qiaoba.common.base.constants.TenantConstant;
import com.qiaoba.common.base.context.BaseContext;
import com.qiaoba.module.tenant.service.SysTenantService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class SysTenantRunner implements ApplicationRunner {

    private final SysTenantService sysTenantService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        BaseContext.setTenantId(TenantConstant.DEFAULT_TENANT_ID);
        sysTenantService.resetCache();
        BaseContext.clearTenantId();
    }
}
