package cn.com.oa.common.constant;

import cn.com.oa.model.Company;
import cn.com.oa.model.Group;
import cn.com.oa.service.ICompanyService;
import cn.com.oa.service.IGroupService;
import cn.com.v2.util.DataSourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

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

@Component
public class DataLoaderRunner implements CommandLineRunner {
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IGroupService groupService;

    @Override
    public void run(String... args) throws Exception {
        DataSourceUtil.setDB("oa");
        Company company = companyService.getCompany();
        Group defaultGroup = groupService.getDefaultGroup();
        Map map = new HashMap<>();
        map.put("company",company);
        map.put("defaultGroup",defaultGroup);
        // 使用DataService来存储数据
        DataService.setConstantData(map);
        DataSourceUtil.setDB("v2");
    }
}