Mybatis-plus 抽象-接口方法类

Model

pojo 类继承 Model 抽象类,即可获得 CRUD(增删改查)功能。Model 使用映射类 pojo 继承 Model 抽象类,直接使用该类可以进行 CRUD,但是必须存在对应的 xxMapper 继承 BaseMapper。

Mapper

Mapper 用于 service 层,通过 xxMapper 调用从 Mapper 继承的方法。
BaseMapper 实现了 Mapper 接口。
xxMapper 类继承 BaseMapper 接口后,无需编写 mapper.xml 文件,即可获得 CRUD(增删改查)功能。BaseMapper 支持 id 为泛型。
BaseMapper 是使用 dao 层数据进行 CRUD,只需要进行使用 dao 层接口继承 BaseMapper 接口即可。

Mapper.class

package com.baomidou.mybatisplus.core.mapper;

public interface Mapper<T> {
}

Mapper.class 为空接口,作为顶层 Mapper 只用于说明规范,具体看其实现类。

Iservice

Iservice 用于 controller 层,通过 service 调用。使用 service 调用进行 CRUD,需要使用 service 接口继承 Iservice,并且 service 接口的实现类要继承 ServiceImpl<xxxMapper, pojo>。

Mapper 和 Iservice 的区别
  • Mapper 用于 service 层,通过 xxMapper 调用从 Mapper 继承的方法。
  • Iservice 用于 controller 层,通过 service 调用从 Iservice 继承的方法。

Mappper 和 Iservice 里面提供的方法都差不多,只是Iservice提供了批量操作的实现,比如: 批量添加、批量修改。

Wrapper

xxMapper 继承 BaseMapper 接口时,继承了其中的空方法,Wrapper 代码生成器的作用是为了动态向 sql 的 CRUD(增删改查)语句,即装饰从 BaseMapper 继承的 sql 语句,Wrapper 就是典型的修饰器模型。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Whitemeen太白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值