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.IMSTrafficSecurityService;
import org.apache.camel.language.SpEL;
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/4 10:58
 * @Description:
 **/
@Service
public class MSTrafficSecurityServiceImpl implements IMSTrafficSecurityService {

    private  List getClazz(){
        ArrayList list = new ArrayList();
        list.add(trafficDeathRateMapper);
        list.add(trafficAccidentDistributionMapper);
        list.add(trafficAccidentRankingMapper);
        list.add(trafficAccidentTendencyMapper);
        list.add(trafficAccidentProportionMapper);
        list.add(trafficAccidentCompleteMapper);
        return list;
    }
    @Autowired
    private TrafficDeathRateMapper trafficDeathRateMapper;
    @Autowired
    private TrafficAccidentProportionMapper trafficAccidentProportionMapper;
    @Autowired
    private TrafficAccidentTendencyMapper trafficAccidentTendencyMapper;
    @Autowired
    private TrafficAccidentRankingMapper trafficAccidentRankingMapper;
    @Autowired
    private TrafficAccidentDistributionMapper trafficAccidentDistributionMapper;
    @Autowired
    private TrafficAccidentCompleteMapper trafficAccidentCompleteMapper;
    @Override
    public List list(String tableType, BaseExample.Page pager) {
        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());
    }
}
