com.baomidou.mybatisplus.extension.toolkit.ChainWrappers Maven / Gradle / Ivy
/*
* Copyright (c) 2011-2022, baomidou ([email protected]).
*
* 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.toolkit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.baomidou.mybatisplus.extension.kotlin.KtQueryChainWrapper;
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateChainWrapper;
/**
* 快捷构造 chain 式调用的工具类
*
* @author miemie
* @since 2019-11-28
* @since 3.3.0
*/
public final class ChainWrappers {
private ChainWrappers() {
// ignore
}
/**
* 链式查询 普通
*
* @return QueryWrapper 的包装类
*/
public static QueryChainWrapper queryChain(BaseMapper mapper) {
return new QueryChainWrapper<>(mapper);
}
public static QueryChainWrapper queryChain(Class entityClass) {
return new QueryChainWrapper<>(entityClass);
}
/**
* 链式查询 lambda 式
* 注意:不支持 Kotlin
*
* @return LambdaQueryWrapper 的包装类
*/
public static LambdaQueryChainWrapper lambdaQueryChain(BaseMapper mapper) {
return new LambdaQueryChainWrapper<>(mapper);
}
public static LambdaQueryChainWrapper lambdaQueryChain(Class entityClass) {
return new LambdaQueryChainWrapper<>(entityClass);
}
/**
* 链式查询 lambda 式
* 注意:不支持 Kotlin
*
* @return LambdaQueryWrapper 的包装类
*/
public static LambdaQueryChainWrapper lambdaQueryChain(BaseMapper mapper, T entity) {
return new LambdaQueryChainWrapper<>(mapper, entity);
}
/**
* 链式查询 lambda 式
* 注意:不支持 Kotlin
*
* @return LambdaQueryWrapper 的包装类
*/
public static LambdaQueryChainWrapper lambdaQueryChain(BaseMapper mapper, Class entityClass) {
return new LambdaQueryChainWrapper<>(mapper, entityClass);
}
/**
* 链式查询 lambda 式
* 仅支持 Kotlin
*
* @return KtQueryWrapper 的包装类
*/
public static KtQueryChainWrapper ktQueryChain(BaseMapper mapper, Class entityClass) {
return new KtQueryChainWrapper<>(mapper, entityClass);
}
/**
* 链式查询 lambda 式
* 仅支持 Kotlin
*
* @return KtQueryWrapper 的包装类
*/
public static KtQueryChainWrapper ktQueryChain(BaseMapper mapper, T entity) {
return new KtQueryChainWrapper<>(mapper, entity);
}
/**
* 链式更改 普通
*
* @return UpdateWrapper 的包装类
*/
public static UpdateChainWrapper updateChain(BaseMapper mapper) {
return new UpdateChainWrapper<>(mapper);
}
public static UpdateChainWrapper updateChain(Class entityClass) {
return new UpdateChainWrapper<>(entityClass);
}
/**
* 链式更改 lambda 式
* 注意:不支持 Kotlin
*
* @return LambdaUpdateWrapper 的包装类
*/
public static LambdaUpdateChainWrapper lambdaUpdateChain(BaseMapper mapper) {
return new LambdaUpdateChainWrapper<>(mapper);
}
public static LambdaUpdateChainWrapper lambdaUpdateChain(Class entityClass) {
return new LambdaUpdateChainWrapper<>(entityClass);
}
/**
* 链式更改 lambda 式
* 仅支持 Kotlin
*
* @return KtQueryWrapper 的包装类
*/
public static KtUpdateChainWrapper ktUpdateChain(BaseMapper mapper, Class entityClass) {
return new KtUpdateChainWrapper<>(mapper, entityClass);
}
/**
* 链式更改 lambda 式
* 仅支持 Kotlin
*
* @return KtQueryWrapper 的包装类
*/
public static KtUpdateChainWrapper ktUpdateChain(BaseMapper mapper, T entity) {
return new KtUpdateChainWrapper<>(mapper, entity);
}
}