package com.bootdo.system.service.impl;

import com.bootdo.system.dao.ProvinceCodeMapper;
import com.bootdo.system.domain.ProvinceCode;
import com.bootdo.system.domain.ProvinceCodeExample;
import com.bootdo.system.service.ProvinceCodeService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

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

@Service
public class ProvinceCodeServiceImpl implements ProvinceCodeService {

    @Resource
    private ProvinceCodeMapper provinceCodeMapper;

    @Override
    public long countByExample(ProvinceCodeExample example) {
        return provinceCodeMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(ProvinceCodeExample example) {
        return provinceCodeMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return provinceCodeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(ProvinceCode record) {
        return provinceCodeMapper.insert(record);
    }

    @Override
    public int insertSelective(ProvinceCode record) {
        return provinceCodeMapper.insertSelective(record);
    }

    @Override
    public List<ProvinceCode> selectByExample(ProvinceCodeExample example) {
        return provinceCodeMapper.selectByExample(example);
    }

    @Override
    public ProvinceCode selectByPrimaryKey(Integer id) {
        return provinceCodeMapper.selectByPrimaryKey(id);
    }

    @Override
    public ProvinceCode selectByCode(Integer code) {
        ProvinceCodeExample example = new ProvinceCodeExample();
        example.createCriteria().andProvinceCodeEqualTo(code);
        List<ProvinceCode> provinceCodes = provinceCodeMapper.selectByExample(example);
        if (CollectionUtils.isNotEmpty(provinceCodes)) {
            return provinceCodes.get(0);
        }
        return null;
    }

    @Override
    public int updateByExampleSelective(ProvinceCode record, ProvinceCodeExample example) {
        return provinceCodeMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(ProvinceCode record, ProvinceCodeExample example) {
        return provinceCodeMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(ProvinceCode record) {
        return provinceCodeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(ProvinceCode record) {
        return provinceCodeMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch(List<ProvinceCode> list) {
        return provinceCodeMapper.updateBatch(list);
    }

    @Override
    public int batchInsert(List<ProvinceCode> list) {
        return provinceCodeMapper.batchInsert(list);
    }

}
