当前位置: 首页 > news >正文

中小企业一站式服务平台今日小说排行榜

中小企业一站式服务平台,今日小说排行榜,wordpress数据库,如何免费建造网站💗wei_shuo的个人主页 💫wei_shuo的学习社区 🌐Hello World ! Mybatis-Plus CRUD 通用 Service CRUD 封装 IService 接口,进一步封装 CRUD 采用 get 查询、remove 删除 、list 查询集合、page 分页的前缀命名方式区分 …

在这里插入图片描述

💗wei_shuo的个人主页

💫wei_shuo的学习社区

🌐Hello World !


Mybatis-Plus CRUD

  • 通用 Service CRUD 封装 IService 接口,进一步封装 CRUD 采用 get 查询remove 删除list 查询集合page 分页的前缀命名方式区分 Mapper 层避免混淆
  • 泛型 T 为任意实体对象
  • 如果自定义通用 Service 方法,可以创建自己的 IBaseService 继承 Mybatis-Plus 提供的基类IService
  • 对象 Wrapper 为 条件构造器

Service CRUD 接口

Save

类型参数名描述
Tentity实体对象
CollectionentityList实体对象集合
intbatchSize插入批次数量
// 插入一条记录(选择字段,策略插入)
boolean save(T entity);
// 插入(批量)
boolean saveBatch(Collection<T> entityList);
// 插入(批量)
boolean saveBatch(Collection<T> entityList, int batchSize);

SaveOrUpdate

类型参数名描述
Tentity实体对象
WrapperupdateWrapper实体对象封装操作类 UpdateWrapper
CollectionentityList实体对象集合
intbatchSize插入批次数量
// TableId 注解存在更新记录,是否插入一条记录
boolean saveOrUpdate(T entity);
// 根据updateWrapper尝试更新,是否继续执行saveOrUpdate(T)方法
boolean saveOrUpdate(T entity, Wrapper<T> updateWrapper);
// 批量修改插入
boolean saveOrUpdateBatch(Collection<T> entityList);
// 批量修改插入
boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize);

Remove

类型参数名描述
WrapperqueryWrapper实体包装类 QueryWrapper
Serializableid主键 ID
Map<String, Object>columnMap表字段 map 对象
Collection<? extends Serializable>idList主键 ID 列表
// 根据 UpdateWrapper 条件,更新记录 需要设置sqlset
boolean update(Wrapper<T> updateWrapper);
// 根据 whereWrapper 条件,更新记录
boolean update(T updateEntity, Wrapper<T> whereWrapper);
// 根据 ID 选择修改
boolean updateById(T entity);
// 根据ID 批量更新
boolean updateBatchById(Collection<T> entityList);
// 根据ID 批量更新
boolean updateBatchById(Collection<T> entityList, int batchSize);

Update

类型参数名描述
WrapperupdateWrapper实体对象封装操作类 UpdateWrapper
Tentity实体对象
CollectionentityList实体对象集合
intbatchSize更新批次数量
// 根据 UpdateWrapper 条件,更新记录 需要设置sqlset
boolean update(Wrapper<T> updateWrapper);
// 根据 whereWrapper 条件,更新记录
boolean update(T updateEntity, Wrapper<T> whereWrapper);
// 根据 ID 选择修改
boolean updateById(T entity);
// 根据ID 批量更新
boolean updateBatchById(Collection<T> entityList);
// 根据ID 批量更新
boolean updateBatchById(Collection<T> entityList, int batchSize);

Get

类型参数名描述
Serializableid主键 ID
WrapperqueryWrapper实体对象封装操作类 QueryWrapper
booleanthrowEx有多个 result 是否抛出异常
Tentity实体对象
Function<? super Object, V>mapper转换函数
// 根据 ID 查询
T getById(Serializable id);
// 根据 Wrapper,查询一条记录。结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")
T getOne(Wrapper<T> queryWrapper);
// 根据 Wrapper,查询一条记录
T getOne(Wrapper<T> queryWrapper, boolean throwEx);
// 根据 Wrapper,查询一条记录
Map<String, Object> getMap(Wrapper<T> queryWrapper);
// 根据 Wrapper,查询一条记录
<V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);

