package com.school.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.school.dao.TeacherDao;
import com.school.entity.Teacher;

// 注入dao
//@Repository("teacherDao")

public class TeacherDaoImpl extends SqlMapClientDaoSupport implements TeacherDao {
	
	//查询所有
	@SuppressWarnings("unchecked")
	public List<Teacher> selectTeacher() {
		List teachers = getSqlMapClientTemplate().queryForList("teacher.selectTeachers");// selectTeachers 代表 查询标签中的id
		return teachers;
	}
	
	//添加
	public void insertTeacher(Teacher teacher) {
		getSqlMapClientTemplate().insert("teacher.insertTeacher", teacher);		
	}
	
	//根据id查询
	public Teacher selectById(int id) {
		return (Teacher) getSqlMapClientTemplate().queryForObject("teacher.teacherById",id);
	}

	//根据id删除
	public void deleteTeacher(int id) {		
		getSqlMapClientTemplate().delete("teacher.deleteTeacher",id);
	}

	//修改
	public void updateTeacher(Teacher teacher) {	
		getSqlMapClientTemplate().update("teacher.updateTeacher",teacher);
	}

}
