mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
feat: selectAll(class,...exclude) 查询全部并排除部分字段
This commit is contained in:
parent
f249368ba7
commit
9500ff6d66
@ -123,10 +123,10 @@ public class MPJLambdaWrapper<T> extends JoinAbstractLambdaWrapper<T, MPJLambdaW
|
||||
* 不建议直接 new 该实例,使用 JoinWrappers.lambda(UserDO.class)
|
||||
*/
|
||||
protected MPJLambdaWrapper(T entity, Class<T> entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq,
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments, SharedString paramAlias,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableList tableList, Integer index, String keyWord, Class<?> joinClass, String tableName,
|
||||
BiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments, SharedString paramAlias,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableList tableList, Integer index, String keyWord, Class<?> joinClass, String tableName,
|
||||
BiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
super.setEntity(entity);
|
||||
super.setEntityClass(entityClass);
|
||||
this.paramNameSeq = paramNameSeq;
|
||||
@ -197,6 +197,30 @@ public class MPJLambdaWrapper<T> extends JoinAbstractLambdaWrapper<T, MPJLambdaW
|
||||
return Query.super.selectAll(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体类全部字段
|
||||
*
|
||||
* @param clazz 查询的实体类
|
||||
* @param exclude 排除字段
|
||||
*/
|
||||
@Override
|
||||
@SafeVarargs
|
||||
public final <E> MPJLambdaWrapper<T> selectAll(Class<E> clazz, SFunction<E, ?>... exclude) {
|
||||
return Query.super.selectAll(clazz, exclude);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体类全部字段
|
||||
*
|
||||
* @param clazz 查询的实体类
|
||||
* @param exclude 排除字段
|
||||
*/
|
||||
@Override
|
||||
@SafeVarargs
|
||||
public final <E> MPJLambdaWrapper<T> selectAll(Class<E> clazz, String prefix, SFunction<E, ?>... exclude) {
|
||||
return Query.super.selectAll(clazz, prefix, exclude);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主表全部字段
|
||||
* <p>
|
||||
|
@ -16,8 +16,7 @@ import com.github.yulichang.wrapper.enums.DefaultFuncEnum;
|
||||
import com.github.yulichang.wrapper.segments.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
@ -173,6 +172,38 @@ public interface Query<Children> extends Serializable {
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体类全部字段
|
||||
*
|
||||
* @param clazz 查询的实体类
|
||||
* @param exclude 排除字段
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <E> Children selectAll(Class<E> clazz, SFunction<E, ?>... exclude) {
|
||||
Set<String> excludeSet = Arrays.stream(exclude).map(i ->
|
||||
LambdaUtils.getName(i).toUpperCase(Locale.ENGLISH)).collect(Collectors.toSet());
|
||||
getSelectColum().addAll(ColumnCache.getListField(clazz).stream().filter(e ->
|
||||
!excludeSet.contains(e.getColumProperty().toUpperCase(Locale.ENGLISH))).map(i ->
|
||||
new SelectNormal(i, getIndex(), isHasAlias(), getAlias())).collect(Collectors.toList()));
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体类全部字段
|
||||
*
|
||||
* @param clazz 查询的实体类
|
||||
* @param exclude 排除字段
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <E> Children selectAll(Class<E> clazz, String prefix, SFunction<E, ?>... exclude) {
|
||||
Set<String> excludeSet = Arrays.stream(exclude).map(i ->
|
||||
LambdaUtils.getName(i).toUpperCase(Locale.ENGLISH)).collect(Collectors.toSet());
|
||||
getSelectColum().addAll(ColumnCache.getListField(clazz).stream().filter(e ->
|
||||
!excludeSet.contains(e.getColumProperty().toUpperCase(Locale.ENGLISH))).map(e ->
|
||||
new SelectNormal(e, getIndex(), true, prefix)).collect(Collectors.toList()));
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* select sql 片段
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user