package com.yeejoin.amos.boot.module.statistcs.biz.init;

import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.AQZSDPStatisticsServiceImpl;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.StCommonServiceImpl;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;

/**
 * @author Administrator
 */
@Component
public class DataInitAfterRuning implements ApplicationRunner {


    private StCommonServiceImpl stCommonService;

    private AmosRequestContext amosRequestContext;

    public DataInitAfterRuning(StCommonServiceImpl stCommonService, AmosRequestContext amosRequestContext) {
        this.stCommonService = stCommonService;
        this.amosRequestContext = amosRequestContext;
    }

    @Override
    public void run(ApplicationArguments args) {
        // 初始化数据到内存
        RequestContext.setAppKey(amosRequestContext.getAppKey());
        RequestContext.setProduct(amosRequestContext.getProduct());
        RequestContext.setToken(amosRequestContext.getToken());
        stCommonService.init();
    }
}
