package com.jiayue.insu.incloud.service;

import com.jiayue.insu.incloud.compermisson.BJZYYJYSDComPermisson;
import com.jiayue.insu.incloud.compermisson.QNHLComPermisson;
import com.jiayue.insu.incloud.constants.CompanyConstant;
import com.jiayue.insu.incloud.entity.Station;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class InitRunner implements CommandLineRunner {
    @Autowired
    private QNHLComPermisson qnhlComPermisson;
    @Autowired
    private BJZYYJYSDComPermisson bjzyyjysdComPermisson;
    @Autowired
    private StationService stationService;
    @Override
    public void run(String... args) throws Exception {
        List<Station> stations = stationService.findByInCode(CompanyConstant.COMPANY_QNHL);
        for (Station station: stations) {
            qnhlComPermisson.generateKey(station);
        }

        List<Station> stations1 = stationService.findByInCode(CompanyConstant.COMPANY_BJZYYJY_SD);
        for (Station station: stations1) {
            bjzyyjysdComPermisson.generateKey(station);
        }
    }
}
