ssm使用全注解实现增删改查案例——IEmpMapper

package org.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.entity.Emp;

public interface IEmpMapper {
    /**
     * 
    * @Description: 该方法的主要作用:根据编号删除.
    * @Title: deleteByPrimaryKey
    * @param  @param eid
    * @param  @return 设定文件  
    * @return  返回类型:int   
    * @throws
     */
    @Delete("delete from emp where eid = #{eid} ")
    int deleteByPrimaryKey(Integer eid);

    /**
     * 
    * @Description: 该方法的主要作用:添加
    * @Title: insert
    * @param  @param record
    * @param  @return 设定文件  
    * @return  返回类型:int   
    * @throws
     */
    @Insert("insert into emp (eid, ename, eage,  edate, did) " +
            "values (#{eid,jdbcType=INTEGER}," +
            " #{ename,jdbcType=VARCHAR}, " +
            "#{eage,jdbcType=INTEGER},  " +
            "#{edate,jdbcType=TIMESTAMP}," +
            " #{did,jdbcType=INTEGER})")
    int insert(Emp record);
    /**
     * 
    * @Description: 该方法的主要作用:根据编号查询
    * @Title: selectByPrimaryKey
    * @param  @param eid
    * @param  @return 设定文件  
    * @return  返回类型:Emp   
    * @throws
     */
    @Select("select * from emp where eid = #{eid}")
    @Results({
        @Result(id=true,property="eid",column="eid"),
        @Result(property="ename",column="ename"),
        @Result(property="eage",column="eage"),
        @Result(property="dept",column="did",javaType=org.entity.Dept.class,
        one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
    })
    Emp selectByPrimaryKey(Integer eid);
    /**
     * 
    * @Description: 该方法的主要作用:修改信息
    * @Title: updateByPrimaryKey
    * @param  @param record
    * @param  @return 设定文件  
    * @return  返回类型:int   
    * @throws
     */
    @Update("pdate emp " +
            " set ename = #{ename,jdbcType=VARCHAR}, " +
            " eage = #{eage,jdbcType=INTEGER}, " +
            " edate = #{edate,jdbcType=TIMESTAMP}, " +
            "  did = #{did,jdbcType=INTEGER} " +
            "where eid = #{eid,jdbcType=INTEGER}")
    int updateByPrimaryKey(Emp record);
    /**
     * 
    * @Description: 该方法的主要作用:查询全部
    * @Title: findEmpAll
    * @param  @return 设定文件  
    * @return  返回类型:List<Emp>   
    * @throws
     */
    @Select("select * from emp")
    @Results({
        @Result(id=true,property="eid",column="eid"),
        @Result(property="ename",column="ename"),
        @Result(property="eage",column="eage"),
        @Result(property="dept",column="did",javaType=org.entity.Dept.class,
        one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
    })
    List<Emp> findEmpAll();

    /**
     * 
    * @Description: 该方法的主要作用:根据部门编号查询员工信息
    * @Title: findEmpByDept
    * @param  @param did
    * @param  @return 设定文件  
    * @return  返回类型:List<Emp>   
    * @throws
     */
    @Select("select * from emp where did = #{dids}")
    @Results({
        @Result(id=true,property="eid",column="eid"),
        @Result(property="ename",column="ename"),
        @Result(property="eage",column="eage"),
        @Result(property="dept",column="did",javaType=org.entity.Dept.class,
        one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
    })
    List<Emp> findEmpByDept(int did);

}
上一篇:easyswoole阿里云获取视频信息(继承上面 easyswoole上传视频到阿里云)


下一篇:监听文本框的值,值改变时执行自定义事件