首页 > 其他分享 >mybatis-plus-方法

mybatis-plus-方法

时间:2023-04-21 17:35:00浏览次数:32  
标签:wrapper return param boolean plus Wrapper mybatis entityList 方法


/**
 * Copyright (c) 2011-2016, hubin ([email protected]).
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;

/**
 * <p>
 * 顶级 Service
 * </p>
 *
 * @author hubin
 * @Date 2016-04-20
 */
public interface IService<T> {

    /**
     * <p>
     * 插入一条记录(选择字段,策略插入)
     * </p>
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean insert(T entity);

    /**
     * <p>
     * 插入一条记录(全部字段)
     * </p>
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean insertAllColumn(T entity);

    /**
     * <p>
     * 插入(批量),该方法不适合 Oracle
     * </p>
     *
     * @param entityList 实体对象列表
     * @return boolean
     */
    boolean insertBatch(List<T> entityList);

    /**
     * <p>
     * 插入(批量)
     * </p>
     *
     * @param entityList 实体对象列表
     * @param batchSize  插入批次数量
     * @return boolean
     */
    boolean insertBatch(List<T> entityList, int batchSize);

    /**
     * <p>
     * 批量修改插入
     * </p>
     *
     * @param entityList 实体对象列表
     * @return boolean
     */
    boolean insertOrUpdateBatch(List<T> entityList);

    /**
     * <p>
     * 批量修改插入
     * </p>
     *
     * @param entityList 实体对象列表
     * @param batchSize
     * @return boolean
     */
    boolean insertOrUpdateBatch(List<T> entityList, int batchSize);

    /**
     * <p>
     * 批量修改或插入全部字段
     * </p>
     *
     * @param entityList 实体对象列表
     * @return boolean
     */
    boolean insertOrUpdateAllColumnBatch(List<T> entityList);

    /**
     * 批量修改或插入全部字段
     *
     * @param entityList 实体对象列表
     * @param batchSize
     * @return boolean
     */
    boolean insertOrUpdateAllColumnBatch(List<T> entityList, int batchSize);

    /**
     * <p>
     * 根据 ID 删除
     * </p>
     *
     * @param id 主键ID
     * @return boolean
     */
    boolean deleteById(Serializable id);

    /**
     * <p>
     * 根据 columnMap 条件,删除记录
     * </p>
     *
     * @param columnMap 表字段 map 对象
     * @return boolean
     */
    boolean deleteByMap(Map<String, Object> columnMap);

    /**
     * <p>
     * 根据 entity 条件,删除记录
     * </p>
     *
     * @param wrapper 实体包装类 {@link Wrapper}
     * @return boolean
     */
    boolean delete(Wrapper<T> wrapper);

    /**
     * <p>
     * 删除(根据ID 批量删除)
     * </p>
     *
     * @param idList 主键ID列表
     * @return boolean
     */
    boolean deleteBatchIds(Collection<? extends Serializable> idList);

    /**
     * <p>
     * 根据 ID 选择修改
     * </p>
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean updateById(T entity);

    /**
     * <p>
     * 根据 ID 修改全部字段
     * </p>
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean updateAllColumnById(T entity);

    /**
     * <p>
     * 根据 whereEntity 条件,更新记录
     * </p>
     *
     * @param entity  实体对象
     * @param wrapper 实体包装类 {@link Wrapper}
     * @return boolean
     */
    boolean update(T entity, Wrapper<T> wrapper);

    /**
     * <p>
     * 根据ID 批量更新
     * </p>
     *
     * @param entityList 实体对象列表
     * @return boolean
     */
    boolean updateBatchById(List<T> entityList);

    /**
     * <p>
     * 根据ID 批量更新
     * </p>
     *
     * @param entityList 实体对象列表
     * @param batchSize  更新批次数量
     * @return boolean
     */
    boolean updateBatchById(List<T> entityList, int batchSize);

    /**
     * <p>
     * 根据ID 批量更新全部字段
     * </p>
     *
     * @param entityList 实体对象列表
     * @return boolean
     */
    boolean updateAllColumnBatchById(List<T> entityList);

    /**
     * <p>
     * 根据ID 批量更新全部字段
     * </p>
     *
     * @param entityList 实体对象列表
     * @param batchSize  更新批次数量
     * @return boolean
     */
    boolean updateAllColumnBatchById(List<T> entityList, int batchSize);

    /**
     * <p>
     * TableId 注解存在更新记录,否插入一条记录
     * </p>
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean insertOrUpdate(T entity);

    /**
     * 插入或修改一条记录的全部字段
     *
     * @param entity 实体对象
     * @return boolean
     */
    boolean insertOrUpdateAllColumn(T entity);

    /**
     * <p>
     * 根据 ID 查询
     * </p>
     *
     * @param id 主键ID
     * @return T
     */
    T selectById(Serializable id);

    /**
     * <p>
     * 查询(根据ID 批量查询)
     * </p>
     *
     * @param idList 主键ID列表
     * @return List<T>
     */
    List<T> selectBatchIds(Collection<? extends Serializable> idList);

    /**
     * <p>
     * 查询(根据 columnMap 条件)
     * </p>
     *
     * @param columnMap 表字段 map 对象
     * @return List<T>
     */
    List<T> selectByMap(Map<String, Object> columnMap);

    /**
     * <p>
     * 根据 Wrapper,查询一条记录
     * </p>
     *
     * @param wrapper 实体对象
     * @return T
     */
    T selectOne(Wrapper<T> wrapper);

    /**
     * <p>
     * 根据 Wrapper,查询一条记录
     * </p>
     *
     * @param wrapper {@link Wrapper}
     * @return Map<String,Object>
     */
    Map<String, Object> selectMap(Wrapper<T> wrapper);

