Mybatis-Plus 之BaseMapper 方法详解

2023-05-16

为什么80%的码农都做不了架构师?>>>   hot3.png

/**
 * Mapper 继承该接口后,无需编写 mapper.xml 文件,即可获得CRUD功能
 * 这个 Mapper 支持 id 泛型
 * @author hubin
 * @Date 2016-01-23
 */
public interface BaseMapper<T> {

    /**
     * 插入一条记录
     * @param entity
     * 实体对象
     * @return int
     */
    Integer insert(T entity);

    /**
     * 根据 ID 删除
     * @param id
     * 主键ID
     * @return int
     */
    Integer deleteById(Serializable id);

    /**
     * 根据 columnMap 条件,删除记录
     * @param columnMap
     * 表字段 map 对象
     * @return int
     */
    Integer deleteByMap(@Param("cm") Map<String, Object> columnMap);

    /**
     * 根据 entity 条件,删除记录
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return int
     */
    Integer delete(@Param("ew") Wrapper<T> wrapper);

    /**
     * 删除(根据ID 批量删除)
     * @param idList
     * 主键ID列表
     * @return int
     */
    Integer deleteBatchIds(List<? extends Serializable> idList);

    /**
     * 根据 ID 修改
     * @param entity
     * 实体对象
     * @return int
     */
    Integer updateById(T entity);

    /**
     * 根据 whereEntity 条件,更新记录
     * @param entity
     * 实体对象
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return
     */
    Integer update(@Param("et") T entity, @Param("ew") Wrapper<T> wrapper);

    /**
     * 根据 ID 查询
     * @param id
     * 主键ID
     * @return T
     */
    T selectById(Serializable id);

    /**
     * 查询(根据ID 批量查询)
     * @param idList
     * 主键ID列表
     * @return List<T>
     */
    List<T> selectBatchIds(List<? extends Serializable> idList);

    /**
     * 查询(根据 columnMap 条件)
     * @param columnMap
     * 表字段 map 对象
     * @return List<T>
     */
    List<T> selectByMap(@Param("cm") Map<String, Object> columnMap);

    /**
     * 根据 entity 条件,查询一条记录
     * @param entity
     * 实体对象
     * @return T
     */
    T selectOne(@Param("ew") T entity);

    /**
     * 根据 Wrapper 条件,查询总记录数
     * @param wrapper
     * 实体对象
     * @return int
     */
    Integer selectCount(@Param("ew") Wrapper<T> wrapper);

    /**
     * 根据 entity 条件,查询全部记录
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return List<T>
     */
    List<T> selectList(@Param("ew") Wrapper<T> wrapper);

    /**
     * 根据 Wrapper 条件,查询全部记录
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return List<T>
     */
    List<Map<String, Object>> selectMaps(@Param("ew") Wrapper<T> wrapper);

    /**
     * 根据 Wrapper 条件,查询全部记录
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return List<Object>
     */
    List<Object> selectObjs(@Param("ew") Wrapper<T> wrapper);

    /** 
     * 用法:(new RowBounds(offset, limit), ew);
     * 根据 entity 条件,查询全部记录(并翻页)
     * @param rowBounds
     * 分页查询条件(可以为 RowBounds.DEFAULT)
     * @param wrapper
     * 实体对象封装操作类(可以为 null)
     * @return List<T>
     */
    List<T> selectPage(RowBounds rowBounds, @Param("ew") Wrapper<T> wrapper);

    /** -- 不常用,
     * 根据 Wrapper 条件,查询全部记录(并翻页)
     * @param rowBounds
     * 分页查询条件(可以为 RowBounds.DEFAULT)
     * @param wrapper
     * 实体对象封装操作类
     * @return List<Map<String, Object>>
     */
    List<Map<String, Object>> selectMapsPage(RowBounds rowBounds, @Param("ew") Wrapper<T> wrapper);
}

用法如下:
 

public interface CompanyMapper extends BaseMapper<Company> {

	Integer companyNameRegistered(String companyName);

	List<InvitedCompany> invitedCompany(Long createUserId);

	Company getByCompanyName(String companyName);

}

 

转载于:https://my.oschina.net/360yg/blog/1834091

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Mybatis-Plus 之BaseMapper 方法详解 的相关文章

