|
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
|
|
|
|
import java.util.Map;
|
|
@@ -110,7 +111,25 @@ public class LambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, LambdaQueryW
|
|
|
@Override
|
|
|
public LambdaQueryWrapper<T> select(Class<T> entityClass, Predicate<TableFieldInfo> predicate) {
|
|
|
super.setEntityClass(entityClass);
|
|
|
- this.sqlSelect.setStringValue(TableInfoHelper.getTableInfo(getEntityClass()).chooseSelect(predicate));
|
|
|
+ return select(predicate);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 过滤查询的字段信息(主键除外!)
|
|
|
+ * <p>例1: 只要 java 字段名以 "test" 开头的 -> select(i -> i.getProperty().startsWith("test"))</p>
|
|
|
+ * <p>例2: 只要 java 字段属性是 CharSequence 类型的 -> select(TableFieldInfo::isCharSequence)</p>
|
|
|
+ * <p>例3: 只要 java 字段没有填充策略的 -> select(i -> i.getFieldFill() == FieldFill.DEFAULT)</p>
|
|
|
+ * <p>例4: 要全部字段 -> select(i -> true)</p>
|
|
|
+ * <p>例5: 只要主键字段 -> select(i -> false)</p>
|
|
|
+ *
|
|
|
+ * @param predicate 过滤方式
|
|
|
+ * @return this
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public LambdaQueryWrapper<T> select(Predicate<TableFieldInfo> predicate) {
|
|
|
+ Class<T> entityClass = getEntityClass();
|
|
|
+ Assert.notNull(entityClass, "entityClass can not be null");
|
|
|
+ this.sqlSelect.setStringValue(TableInfoHelper.getTableInfo(entityClass).chooseSelect(predicate));
|
|
|
return typedThis;
|
|
|
}
|
|
|
|