zoukankan      html  css  js  c++  java
  • ssm使用全注解实现增删改查案例——IDeptMapper

    package org.dao;
    
    import java.util.List;
    
    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Many;
    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.Dept;
    
    public interface IDeptMapper {
        /**
         * 
        * @Description: 该方法的主要作用:删除部门信息
        * @Title: deleteByPrimaryKey
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Delete("delete from dept where id = #{id}")
        int deleteByPrimaryKey(Integer id);
    
        /**
         * 
        * @Description: 该方法的主要作用:添加部门信息
        * @Title: insert
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Insert("insert into dept (id, name, loc )" +
                " values (#{id,jdbcType=INTEGER}, " +
                "#{name,jdbcType=VARCHAR}, " +
                "#{loc,jdbcType=VARCHAR})")
        int insert(Dept record);
    
        /**
         * 
        * @Description: 该方法的主要作用:根据编号查询信息
        * @Title: selectByPrimaryKey
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:Dept   
        * @throws
         */
        @Select("select * from dept where id  = #{id}")
        @Results({
            @Result(id=true,property="id",column="id"),
            @Result(property="name",column="name"),
            @Result(property="loc",column="loc"),
            @Result(property="empList",column="id",javaType=List.class,
            many=@Many(select="org.dao.IEmpMapper.findEmpByDept"))
        })
        Dept selectByPrimaryKey(Integer id);
    
        /**
         * 
        * @Description: 该方法的主要作用:修改信息
        * @Title: updateByPrimaryKey
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Update("update dept " +
                "set name = #{name,jdbcType=VARCHAR}, " +
                " loc = #{loc,jdbcType=VARCHAR} " +
                "where id = #{id,jdbcType=INTEGER}")
        int updateByPrimaryKey(Dept record);
    
        /**
         * 
        * @Description: 该方法的主要作用:查询全部
        * @Title: findDeptAll
        * @param  @return 设定文件  
        * @return  返回类型:List<Dept>   
        * @throws
         */
        @Select("select * from dept")
        List<Dept> findDeptAll();
    }
  • 相关阅读:
    git和TortoiseGit安装
    poi导出excel
    POI生成word文档
    java反编译工具
    如何把wecenter的推荐的问题模块单独调取出来?
    想学网站运营?我教你啊!(下)
    想学网站运营?我教你啊!(中)
    想学网站运营?我教你啊!(上)
    织梦模块管理里面空白
    Discuz/X3.1去掉标题中的Powered by Discuz!以及解决首页标题后的"-"
  • 原文地址:https://www.cnblogs.com/a1111/p/12816063.html
Copyright © 2011-2022 走看看