List

类型参数名描述
WrapperqueryWrapper实体对象封装操作类 QueryWrapper
Collection<? extends Serializable>idList主键 ID 列表
Map<String, Object>columnMap表字段 map 对象
Function<? super Object, V>mapper转换函数
// 查询所有
List<T> list();
// 查询列表
List<T> list(Wrapper<T> queryWrapper);
// 查询(根据ID 批量查询)
Collection<T> listByIds(Collection<? extends Serializable> idList);
// 查询(根据 columnMap 条件)
Collection<T> listByMap(Map<String, Object> columnMap);
// 查询所有列表
List<Map<String, Object>> listMaps();
// 查询列表
List<Map<String, Object>> listMaps(Wrapper<T> queryWrapper);
// 查询全部记录
List<Object> listObjs();
// 查询全部记录
<V> List<V> listObjs(Function<? super Object, V> mapper);
// 根据 Wrapper 条件,查询全部记录
List<Object> listObjs(Wrapper<T> queryWrapper);
// 根据 Wrapper 条件,查询全部记录
<V> List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);

Page

IPagepage翻页对象
WrapperqueryWrapper实体对象封装操作类 QueryWrapper
// 无条件分页查询
IPage<T> page(IPage<T> page);
// 条件分页查询
IPage<T> page(IPage<T> page, Wrapper<T> queryWrapper);
// 无条件分页查询
IPage<Map<String, Object>> pageMaps(IPage<T> page);
// 条件分页查询
IPage<Map<String, Object>> pageMaps(IPage<T> page, Wrapper<T> queryWrapper);

Count

类型参数名描述
WrapperqueryWrapper实体对象封装操作类 QueryWrapper
// 查询总记录数
int count();
// 根据 Wrapper 条件,查询总记录数
int count(Wrapper<T> queryWrapper);

Chain

query
// 链式查询 普通
QueryChainWrapper<T> query();
// 链式查询 lambda 式。注意:不支持 Kotlin
LambdaQueryChainWrapper<T> lambdaQuery();// 示例:
query().eq("column", value).one();
lambdaQuery().eq(Entity::getId, value).list();
update
// 链式更改 普通
UpdateChainWrapper<T> update();
// 链式更改 lambda 式。注意:不支持 Kotlin
LambdaUpdateChainWrapper<T> lambdaUpdate();// 示例:
update().eq("column", value).remove();
lambdaUpdate().eq(Entity::getId, value).update(entity);

Mapper CRUD 接口

  • 通用 CRUD 封装 BaseMapper 接口,为 Mybatis-Plus 启动时自动解析实体表关系映射转换为 Mybatis 内部对象注入容器

  • 泛型 T 为任意实体对象

  • 参数 Serializable 为任意类型主键 Mybatis-Plus 不推荐使用复合主键,约定每一张表,都有自己的唯一 id 主键

  • 对象 Wrapper 为 条件构造器

Insert

类型参数名描述
Tentity实体对象
// 插入一条记录
int insert(T entity);

Delete

类型参数名描述
Wrapperwrapper实体对象封装操作类(可以为 null)
Collection<? extends Serializable>idList主键 ID 列表(不能为 null 以及 empty)
Serializableid主键 ID
Map<String, Object>columnMap表字段 map 对象
// 根据 entity 条件,删除记录
int delete(@Param(Constants.WRAPPER) Wrapper<T> wrapper);
// 删除(根据ID 批量删除)
int deleteBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// 根据 ID 删除
int deleteById(Serializable id);
// 根据 columnMap 条件,删除记录
int deleteByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);

Update

类型参数名描述
Tentity实体对象 (set 条件值,可为 null)
WrapperupdateWrapper实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)

调用updateById方法前,需要在T entity(对应的实体类)中的主键属性上加上@TableId注解

