All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.mybatisplus.mapper.MyBatisPlusMapper Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.mybatisplus.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 批量相关接口。查询分页使用Map作为入参。
 *
 * @param  类型
 */
public interface MyBatisPlusMapper extends BaseMapper {

    /**
     * 

* 批量插入。 *

* * @param entityList 实体对象列表 * @return 行数 */ int insertBatch(List entityList); /** *

* 插入,若已经存在则更新。只支持{@code MySQL}。 *

* * @param entity 实体 * @return 行数 */ int saveOrUpdate(T entity); /** *

* 根据ID 批量更新。 *

* * @param entityList 实体对象列表 * @return 行数 */ int updateBatchById(List entityList); /** * 精确分页查询。 * * @param page 分页查询对象 * @param param key须是数据库字段,value是比较值 * @return 分页对象 */ default Page selectPagingAccurate(Page page, Map param) { return selectPaging(page, Wrappers.query().allEq(param)); } /** * 精确总数查询。 * * @param param key须是数据库字段,value是比较值 * @return 行数 */ default Integer selectCountAccurate(Map param) { return selectCount(Wrappers.query().allEq(param)); } /** * 模糊分页查询。 * * @param page 分页查询对象 * @param param key须是数据库字段,value是比较值 * @return 分页对象 */ default Page selectPagingBlurry(Page page, Map param) { QueryWrapper query = Wrappers.query(); if (null != param) { param.forEach((k, v) -> { query.like(k, v); }); } return selectPaging(page, query); } /** * 模糊总数查询。 * * @param param key须是数据库字段,value是比较值 * @return 行数 */ default Integer selectCountBlurry(Map param) { QueryWrapper query = Wrappers.query(); if (null != param) { param.forEach((k, v) -> { query.like(k, v); }); } return selectCount(query); } /** * 内部使用方法 强转{@code Ipage}对象。 * * @param page 分页对象 * @param queryWrapper 查询条件 * @return 结果分页对象 */ default Page selectPaging (Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper) { //return (Page)selectPage((IPage)page, queryWrapper); return selectPage(page, queryWrapper); } /** * 插入如果中已经存在相同的记录,则忽略当前新数据。 * * @param entity 实体对象 * @return 行数 */ int insertIgnore(T entity); /** * 表示插入替换数据,需求表中有PrimaryKey,或者unique索引,如果数据库已经存在数据,则用新数据替换,如果没有数据效果则和insert into一样。 * * @param entity 实体对象 * @return 更改的条数 */ int replace(T entity); /** * 批量插入。 * * @param entityList 实体对象集合 * @return 行数 */ int insertBatchSomeColumn(List entityList); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy