package com.lightinit.hsdatashow.impl.topic.water;

import com.lightinit.hsdatashow.entity.StWaterGroundwaterMonitoringStation;
import com.lightinit.hsdatashow.mapper.StWaterGroundwaterMonitoringStationMapper;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.model.topic.water.MonitoringStatioSearchModel;
import com.lightinit.hsdatashow.model.topic.water.NameAndValueModel;
import com.lightinit.hsdatashow.service.topic.water.IGroundwaterMonitoringStationService;
import com.lightinit.hsdatashow.spring.DynamicDataContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class GroundwaterMonitoringStationServiceImpl implements IGroundwaterMonitoringStationService {
   @Autowired
    private StWaterGroundwaterMonitoringStationMapper stWaterGroundwaterMonitoringStationMapper;
    @Override
    public ResultState getAreaConstitute() {
        DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
        ResultState resultState = new ResultState();
        Map<String,Object> map = new HashMap<>();
        List<String> names = new ArrayList<>();
        List<NameAndValueModel> list = stWaterGroundwaterMonitoringStationMapper.getAreaConstitute();
        for(NameAndValueModel nameAndValueModel : list) {
            names.add(nameAndValueModel.getName());
        }
        map.put("list",list);
        map.put("names",names);
        resultState.setData(map);
        return resultState;
    }

    @Override
    public ResultState getMonitoringStationType() {
        DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
        ResultState resultState = new ResultState();
        Map<String,Object> map = new HashMap<>();
        List<String> names = new ArrayList<>();
        List<NameAndValueModel> list = stWaterGroundwaterMonitoringStationMapper.getMonitoringStationType();
        for(NameAndValueModel nameAndValueModel : list) {
            names.add(nameAndValueModel.getName());
        }
        map.put("list",list);
        map.put("names",names);
        resultState.setData(map);
        return resultState;
    }

    @Override
    public List<StWaterGroundwaterMonitoringStation> getMonitoringStation(MonitoringStatioSearchModel searchModel) {
        return stWaterGroundwaterMonitoringStationMapper.getMonitoringStation(searchModel);
    }

}
