package com.mortals.xhx.daemon.applicationservice;

import com.mortals.framework.service.ICacheService;
import com.mortals.framework.springcloud.config.web.BaseWebMvcConfigurer;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import com.mortals.xhx.module.site.service.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import com.mortals.framework.springcloud.service.IApplicationStartedService;

import java.util.List;

/**
 * 应用级服务，在应用启动后、停止过程中调用
 * 应用已经完成启动完成，才调用该服务
 * 应用场景：
 * 1、应用任务，应用启动后定时或间隔执行的任务
 * 2、Socket服务端
 *
 * @author GM
 * @date 2020年7月15日
 */
@Component
public class DemoStartedService implements IApplicationStartedService {

    private static Log logger = LogFactory.getLog(DemoStartedService.class);

    @Autowired
    private SiteService siteService;
    @Autowired
    private ICacheService cacheService;

    @Override
    public void start() {
        logger.info("开始服务..[配置已加载完成，并且所有框架都已经初始化]");
        List<SiteTreeSelect> siteTreeSelects = siteService.siteTree(null);
        siteService.setSiteTree(siteTreeSelects, null);

    }

    @Override
    public void stop() {
        logger.info("停止服务..");
    }

    @Override
    public int getOrder() {
        return 10;
    }

}
