package com.icomsys.main_vm.biz.rcp.monitoring.service.impl;

import com.icomsys.main_vm.biz.rcp.monitoring.service.MonitoringOutscenarioService;
import com.icomsys.main_vm.db.mybatis.alias.MonitoringOutscenarioVO;
import com.icomsys.main_vm.db.mybatis.mapper.MonitoringOutscenarioMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class MonitoringOutscenarioServiceImpl implements MonitoringOutscenarioService {

    @Autowired
    private MonitoringOutscenarioMapper monitoringOutscenarioMapper;

    @Override
    public List<HashMap> selectOutscenarioList(MonitoringOutscenarioVO vo) {
        List<HashMap> resultList = monitoringOutscenarioMapper.selectOutscenarioList(vo);

        int cnt = 0;
        for (HashMap data: resultList) {
            if (cnt == vo.getPageSize() && vo.getPage() != -1) {    break;  }     // page -1 엑셀 다운로드일경우 전체 count

            vo.setScenarioSeq((Long)data.get("scenarioSeq"));
            data.put("scenarioCnt", monitoringOutscenarioMapper.selectOutscenarioCnt(vo));
            cnt++;
        }
        return resultList;
    }

    @Override
    public int selectOutscenarioListCnt(MonitoringOutscenarioVO vo) {
        return monitoringOutscenarioMapper.selectOutscenarioListCnt(vo);
    }

    @Override
    public List<HashMap> selectScenarioNameList(MonitoringOutscenarioVO vo) {
        return monitoringOutscenarioMapper.selectScenarioNameList(vo);
    }

    @Override
    public List<String> selectTokenListByScenario(MonitoringOutscenarioVO vo) {
        return monitoringOutscenarioMapper.selectTokenListByScenario(vo);
    }

    @Override
    public List<HashMap> selectCallListByScenario(MonitoringOutscenarioVO vo) {
        return monitoringOutscenarioMapper.selectCallListByScenario(vo);
    }
}
