package com.gyee.frame.common.spring;

import com.gyee.frame.model.auto.RMConfig;
import com.gyee.frame.model.auto.RMConfigExample;
import com.gyee.frame.service.RMConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 服务启动执行
 */
@Component
public class InitialRunner implements CommandLineRunner {


    @Autowired
    private RMConfigService rMConfigService;
    //RMConfig

    public static Map<String, RMConfig> rmcmap = new HashMap<String, RMConfig>();
    @Override
    public void run(String... args) throws Exception {
        System.out.println(">>>>>>>>>>>>>>>服务启动执行，换成测点关联数据 <<<<<<<<<<<<<");

        RMConfigExample example=new RMConfigExample();

        example.setOrderByClause("id ASC");

        example.createCriteria().getAllCriteria();

        List<RMConfig> list= rMConfigService.selectByExample(example);

        if(!list.isEmpty())
        {
            for(RMConfig rm:list)
            {
                rmcmap.put(rm.getId(),rm);
            }
        }
    }

}