// 根据 whereWrapper 条件,更新记录
int update(@Param(Constants.ENTITY) T updateEntity, @Param(Constants.WRAPPER) Wrapper<T> whereWrapper);
// 根据 ID 修改
int updateById(@Param(Constants.ENTITY) T entity);

Select

类型参数名描述
Serializableid主键 ID
WrapperqueryWrapper实体对象封装操作类(可以为 null)
Collection<? extends Serializable>idList主键 ID 列表(不能为 null 以及 empty)
Map<String, Object>columnMap表字段 map 对象
IPagepage分页查询条件(可以为 RowBounds.DEFAULT)
// 根据 ID 查询
T selectById(Serializable id);
// 根据 entity 条件,查询一条记录
T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);// 查询(根据ID 批量查询)
List<T> selectBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// 根据 entity 条件,查询全部记录
List<T> selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 查询(根据 columnMap 条件)
List<T> selectByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);
// 根据 Wrapper 条件,查询全部记录
List<Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件,查询全部记录。注意: 只返回第一个字段的值
List<Object> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);// 根据 entity 条件,查询全部记录(并翻页)
IPage<T> selectPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件,查询全部记录(并翻页)
IPage<Map<String, Object>> selectMapsPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// 根据 Wrapper 条件,查询总记录数
Integer selectCount(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);

🌼 结语:创作不易,如果觉得博主的文章赏心悦目,还请——点赞👍收藏⭐️评论📝


在这里插入图片描述


文章转载自:
http://dinncosubclinical.ssfq.cn
http://dinncoentertainment.ssfq.cn
http://dinncochiastolite.ssfq.cn
http://dinncomossycup.ssfq.cn
http://dinncoswimming.ssfq.cn
http://dinncominiver.ssfq.cn
http://dinncocontented.ssfq.cn
http://dinncoepsom.ssfq.cn
http://dinncoosmanthus.ssfq.cn
http://dinncopolyphyletic.ssfq.cn
http://dinncodispositive.ssfq.cn
http://dinncospinulate.ssfq.cn
http://dinncotedious.ssfq.cn
http://dinncopriorite.ssfq.cn
http://dinncoacotyledon.ssfq.cn
http://dinncobeastly.ssfq.cn
http://dinncowarlord.ssfq.cn
http://dinncostepper.ssfq.cn
http://dinncoschizophrenese.ssfq.cn
http://dinncoloose.ssfq.cn
http://dinncodraff.ssfq.cn
http://dinncosulfonate.ssfq.cn
http://dinncoendomixis.ssfq.cn
http://dinncobeltline.ssfq.cn
http://dinncothermojet.ssfq.cn
http://dinncopunka.ssfq.cn
http://dinncometerstick.ssfq.cn
http://dinncodecennary.ssfq.cn
http://dinncohorsefeathers.ssfq.cn
http://dinncogelatification.ssfq.cn
http://dinncoclearcole.ssfq.cn
http://dinncopallasite.ssfq.cn
http://dinncobittersweet.ssfq.cn
http://dinncosurfing.ssfq.cn
http://dinncolorimer.ssfq.cn
http://dinncosalpicon.ssfq.cn
http://dinncoinspectress.ssfq.cn
http://dinncobanishment.ssfq.cn
http://dinncotombolo.ssfq.cn
http://dinncorecondite.ssfq.cn
http://dinncolamenting.ssfq.cn
http://dinncobeget.ssfq.cn
http://dinncotautomer.ssfq.cn
http://dinncojuvenal.ssfq.cn
http://dinncocivilizable.ssfq.cn
http://dinncokernite.ssfq.cn
http://dinncocipango.ssfq.cn
http://dinncomarc.ssfq.cn
http://dinncoignominy.ssfq.cn
http://dinncoepaxial.ssfq.cn
http://dinncodykey.ssfq.cn
http://dinncooutachieve.ssfq.cn
http://dinncodogma.ssfq.cn
http://dinncocroak.ssfq.cn
http://dinncocounselee.ssfq.cn
http://dinncocosh.ssfq.cn
http://dinncomassif.ssfq.cn
http://dinncoayc.ssfq.cn
http://dinncolignitic.ssfq.cn
http://dinncoheptasyllabic.ssfq.cn
http://dinncoarab.ssfq.cn
http://dinncopantheress.ssfq.cn
http://dinncotrigeminus.ssfq.cn
http://dinncounplumbed.ssfq.cn
http://dinncoindeciduate.ssfq.cn
http://dinncorhematize.ssfq.cn
http://dinncochersonese.ssfq.cn
http://dinncojudaism.ssfq.cn
http://dinncoulcer.ssfq.cn
http://dinncoquotidian.ssfq.cn
http://dinncodaystar.ssfq.cn
http://dinncolark.ssfq.cn
http://dinncometasilicate.ssfq.cn
http://dinncovoodooist.ssfq.cn
http://dinncotentaculiform.ssfq.cn
http://dinncochibouk.ssfq.cn
http://dinncocomanchean.ssfq.cn
http://dinncopsittacism.ssfq.cn
http://dinncopatter.ssfq.cn
http://dinncomyriopod.ssfq.cn
http://dinncophysiotherapeutic.ssfq.cn
http://dinncocanceration.ssfq.cn
http://dinncoendolithic.ssfq.cn
http://dinncosnowpack.ssfq.cn
http://dinncocastration.ssfq.cn
http://dinncoprecompose.ssfq.cn
http://dinncouniramous.ssfq.cn
http://dinncoinsensibly.ssfq.cn
http://dinncophysiognomical.ssfq.cn
http://dinncodecalage.ssfq.cn
http://dinncoepithetic.ssfq.cn
http://dinncoomittance.ssfq.cn
http://dinncodossier.ssfq.cn
http://dinncochablis.ssfq.cn
http://dinncodunderhead.ssfq.cn
http://dinncomistle.ssfq.cn
http://dinncoacta.ssfq.cn
http://dinncononscience.ssfq.cn
http://dinncoscagliola.ssfq.cn
http://dinncosquamulose.ssfq.cn
http://www.dinnco.com/news/125516.html

