网站方案建设书怎么写,外链link,旅游网络营销论文,网上房地产官网#x1f497;wei_shuo的个人主页 #x1f4ab;wei_shuo的学习社区 #x1f310;Hello World #xff01; Mybatis-Plus CRUD 通用 Service CRUD 封装 IService 接口#xff0c;进一步封装 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(CollectionT entityList);
// 插入批量
boolean saveBatch(CollectionT entityList, int batchSize);SaveOrUpdate
类型参数名描述Tentity实体对象WrapperupdateWrapper实体对象封装操作类 UpdateWrapperCollectionentityList实体对象集合intbatchSize插入批次数量
// TableId 注解存在更新记录是否插入一条记录
boolean saveOrUpdate(T entity);
// 根据updateWrapper尝试更新是否继续执行saveOrUpdate(T)方法
boolean saveOrUpdate(T entity, WrapperT updateWrapper);
// 批量修改插入
boolean saveOrUpdateBatch(CollectionT entityList);
// 批量修改插入
boolean saveOrUpdateBatch(CollectionT entityList, int batchSize);Remove
类型参数名描述WrapperqueryWrapper实体包装类 QueryWrapperSerializableid主键 IDMapString, ObjectcolumnMap表字段 map 对象Collection? extends SerializableidList主键 ID 列表
// 根据 UpdateWrapper 条件更新记录 需要设置sqlset
boolean update(WrapperT updateWrapper);
// 根据 whereWrapper 条件更新记录
boolean update(T updateEntity, WrapperT whereWrapper);
// 根据 ID 选择修改
boolean updateById(T entity);
// 根据ID 批量更新
boolean updateBatchById(CollectionT entityList);
// 根据ID 批量更新
boolean updateBatchById(CollectionT entityList, int batchSize);Update
类型参数名描述WrapperupdateWrapper实体对象封装操作类 UpdateWrapperTentity实体对象CollectionentityList实体对象集合intbatchSize更新批次数量
// 根据 UpdateWrapper 条件更新记录 需要设置sqlset
boolean update(WrapperT updateWrapper);
// 根据 whereWrapper 条件更新记录
boolean update(T updateEntity, WrapperT whereWrapper);
// 根据 ID 选择修改
boolean updateById(T entity);
// 根据ID 批量更新
boolean updateBatchById(CollectionT entityList);
// 根据ID 批量更新
boolean updateBatchById(CollectionT entityList, int batchSize);Get
类型参数名描述Serializableid主键 IDWrapperqueryWrapper实体对象封装操作类 QueryWrapperbooleanthrowEx有多个 result 是否抛出异常Tentity实体对象Function? super Object, Vmapper转换函数
// 根据 ID 查询
T getById(Serializable id);
// 根据 Wrapper查询一条记录。结果集如果是多个会抛出异常随机取一条加上限制条件 wrapper.last(LIMIT 1)
T getOne(WrapperT queryWrapper);
// 根据 Wrapper查询一条记录
T getOne(WrapperT queryWrapper, boolean throwEx);
// 根据 Wrapper查询一条记录
MapString, Object getMap(WrapperT queryWrapper);
// 根据 Wrapper查询一条记录
V V getObj(WrapperT queryWrapper, Function? super Object, V mapper);List
类型参数名描述WrapperqueryWrapper实体对象封装操作类 QueryWrapperCollection? extends SerializableidList主键 ID 列表MapString, ObjectcolumnMap表字段 map 对象Function? super Object, Vmapper转换函数
// 查询所有
ListT list();
// 查询列表
ListT list(WrapperT queryWrapper);
// 查询根据ID 批量查询
CollectionT listByIds(Collection? extends Serializable idList);
// 查询根据 columnMap 条件
CollectionT listByMap(MapString, Object columnMap);
// 查询所有列表
ListMapString, Object listMaps();
// 查询列表
ListMapString, Object listMaps(WrapperT queryWrapper);
// 查询全部记录
ListObject listObjs();
// 查询全部记录
V ListV listObjs(Function? super Object, V mapper);
// 根据 Wrapper 条件查询全部记录
ListObject listObjs(WrapperT queryWrapper);
// 根据 Wrapper 条件查询全部记录
V ListV listObjs(WrapperT queryWrapper, Function? super Object, V mapper);Page
IPagepage翻页对象WrapperqueryWrapper实体对象封装操作类 QueryWrapper
// 无条件分页查询
IPageT page(IPageT page);
// 条件分页查询
IPageT page(IPageT page, WrapperT queryWrapper);
// 无条件分页查询
IPageMapString, Object pageMaps(IPageT page);
// 条件分页查询
IPageMapString, Object pageMaps(IPageT page, WrapperT queryWrapper);Count
类型参数名描述WrapperqueryWrapper实体对象封装操作类 QueryWrapper
// 查询总记录数
int count();
// 根据 Wrapper 条件查询总记录数
int count(WrapperT queryWrapper);Chain
query
// 链式查询 普通
QueryChainWrapperT query();
// 链式查询 lambda 式。注意不支持 Kotlin
LambdaQueryChainWrapperT lambdaQuery();// 示例
query().eq(column, value).one();
lambdaQuery().eq(Entity::getId, value).list();update
// 链式更改 普通
UpdateChainWrapperT update();
// 链式更改 lambda 式。注意不支持 Kotlin
LambdaUpdateChainWrapperT 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实体对象封装操作类可以为 nullCollection? extends SerializableidList主键 ID 列表(不能为 null 以及 empty)Serializableid主键 IDMapString, ObjectcolumnMap表字段 map 对象
// 根据 entity 条件删除记录
int delete(Param(Constants.WRAPPER) WrapperT wrapper);
// 删除根据ID 批量删除
int deleteBatchIds(Param(Constants.COLLECTION) Collection? extends Serializable idList);
// 根据 ID 删除
int deleteById(Serializable id);
// 根据 columnMap 条件删除记录
int deleteByMap(Param(Constants.COLUMN_MAP) MapString, 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) WrapperT whereWrapper);
// 根据 ID 修改
int updateById(Param(Constants.ENTITY) T entity);Select
类型参数名描述Serializableid主键 IDWrapperqueryWrapper实体对象封装操作类可以为 nullCollection? extends SerializableidList主键 ID 列表(不能为 null 以及 empty)MapString, ObjectcolumnMap表字段 map 对象IPagepage分页查询条件可以为 RowBounds.DEFAULT
// 根据 ID 查询
T selectById(Serializable id);
// 根据 entity 条件查询一条记录
T selectOne(Param(Constants.WRAPPER) WrapperT queryWrapper);// 查询根据ID 批量查询
ListT selectBatchIds(Param(Constants.COLLECTION) Collection? extends Serializable idList);
// 根据 entity 条件查询全部记录
ListT selectList(Param(Constants.WRAPPER) WrapperT queryWrapper);
// 查询根据 columnMap 条件
ListT selectByMap(Param(Constants.COLUMN_MAP) MapString, Object columnMap);
// 根据 Wrapper 条件查询全部记录
ListMapString, Object selectMaps(Param(Constants.WRAPPER) WrapperT queryWrapper);
// 根据 Wrapper 条件查询全部记录。注意 只返回第一个字段的值
ListObject selectObjs(Param(Constants.WRAPPER) WrapperT queryWrapper);// 根据 entity 条件查询全部记录并翻页
IPageT selectPage(IPageT page, Param(Constants.WRAPPER) WrapperT queryWrapper);
// 根据 Wrapper 条件查询全部记录并翻页
IPageMapString, Object selectMapsPage(IPageT page, Param(Constants.WRAPPER) WrapperT queryWrapper);
// 根据 Wrapper 条件查询总记录数
Integer selectCount(Param(Constants.WRAPPER) WrapperT queryWrapper);结语创作不易如果觉得博主的文章赏心悦目还请——点赞收藏⭐️评论 文章转载自: http://www.morning.gjwkl.cn.gov.cn.gjwkl.cn http://www.morning.xglgm.cn.gov.cn.xglgm.cn http://www.morning.ycgrl.cn.gov.cn.ycgrl.cn http://www.morning.twfdm.cn.gov.cn.twfdm.cn http://www.morning.mdwtm.cn.gov.cn.mdwtm.cn http://www.morning.kpyyf.cn.gov.cn.kpyyf.cn http://www.morning.qpqwb.cn.gov.cn.qpqwb.cn http://www.morning.rhdln.cn.gov.cn.rhdln.cn http://www.morning.qbfkz.cn.gov.cn.qbfkz.cn http://www.morning.jftl.cn.gov.cn.jftl.cn http://www.morning.pxsn.cn.gov.cn.pxsn.cn http://www.morning.qhmgq.cn.gov.cn.qhmgq.cn http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn http://www.morning.jjzbx.cn.gov.cn.jjzbx.cn http://www.morning.xhfky.cn.gov.cn.xhfky.cn http://www.morning.dzgmj.cn.gov.cn.dzgmj.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn http://www.morning.jnkng.cn.gov.cn.jnkng.cn http://www.morning.tyklz.cn.gov.cn.tyklz.cn http://www.morning.dtnzk.cn.gov.cn.dtnzk.cn http://www.morning.kcbml.cn.gov.cn.kcbml.cn http://www.morning.easiuse.com.gov.cn.easiuse.com http://www.morning.qttft.cn.gov.cn.qttft.cn http://www.morning.fglxh.cn.gov.cn.fglxh.cn http://www.morning.mdwb.cn.gov.cn.mdwb.cn http://www.morning.yntsr.cn.gov.cn.yntsr.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.cjwkf.cn.gov.cn.cjwkf.cn http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn http://www.morning.fengnue.com.gov.cn.fengnue.com http://www.morning.hclplus.com.gov.cn.hclplus.com http://www.morning.qkqzm.cn.gov.cn.qkqzm.cn http://www.morning.ktrh.cn.gov.cn.ktrh.cn http://www.morning.rmtmk.cn.gov.cn.rmtmk.cn http://www.morning.w58hje.cn.gov.cn.w58hje.cn http://www.morning.yggdq.cn.gov.cn.yggdq.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.krkwp.cn.gov.cn.krkwp.cn http://www.morning.nkkpp.cn.gov.cn.nkkpp.cn http://www.morning.yqqxj1.cn.gov.cn.yqqxj1.cn http://www.morning.snmsq.cn.gov.cn.snmsq.cn http://www.morning.wzknt.cn.gov.cn.wzknt.cn http://www.morning.xckrj.cn.gov.cn.xckrj.cn http://www.morning.hnrqn.cn.gov.cn.hnrqn.cn http://www.morning.wjplr.cn.gov.cn.wjplr.cn http://www.morning.lyzwdt.com.gov.cn.lyzwdt.com http://www.morning.wtdyq.cn.gov.cn.wtdyq.cn http://www.morning.yxgqr.cn.gov.cn.yxgqr.cn http://www.morning.zlzpz.cn.gov.cn.zlzpz.cn http://www.morning.wsgyq.cn.gov.cn.wsgyq.cn http://www.morning.zlhcw.cn.gov.cn.zlhcw.cn http://www.morning.wbxr.cn.gov.cn.wbxr.cn http://www.morning.ftldl.cn.gov.cn.ftldl.cn http://www.morning.bmyrl.cn.gov.cn.bmyrl.cn http://www.morning.qpljg.cn.gov.cn.qpljg.cn http://www.morning.mwmxs.cn.gov.cn.mwmxs.cn http://www.morning.fkmrj.cn.gov.cn.fkmrj.cn http://www.morning.smxyw.cn.gov.cn.smxyw.cn http://www.morning.qmbgb.cn.gov.cn.qmbgb.cn http://www.morning.jmlgk.cn.gov.cn.jmlgk.cn http://www.morning.ghssm.cn.gov.cn.ghssm.cn http://www.morning.c7622.cn.gov.cn.c7622.cn http://www.morning.lhwlp.cn.gov.cn.lhwlp.cn http://www.morning.fgsct.cn.gov.cn.fgsct.cn http://www.morning.qscsy.cn.gov.cn.qscsy.cn http://www.morning.llmhq.cn.gov.cn.llmhq.cn http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn http://www.morning.spfq.cn.gov.cn.spfq.cn http://www.morning.ygwyt.cn.gov.cn.ygwyt.cn http://www.morning.xsbhg.cn.gov.cn.xsbhg.cn http://www.morning.fbzdn.cn.gov.cn.fbzdn.cn http://www.morning.zglrl.cn.gov.cn.zglrl.cn http://www.morning.nfccq.cn.gov.cn.nfccq.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.jghqc.cn.gov.cn.jghqc.cn http://www.morning.bfbl.cn.gov.cn.bfbl.cn http://www.morning.cybch.cn.gov.cn.cybch.cn http://www.morning.spnky.cn.gov.cn.spnky.cn http://www.morning.hdwjb.cn.gov.cn.hdwjb.cn http://www.morning.ptqds.cn.gov.cn.ptqds.cn