/** * Copyright (c) 2011-2020, hubin (jobob@qq.com). *

* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.baomidou.mybatisplus.mapper; import java.io.Serializable; import java.util.List; import java.util.Map; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.session.RowBounds; /** *

* Mapper 继承该接口后,无需编写 mapper.xml 文件,即可获得CRUD功能 *

*

* 这个 Mapper 支持 id 泛型 *

* * @author hubin * @Date 2016-01-23 */ public interface BaseMapper { /** *

* 插入一条记录 *

* * @param entity 实体对象 * @return int */ Integer insert(T entity); /** *

* 插入一条记录 *

* * @param entity 实体对象 * @return int */ Integer insertAllColumn(T entity); /** *

* 根据 ID 删除 *

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

* 根据 columnMap 条件,删除记录 *

* * @param columnMap 表字段 map 对象 * @return int */ Integer deleteByMap(@Param("cm") Map columnMap); /** *

* 根据 entity 条件,删除记录 *

* * @param wrapper 实体对象封装操作类(可以为 null) * @return int */ Integer delete(@Param("ew") Wrapper wrapper); /** *

* 删除(根据ID 批量删除) *

* * @param idList 主键ID列表 * @return int */ Integer deleteBatchIds(List idList); /** *

* 根据 ID 修改 *

* * @param entity 实体对象 * @return int */ Integer updateById(@Param("et") T entity); /** *

* 根据 ID 修改 *

* * @param entity 实体对象 * @return int */ Integer updateAllColumnById(@Param("et") T entity); /** *

* 根据 whereEntity 条件,更新记录 *

* * @param entity 实体对象 * @param wrapper 实体对象封装操作类(可以为 null) * @return */ Integer update(@Param("et") T entity, @Param("ew") Wrapper wrapper); /** *

* 根据 ID 查询 *

* * @param id 主键ID * @return T */ T selectById(Serializable id); /** *

* 查询(根据ID 批量查询) *

* * @param idList 主键ID列表 * @return List */ List selectBatchIds(List idList); /** *

* 查询(根据 columnMap 条件) *

* * @param columnMap 表字段 map 对象 * @return List */ List selectByMap(@Param("cm") Map columnMap); /** *

* 根据 entity 条件,查询一条记录 *

* * @param entity 实体对象 * @return T */ T selectOne(@Param("ew") T entity); /** *

* 根据 Wrapper 条件,查询总记录数 *

* * @param wrapper 实体对象 * @return int */ Integer selectCount(@Param("ew") Wrapper wrapper); /** *

* 根据 entity 条件,查询全部记录 *

* * @param wrapper 实体对象封装操作类(可以为 null) * @return List */ List selectList(@Param("ew") Wrapper wrapper); /** *

* 根据 Wrapper 条件,查询全部记录 *

* * @param wrapper 实体对象封装操作类(可以为 null) * @return List */ List> selectMaps(@Param("ew") Wrapper wrapper); /** *

* 根据 Wrapper 条件,查询全部记录 *

* * @param wrapper 实体对象封装操作类(可以为 null) * @return List */ List selectObjs(@Param("ew") Wrapper wrapper); /** *

* 根据 entity 条件,查询全部记录(并翻页) *

* * @param rowBounds 分页查询条件(可以为 RowBounds.DEFAULT) * @param wrapper 实体对象封装操作类(可以为 null) * @return List */ List selectPage(RowBounds rowBounds, @Param("ew") Wrapper wrapper); /** *

* 根据 Wrapper 条件,查询全部记录(并翻页) *

* * @param rowBounds 分页查询条件(可以为 RowBounds.DEFAULT) * @param wrapper 实体对象封装操作类 * @return List> */ List> selectMapsPage(RowBounds rowBounds, @Param("ew") Wrapper wrapper); }