package com.lightinit.hsdatashow.impl.ms;

import com.lightinit.hsdatashow.common.SingleChartMapperUtils;
import com.lightinit.hsdatashow.entity.*;
import com.lightinit.hsdatashow.mapper.*;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.service.ms.IMSHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @Author: sunxiang
 * @Date: 2018/9/7 11:40
 * @Description:
 **/
@Service
public class MSHomeServiceImpl implements IMSHomeService {

    private  List getClazz(){
        ArrayList list = new ArrayList();
        list.add(cityGreeningMapper);
        list.add(societySecurityMapper);
        list.add(pollutionIndexMapper);
        list.add(societyDevelopMapper);
        return list;
    }
    @Autowired
    private CityGreeningMapper cityGreeningMapper;
    @Autowired
    private SocietySecurityMapper societySecurityMapper;
    @Autowired
    private PollutionIndexMapper pollutionIndexMapper;
    @Autowired
    private SocietyDevelopMapper societyDevelopMapper;
    @Override
    public List list(String tableType, BaseExample.Page pager) {
        if(tableType.equalsIgnoreCase("pollutionIndex")){
            return SingleChartMapperUtils.list(getClazz(),tableType,pager,"id");
        }else{
            return SingleChartMapperUtils.list(getClazz(),tableType,pager);
        }
    }

    @Override
    public long queryCount(String tableType) {
        return SingleChartMapperUtils.queryCount(getClazz(),tableType);
    }

    @Override
    public Object findById(String tableType, Long id) {
        return SingleChartMapperUtils.findById(getClazz(),tableType,id);
    }

    @Override
    public ResultState delete(String tableType, Long id) {
        return SingleChartMapperUtils.delete(getClazz(),tableType,id);
    }

    @Override
    public <V> ResultState add(V v, boolean isEdit) {
        return SingleChartMapperUtils.add(v,isEdit,getClazz());
    }
}
