package incheon.sgp.sea.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import incheon.sgp.sea.mapper.SgpSeaMapper;
import incheon.sgp.sea.vo.AddressVO;
import incheon.sgp.sea.vo.SgpSeaFilterVO;
import incheon.sgp.sea.vo.SgpSeaVO;
import incheon.sgp.sea.vo.SgpSeaFcltyVO;

@Service("sgpSeaService")
public class SgpSeaServiceImpl implements SgpSeaService {

    @Resource(name = "sgpSeaMapper")
    private SgpSeaMapper sgpSeaMapper; 

    @Override
    public List<SgpSeaVO> seaList(SgpSeaFilterVO filterVO) {
        return sgpSeaMapper.seaList(filterVO);
    }

    @Override
    public Map<String, Object> seaStats(SgpSeaFilterVO filterVO) {
        Map<String, Object> result = new HashMap<>();
        result.put("pieChartData", sgpSeaMapper.selectPieChartData(filterVO));
        result.put("pipeChartData", sgpSeaMapper.selectPipeChartData(filterVO));
        //result.put("pipeChart2Data", sgpSeaMapper.selectPipeChart2Data(filterVO));
        return result;
    }
    
    @Override
    public List<SgpSeaVO> seaTypeList() throws Exception {
        return sgpSeaMapper.seaTypeList();
    }

    @Override
    public List<SgpSeaVO> seaTypeDetailList(String parentCode) throws Exception {
        return sgpSeaMapper.seaTypeDetailList(parentCode);
    }
    
    @Override
    public void saveFclty(SgpSeaFcltyVO vo) throws Exception {
        if (vo.getFcltyId() == null) {
            // 신규 등록
        	sgpSeaMapper.insertFclty(vo);
        } else {
            // 수정
        	sgpSeaMapper.updateFclty(vo);
        }
    }
    
    @Override
    public void deleteFclty(SgpSeaFcltyVO vo) throws Exception {
        sgpSeaMapper.deleteFclty(vo);
    }

    @Override
    public List<AddressVO> getAddress(SgpSeaFilterVO filterVO) {
        return List.of();
    }

    @Override
    public List<AddressVO> getAddressByPoi(SgpSeaFilterVO filterVO) {
        return sgpSeaMapper.selectAddrByPoint(filterVO);
    }
}