    /**
     * <p>
     * 根据 Wrapper,查询一条记录
     * </p>
     *
     * @param wrapper {@link Wrapper}
     * @return Object
     */
    Object selectObj(Wrapper<T> wrapper);

    /**
     * <p>
     * 根据 Wrapper 条件,查询总记录数
     * </p>
     *
     * @param wrapper 实体对象
     * @return int
     */
    int selectCount(Wrapper<T> wrapper);

    /**
     * <p>
     * 查询列表
     * </p>
     *
     * @param wrapper 实体包装类 {@link Wrapper}
     * @return
     */
    List<T> selectList(Wrapper<T> wrapper);

    /**
     * <p>
     * 翻页查询
     * </p>
     *
     * @param page 翻页对象
     * @return
     */
    Page<T> selectPage(Page<T> page);

    /**
     * <p>
     * 查询列表
     * </p>
     *
     * @param wrapper {@link Wrapper}
     * @return
     */
    List<Map<String, Object>> selectMaps(Wrapper<T> wrapper);

    /**
     * <p>
     * 根据 Wrapper 条件,查询全部记录
     * </p>
     *
     * @param wrapper 实体对象封装操作类(可以为 null)
     * @return List<Object>
     */
    List<Object> selectObjs(Wrapper<T> wrapper);

    /**
     * <p>
     * 翻页查询
     * </p>
     *
     * @param page    翻页对象
     * @param wrapper {@link Wrapper}
     * @return
     */
    @SuppressWarnings("rawtypes")
    Page<Map<String, Object>> selectMapsPage(Page page, Wrapper<T> wrapper);

    /**
     * <p>
     * 翻页查询
     * </p>
     *
     * @param page    翻页对象
     * @param wrapper 实体包装类 {@link Wrapper}
     * @return
     */
    Page<T> selectPage(Page<T> page, Wrapper<T> wrapper);

}

 

标签:wrapper,return,param,boolean,plus,Wrapper,mybatis,entityList,方法
From: https://blog.51cto.com/u_16082902/6213850

相关文章

  • 洪君:mybatis plus012:增删改查 洪君
    plus的pom依赖:替代原mybatis<!--mybatisplus--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus</artifactId><version>2.1.9</version></d......
  • Pandownload凉凉后,可能只有这么一个不花钱的百度网盘提速方法
    一、速度变化beforeafter二、提速设置百度网盘右上角的设置——>传输——>下载提速——>去开启——>开启下载提速——>应用——>确定应用后,速度如果没有提升。那么记得重启网盘,再看看。三、其他也试过KinhDown、6盘等,真没啥鸟用。开启这个提速后,正常速度能到1~2MB/s,也是够用了。......
  • net 7 中间件sql 注入的方法
    百度一下都是filter防止sql注入的,其实到MVC的fileter已经浪费了很多性能,我们在管道组装的时候,就可以拦截非法字符。在中间件收集参数是比较麻烦的事情,、知识点储备需要理解中间件,以及怎么封装中间件,我们netcore都是add 一个服务+app.use 一个中间件开发方式 2 如果收......
  • 父盒子设置flex:1,子盒子设置height:100%无效的解决方法
    有时候写页面的时候,需要在设置为flex:1的父盒子里面写子盒子,并将子盒子height设置为100%但是可以发现,这样的尝试是无效的,原因是由于父盒子没有设置height属性,导致了子盒子设置百分比失效解决方法:给父盒子设置height:0,此时子盒子再设置height:100%即可生效......
  • 机械设备油液监测方法
    油液监测方法包括油质分析和油中的微粒分析两方面。(1)常规理化性能分析润滑油常规理化性能分析是根据润滑剂本身性能的变化,来判断机械的磨损状态,可以防止因润滑不良而导致的故障。实践证明,润滑剂的性能与机械设备的磨损状态、设备的使用寿命有着密切的关系,通过对......
  • 数组的常用方法
    数组的常用方法数组是一个复杂数据类型,我们在操作它的时候就不能再想基本数据类型一样操作了比如我们想改变一个数组//创建一个数组vararr=[1,2,3]//我们想把数组变成只有1和2arr=[1,2]这样肯定是不合理,因为这样不是在改变之前的数组相当于心弄了一个......
  • JAVA获取当前时间的三种方法
    1、java.util.Dateday=newDate();SimpleDateFormatsdf=newSimpleDateFormat(“yyyy-MM-ddHH:mm:ss”);System.out.println(sdf.format(day));通过Date类来获取当前时间,比较常用。需要使用Java.util.Date类,速度一般。2、SimpleDateFormatsdf=newSimpleDateFormat......
  • 如何有效的关闭Win10自动更新?(5种方法)
    转载自如何有效的关闭Win10自动更新?(5种方法)-littlefat-博客园(cnblogs.com)想寻找Win10关闭自动更新方法?对于Win10用户经常会遇到系统提示更新,很多用户都因其而烦恼。有时选择拒绝更新,系统会一直不停的提示系统更新;选择更新了,更新后一些软件或网络打印机等相关设备又无法使......
  • 升级element-plus
    之前用的是  "element-plus":"^1.0.2-beta.53"版本,什么都处理好了,但是会el-select里面使用v-if的时候控制台会报错查询以后我升级到:"element-plus":"^1.2.0-beta.6"不敢升级太高,毕竟项目快做完了,升级稳定版坑太多了,一个个补来不及,只能先小升级一下,升级后如下问题:el-selec......
  • 获取url中参数具体值的方法
    我们常用的是用正则或者其他处理办法,这个这里不讲,主要想谈以下方法 1、如果给到的地址是完整的地址,比如 https://i.cnblogs.com/posts/edit?test=123那么,我们使用 newURL('https://i.cnblogs.com/posts/edit?test=123').searchParams.get('test') 即可获取到test对应的值......