随机推荐

  • RBF神经网络的matlab简单实现

    径向基神经网络 1 径向基函数 Radial Basis Function xff0c RBF 神经网络是一种性能良好的前向网络 xff0c 具有最佳逼近 训练简洁 学习收敛速度快以及克服局部最小值问题的性能 xff0c 目前已经证明径向基
  • npm不是以管理身份运行遇到的问题

    环境 win10 43 npm3 10 5 问题 在npm install lodash时 出现下列错误 34 npm debug log 34 文件内容 0 info it worked if it ends with ok 1 verb
  • JSON_VALUE

    本页目录 语法入参功能描述示例 语法 span class pln style color rgb 0 0 0 VARCHAR JSON VALUE span span class pun style color rgb 102 102 0
  • 浮点数的表示方法

    计算机中浮点数的表示 never2die 长江大学湖北荆州 中文摘要 xff1a 本文介绍了浮点数在计算机中的几种表示方法 xff0c 并对此进行整理分析 xff0c 为人们以后做此方面的研究提供参考 中文关键词 xff1a 浮点数 xff
  • matlab 中atan2函数的介绍

    atan2 a b 是4象限反正切 xff0c 它的取值不仅取决于正切值a b xff0c 还取决于点 b a 落入哪个象限 xff1a 当点 b a 落入第一象限时 xff0c atan2 a b 的范围是 0 pi 2 当点 b a 落
  • 研究生毕业入职阿里,2年升职到P7,晒出真实月薪,以为看错了

    互联网企业已经成为现在大部分年轻人选择职业打拼的行业 xff0c 这个行业机会多 xff0c 有各种各样的职位和机会留给优秀的年轻人去闯 xff0c 但是相应的压力也非常大 毕竟高薪水的待遇下 xff0c 工作压力又怎么会轻松的了呢 xff
  • mac清理软件哪个好用?五大Mac Cleaner介绍推荐

    还在找好用的Mac清理软件吗 xff1f 你的Mac变慢了吗 xff1f 如果给你的Mac安装一款Mac清理软件 xff0c 可以删除Mac中不需要的垃圾文件 xff0c 以释放Mac的磁盘空间和内存 不知道mac清理软件哪个好用 xff1
  • 解决"SSL handshake failed"问题

    前阵子不知是对Ubuntu动了些啥 xff0c 结果Ubuntu One死活也不上 App Center上点击 34 Buy 34 按钮会提示 34 SSL handshake failed 34 猜想大概是由于同一问题导致的 网上给出的解
  • 当在Win8下安装msi类型的文件出现errorcode 2503的解决方法

    Win8安装程序出现2502 2503错误解决方法 在Win8中 xff0c 在安装msi安装包的时候常常会出现代码为2502 2503的错误 其实这种错误是由于安装权限不足造成的 xff0c 可以这种msi的安装包不像其他exe的安装程序
  • 极限编程实践

    摘自 xff1a 敏捷软件开发 xff1a 原则 模式与实践 Robert C Martin 著 xff0c 邓辉 译 极限编程实践 xff1a 1 完整团队 XP项目的所有参与者 xff08 开发人员 业务分析师 测试人员等等 xff09
  • keil5c语言定义引脚,keil编写C程序是不是不能在函数内定义变量啊,求大神

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 肯定可以的 xff1a 比如 程序动态显示字符 显示光标和光标闪烁打开效果 include 包含头文件 xff0c 义 include sbit RS 61 P2 4 定义端口 sbit RW
  • CircleProgressBar

    今天又写了一个demo xff0c 带有两个进度值的 圆环进度条 xff0c 原谅我是个小白 xff0c 只能写一写简单的自定义控件 xff0c 我会继续努力的 先看效果图 001 gif lt pre gt 64 Override pro
  • c++采集声卡输出_手机直播声卡转换器的分析与选购

    时下直播行业非常火爆 xff0c 相关周边产品五花八门 xff0c 良莠不齐 今天为大家带来的这篇长文 xff0c 旨在为选购设备苦恼的朋友提供帮助 闲话少叙 xff0c 开始正题 目前大家的使用的直播设备基本分为以下两种形式 xff1a
  • awk的使用及字符串的操作

    awk教程 awk的基本功能是对文件进行指定规则浏览和抽取信息 基本格式 xff1a 1 awk F 分隔域 39 command 39 input file s 2 写入shell脚本中 3 awk f awk script file i
  • VS2017安装后如何移动 Windows Kits文件夹

    MS的回答 LINK Try the following technique Close all programs move the Windows Kits folder to another disk for example to D
  • pytorch GPU的程序kill后未释放内存

    使用PyTorch设置多线程 xff08 threads xff09 进行数据读取 xff08 DataLoader xff09 xff0c 其实是假的多线程 xff0c 他是开了N个子进程 xff08 PID都连着 xff09 进行模拟多
  • 一个「学渣」从零Web前端自学之路

    从 13 年专科毕业开始 xff0c 一路跌跌撞撞走了很多弯路 xff0c 做过餐厅服务员 xff0c 进过工厂干过流水线 xff0c 做过客服 xff0c 干过电话销售可以说经历相当的 丰富 最后的机缘巧合下 xff0c 走上了前端开发之
  • 请求时token过期自动刷新token

    1 在开发过程中 xff0c 我们都会接触到token xff0c token的作用是什么呢 xff1f 主要的作用就是为了安全 xff0c 用户登陆时 xff0c 服务器会随机生成一个有时效性的token 用户的每一次请求都需要携带上to
  • Lua Table 长度的计算

    计算 Lua 的 Table长度 在 Lua 中 xff0c 我们可以通过这个符号 来计算字符串的长度和一个table的长度 xff0c 比如 xff1a str 61 34 I 39 am a string 34 print str 61
  • Mybatis-Plus 之BaseMapper 方法详解

    为什么80 的码农都做不了架构师 xff1f gt gt gt Mapper 继承该接口后 xff0c 无需编写 mapper xml 文件 xff0c 即可获得CRUD功能 这个 Mapper 支持 id 泛型 64 author hub