package com.mortals.xhx.daemon.applicationservice;

import com.alibaba.fastjson.JSON;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.ThreadPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
@Slf4j
public class StartService implements IApplicationStartedService {


    @Override
    public void start() {
        ThreadPool.getInstance().init(10);

        //测试 多个返回

        int i = 0;

        List<String> list = query(i);

        log.info(JSON.toJSONString(list));


    }

    public List<String> query(int i) {
        i++;

        if (i > 5) {

            return new ArrayList<>();

        }


        return query(i);


    }


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

    }

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


}
