package cn.th.work.dao.Impl;

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

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.th.work.dao.BaseDao;

@Repository
public  class BaseDaoImpl<T> extends SqlSessionDaoSupport implements BaseDao<T> {
	
	@Autowired
	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){
		 super.setSqlSessionFactory(sqlSessionFactory);
	}
	
	//命名空间
	private String nameSpace;

	public String getNameSpace() {
		return nameSpace;
	}

	public void setNameSpace(String nameSpace) {
		this.nameSpace = nameSpace;
	}
	
	//主要业务
    
	//增
	public int save(T entity) {
		int num=0;
		num=this.getSqlSession().insert(nameSpace+".save",entity);
		return num;
	}

	//删一个
	public int deleteById(Serializable id) {
		int num=0;
		num=this.getSqlSession().delete(nameSpace+".deleteById",id);
		return num;
	}
    
	//批量删
	public void deletePart(Serializable[] ids) {
		
		this.getSqlSession().delete(nameSpace+".deletePart",ids);
	}
    
	//获得一个对象
	public T get(Serializable id) {
		
		return this.getSqlSession().selectOne(nameSpace+".get", id);
	}

	//改
	public int update(T entity) {
		int num=0;
		num=this.getSqlSession().update(nameSpace+".update",entity);
		return num;
	}

	//分页
	public List<T> getAll(Map map) {
		List<T> list=null;
		list=this.getSqlSession().selectList(nameSpace+".getAll",map);
		return list;
	}

	public int getCount(Map map) {
		int num=0;
		num=this.getSqlSession().selectOne(nameSpace+".getCount",map);
		return num;
	}

	
}
最近下载更多
zj20020510  LV5 2023年9月18日
renyuan  LV9 2022年12月7日
cx0127  LV13 2022年10月30日
testuser1234567  LV24 2022年6月30日
Zjy-0913  LV1 2022年6月11日
chasiubao  LV2 2022年6月9日
我是helloworld  LV23 2022年5月12日
lls0832  LV3 2022年5月3日
azdd11  LV1 2022年4月8日
jwfadacai  LV8 2021年12月31日
最近浏览更多
2131234536546  LV7 3月31日
欠踹de背影  LV25 3月18日
a318888331  LV13 3月7日
liyijiesb 3月4日
暂无贡献等级
zhangjilu  LV18 1月7日
WBelong  LV7 2023年12月27日
wwwww816  LV3 2023年12月19日
流连瓦盖法  LV7 2023年12月13日
hongdongdong  LV12 2023年12月2日
feia1236  LV10 2023年11月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友