|
@@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
|
import org.apache.ibatis.reflection.property.PropertyNamer;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class Select<T> {
|
|
|
|
|
@@ -56,17 +59,26 @@ public class Select<T> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public Select<T> selectAll(Class<?> cls) {
|
|
|
- return selectAll(sql.getTableAlias(cls), cls);
|
|
|
+ @SafeVarargs
|
|
|
+ public final <S> Select<T> selectAll(Class<S> cls, SFunction<S, ?>... excludeFunction) {
|
|
|
+ return selectAll(sql.getTableAlias(cls), cls, excludeFunction);
|
|
|
}
|
|
|
|
|
|
- public Select<T> selectAll(String alias, Class<?> cls) {
|
|
|
+ @SafeVarargs
|
|
|
+ public final <S> Select<T> selectAll(String alias, Class<S> cls, SFunction<S, ?>... excludeFunction) {
|
|
|
+ Set<String> excludeNameSet = Arrays.stream(excludeFunction)
|
|
|
+ .map(item -> PropertyNamer.methodToProperty(LambdaUtils.extract(item).getImplMethodName()))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
Field[] fields = ReflectUtil.getFields(cls);
|
|
|
for (Field field : fields) {
|
|
|
String fieldName = ReflectUtil.getFieldName(field);
|
|
|
if ("serialVersionUID".equals(fieldName)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if (excludeNameSet.contains(fieldName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
TableField tableField = field.getAnnotation(TableField.class);
|
|
|
if (tableField != null) {
|
|
|
if (!tableField.exist() || !tableField.select()) {
|