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.RegionMapper;
import com.gyee.frame.model.auto.Region;
import com.gyee.frame.model.auto.RegionExample;
import com.gyee.frame.util.SnowflakeIdWorker;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class RegionService implements BaseService<Region, RegionExample> {
    @Resource
    private RegionMapper regionMapper;


    @Override
    public int deleteByPrimaryKey(String ids) {

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


    }


    @Override
    public Region selectByPrimaryKey(String id) {

        return regionMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(Region record) {
        return regionMapper.updateByPrimaryKeySelective(record);
    }


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

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


        return regionMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(Region record, RegionExample example) {

        return regionMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(Region record, RegionExample example) {

        return regionMapper.updateByExample(record, example);
    }

    @Override
    public List<Region> selectByExample(RegionExample example) {

        return regionMapper.selectByExample(example);
    }


    @Override
    public long countByExample(RegionExample example) {

        return regionMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(RegionExample example) {

        return regionMapper.deleteByExample(example);
    }


    public  List<Region> findAllList() {

        RegionExample example = new RegionExample();

        List<Region> vos = regionMapper.selectByExample(example);


        return vos;

    }

}
