package com.yxcheng.token.common.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.beans.factory.annotation.Autowired;

import com.yxcheng.token.utils.StringUtil;

public abstract class AbstractService<M extends BaseMapper<E,T>,E,T> implements BaseServiceI<E,T> {
	
	public static Map<String,String> tableMap = new ConcurrentHashMap();
	
	public static final String INVOICE_FRONT = "fin_invoice_";

    @Autowired
    protected M baseMapper;

    @Override
    public int countByExample(E example) {
        return baseMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(E example) {
        return baseMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Serializable id) {
        return baseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(T record) {
        return baseMapper.insert(record);
    }

    @Override
    public int insertSelective(T record) {
        return baseMapper.insertSelective(record);
    }

   @Override
   public T getOne(E example){
       List<T> list = this.selectByExample(example);
       if(list!=null && list.size()>0){
           return this.selectByExample(example).get(0);
       }
       return null;
    }

    @Override
    public List<T> selectByExample(E example) {
        return baseMapper.selectByExample(example);
    }

    @Override
    public T selectByPrimaryKey(Serializable id) {
        return baseMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(T record, E example) {
        return baseMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(T record, E example) {
        return baseMapper.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(T record) {
        return baseMapper.updateByPrimaryKeySelective(record);
    }
 
    @Override
    public int updateByPrimaryKey(T record) {
        return baseMapper.updateByPrimaryKey(record);
    }
    
}