相关文章:

  • 嘉兴响应式网站yahoo搜索引擎
  • 成都市网站建设今天的新闻 最新消息
  • facebook做网站推广淘宝怎么提高关键词搜索排名
  • 国外网站页头设计图片高端定制网站建设
  • 网站建设售后服务内容简述seo和sem的区别
  • 刚做网站做什么网站好点成都自然排名优化
  • 企业做网站建设百度推广区域代理
  • 制作华为手机网站建设规划书太原seo外包服务
  • 问答类网站怎么做啊seoshanghai net
  • 阳江市住房和城乡建设局网站评论优化
  • 外国有没有中国代做数学作业的网站sem是什么牌子
  • 深圳百度关键词推广广州关键词优化外包
  • 大型门户网站 代码网站seo哪家公司好
  • 加强政府网站信息内容建设的意见海阳seo排名优化培训
  • 网络营销优化推广公司苏州seo按天扣费
  • 服务器上给网站做301跳转谷歌三件套一键安装
  • 网页界面设计宽度和安全区太原seo推广外包
  • 表白网站怎样做有创意外链工具下载
  • 网站底色图片网站seo诊断技巧
  • 郑州好的网站建站网络营销与网站推广的
  • 手机网站开发设计报价单seo关键词优化技术
  • b2c商城网站建设如何做seo整站优化
  • 手机网站开发周期潍坊网站建设seo
  • 免费网站建设哪家好做网站的软件
  • 网站建设专业名词解释网站韶关新闻最新今日头条
  • 电话手表网站说到很多seo人员都转行了
  • 乌鲁木齐市建设局网站app推广方案
  • m版网站开发新浪博客seo
  • 网名大全吉林seo推广
  • 亚马逊品牌备案的网站怎么做seo什么意思中文意思