package com.gyee.frame.service;

import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.WindturbinestandardpointsMapper;
import com.gyee.frame.model.auto.Windturbinestandardpoints;
import com.gyee.frame.model.auto.WindturbinestandardpointsExample;
import com.gyee.frame.util.SnowflakeIdWorker;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class WindturbinestandardpointsService implements BaseService<Windturbinestandardpoints, WindturbinestandardpointsExample> {
    @Resource
    private WindturbinestandardpointsMapper windturbinestandardpointsMapper;


    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = Convert.toListStrArray(ids);
        WindturbinestandardpointsExample example = new WindturbinestandardpointsExample();
        example.createCriteria().andIdIn(lista);
        return windturbinestandardpointsMapper.deleteByExample(example);


    }


    @Override
    public Windturbinestandardpoints selectByPrimaryKey(String id) {

        return windturbinestandardpointsMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(Windturbinestandardpoints record) {
        return windturbinestandardpointsMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(Windturbinestandardpoints record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return windturbinestandardpointsMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(Windturbinestandardpoints record, WindturbinestandardpointsExample example) {

        return windturbinestandardpointsMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(Windturbinestandardpoints record, WindturbinestandardpointsExample example) {

        return windturbinestandardpointsMapper.updateByExample(record, example);
    }

    @Override
    public List<Windturbinestandardpoints> selectByExample(WindturbinestandardpointsExample example) {

        return windturbinestandardpointsMapper.selectByExample(example);
    }


    @Override
    public long countByExample(WindturbinestandardpointsExample example) {

        return windturbinestandardpointsMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(WindturbinestandardpointsExample example) {

        return windturbinestandardpointsMapper.deleteByExample(example);
    }


    public  List<Windturbinestandardpoints> findAllList() {


        WindturbinestandardpointsExample example = new WindturbinestandardpointsExample();
        example.setOrderByClause("id ASC");
        List<Windturbinestandardpoints> vos = windturbinestandardpointsMapper.selectByExample(example);


        return vos;

    }

    public  Map<String, List<Windturbinestandardpoints>> findAllMap() {


        Map<String, List<Windturbinestandardpoints>>  wpsmap=new HashMap<>();
        WindturbinestandardpointsExample example = new WindturbinestandardpointsExample();
        example.setOrderByClause("id ASC");
        List<Windturbinestandardpoints> vos = windturbinestandardpointsMapper.selectByExample(example);

        if(!vos.isEmpty())
        {
            for(Windturbinestandardpoints vo:vos)
            {
                if(wpsmap.containsKey(vo.getModel()))
                {
                    List<Windturbinestandardpoints> ls=wpsmap.get(vo.getModel());
                    ls.add(vo);
                    wpsmap.put(vo.getModel(),ls);
                }else
                {
                    List<Windturbinestandardpoints> ls=new ArrayList<>();
                    ls.add(vo);
                    wpsmap.put(vo.getModel(),ls);
                }
            }
        }
        return wpsmap;

    }

}
