package com.blueland.webapp;

import com.blueland.service.SysRedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @auther xcy
 * @create 2022-06-15 10:55
 * 启动加载类
 */
@Component
public class MyApplicationRunner implements ApplicationRunner {

    private static final Logger log = LoggerFactory.getLogger(MyApplicationRunner.class);

    @Autowired
    SysRedisService sysRedisService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
            sysRedisService.initDict();
            log.info("字典缓存加载完成");
            sysRedisService.initRole();
            log.info("角色缓存加载完成");
            sysRedisService.initMenuId();
            log.info("菜单id缓存加载完成");
            sysRedisService.initMenu();
            log.info("菜单缓存加载完成");
            sysRedisService.initDept();
            log.info("部门缓存加载完成");
            sysRedisService.initStaff();
            log.info("员工缓存加载完成");
        } catch (Exception e) {
            System.out.println(e);
        }
    }

}
