package com.ssm.student.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.ssm.student.entity.Student;
/**
* 学生模块业务层接口
* @author pengfei.xiong
* @date 2017-8-13
*/
public interface StudentDao {
/**
* 添加学生
* @param student 学生实体对象
* @throws Exception 异常
*/
@Insert("insert into student(name,age) values(#{name},#{age})")
public void insertStu(Student student)throws Exception;
/**
* 添加学生
* @param student
* @return 返回受影响的行数
* @throws Exception
*/
@Insert("insert into student(id,name,age) values(#{id},#{name},#{age})")
@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="id")
public int insertStu2(Student student)throws Exception;
/**
* 返回学生集合列表
* @return
* @throws Exception
*/
@Select("select id,name,age from student")
@ResultType(Student.class)
public List<Student> selectAll() throws Exception;
public void addUser(Student student);
@Select("select id,name,age from student")
@ResultType(Map.class)
public List<Map<String,Object>> selectAllMap() throws Exception;
/**
* 根据id查询学生信息
* @param id
* @return 返回学生对象
* @throws Exception
*/
@Select("select id,name,age from student where id=#{id}")
@ResultType(Student.class)
public Student selectById(int id) throws Exception;
/**
* 根据Name查询学生信息
* @param id
* @return 返回学生对象
* @throws Exception
*/
@Select("select id,name,age from student where name=#{name}")
@ResultType(Student.class)
public Student selectByName(String name) throws Exception;
/**
* 修改学生信息
* @param student
* @return
* @throws Exception
*/
@Update("update student set name=#{name},age=#{age} where id=#{id}")
public int update(Student student) throws Exception;
/**
* 删除学生信息
* @param student
* @return
* @throws Exception
*/
@Delete("delete from student where id = #{ids}")
public int delete(@Param("ids")int id) throws Exception;
}
demo地址:http://download.csdn.net/download/xpf_user/10130963