package cn.sxx.service; import java.util.List; public interface BaseService<T,Q> { public void save(T t); public void update(T t); public T getObj(Integer id); public void delete(Integer id); public void delete(T t); public List<T> queryObjByCondition(Q q); }
其实现类
package cn.sxx.service.impl; import java.util.List; import cn.sxx.dao.BaseDao; import cn.sxx.service.BaseService; public class BaseServiceImpl<T,Q> implements BaseService<T, Q> { BaseDao<T,Q> baseDao; @Override public void save(T t) { baseDao.save(t); } @Override public void update(T t) { baseDao.update(t); } @Override public T getObj(Integer id) { return (T) baseDao.getObj(id); } @Override public void delete(Integer id) { baseDao.delete(id); } @Override public void delete(T t) { baseDao.delete(t); } @Override public List<T> queryObjByCondition(Q q) { return baseDao.queryObjByCondition(q); } }