

package com.yc.education.service.impl;

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

import com.yc.education.service.IService;

import tk.mybatis.mapper.common.Mapper;

import java.util.List;


public abstract class BaseService<T> implements IService<T> {

    @Autowired
    protected Mapper<T> mapper;
    

    public Mapper<T> getMapper() {
        return mapper;
    }

    public T selectByKey(Object key) {
        return mapper.selectByPrimaryKey(key);
    }

    public int save(T entity) {
        return mapper.insert(entity);
    }

    public int delete(Object key) {
        return mapper.deleteByPrimaryKey(key);
    }

    public int updateAll(T entity) {
        return mapper.updateByPrimaryKey(entity);
    }

    public int updateNotNull(T entity) {
        return mapper.updateByPrimaryKeySelective(entity);
    }

    public List<T> selectByExample(Object example) {
        return mapper.selectByExample(example);
    }

    //TODO 其他...
}
