/* * Copyright (c) 2011-2016, 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.extension.service; import java.io.Serializable; import java.util.Collection; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; /** *

* 顶级 Service *

* * @author hubin * @since 2018-06-23 */ public interface IService { /** *

* 插入一条记录(选择字段,策略插入) *

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

* 插入(批量),该方法不适合 Oracle *

* * @param entityList 实体对象集合 * @return boolean */ boolean insertBatch(Collection entityList); /** *

* 插入(批量) *

* * @param entityList 实体对象集合 * @param batchSize 插入批次数量 * @return boolean */ boolean insertBatch(Collection entityList, int batchSize); /** *

* 批量修改插入 *

* * @param entityList 实体对象集合 * @return boolean */ boolean insertOrUpdateBatch(Collection entityList); /** *

* 批量修改插入 *

* * @param entityList 实体对象集合 * @param batchSize * @return boolean */ boolean insertOrUpdateBatch(Collection entityList, int batchSize); /** *

* 根据 ID 删除 *

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

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

* * @param columnMap 表字段 map 对象 * @return boolean */ boolean deleteByMap(Map columnMap); /** *

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

* * @param wrapper 实体包装类 {@link Wrapper} * @return boolean */ boolean delete(Wrapper wrapper); /** *

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

* * @param idList 主键ID列表 * @return boolean */ boolean deleteBatchIds(Collection idList); /** *

* 根据 ID 选择修改 *

* * @param entity 实体对象 * @return boolean */ boolean updateById(T entity); /** *

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

* * @param entity 实体对象 * @param wrapper 实体包装类 {@link Wrapper} * @return boolean */ boolean update(T entity, Wrapper wrapper); /** *

* 根据ID 批量更新 *

* * @param entityList 实体对象集合 * @return boolean */ boolean updateBatchById(Collection entityList); /** *

* 根据ID 批量更新 *

* * @param entityList 实体对象集合 * @param batchSize 更新批次数量 * @return boolean */ boolean updateBatchById(Collection entityList, int batchSize); /** *

* TableId 注解存在更新记录,否插入一条记录 *

* * @param entity 实体对象 * @return boolean */ boolean insertOrUpdate(T entity); /** *

* 根据 ID 查询 *

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

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

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

* 查询(根据 columnMap 条件) *

* * @param columnMap 表字段 map 对象 * @return Collection */ Collection selectByMap(Map columnMap); /** *

* 根据 Wrapper,查询一条记录 *

* * @param wrapper 实体对象 * @return T */ T selectOne(Wrapper wrapper); /** *

* 根据 Wrapper,查询一条记录 *

* * @param wrapper {@link Wrapper} * @return Map */ Map selectMap(Wrapper wrapper); /** *

* 根据 Wrapper,查询一条记录 *

* * @param wrapper {@link Wrapper} * @return Object */ Object selectObj(Wrapper wrapper); /** *

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

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

* 查询列表 *

* * @param wrapper 实体包装类 {@link Wrapper} * @return */ Collection selectList(Wrapper wrapper); /** *

* 翻页查询 *

* * @param page 翻页对象 * @param wrapper 实体包装类 {@link Wrapper} * @return */ IPage selectPage(IPage page, Wrapper wrapper); /** *

* 查询列表 *

* * @param wrapper {@link Wrapper} * @return */ List> selectMaps(Wrapper wrapper); /** *

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

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

* 翻页查询 *

* * @param page 翻页对象 * @param wrapper {@link Wrapper} * @return */ IPage> selectMapsPage(IPage page, Wrapper wrapper); }