package com.gic.haoban.manage.web.init;

import com.gic.dict.api.dto.GlobalDictMap;
import com.gic.dict.api.service.ManagerDictService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class MyApplicationContextAware implements ApplicationContextAware {
    private final Logger log = LogManager.getLogger(MyApplicationContextAware.class);

    @Autowired
    private ManagerDictService managerDictService;


    @Override
    public void setApplicationContext(ApplicationContext appContext) throws BeansException {
        GlobalDictMap.countyMap = managerDictService.getCountysMap();
        GlobalDictMap.cityMap = managerDictService.getCitysMap();
        GlobalDictMap.provinceMap = managerDictService.getProvincesMap();
        GlobalDictMap.dictMap = managerDictService.getDictList();
        GlobalDictMap.storeCategoryDictMap = managerDictService.getStoreCategoryDictList();
        log.info("数据字典放入缓存");

    }

}
