public interface Query<Children> extends Serializable
Query| 限定符和类型 | 方法和说明 |
|---|---|
String |
getAlias() |
Children |
getChildren() |
Integer |
getIndex() |
List<Select> |
getSelectColum() |
String |
getSqlSelect()
select sql 片段
|
boolean |
isHasAlias() |
default Children |
select(Class<?> entityClass,
java.util.function.Predicate<com.baomidou.mybatisplus.core.metadata.TableFieldInfo> predicate)
已过时。
|
Children |
select(kotlin.reflect.KProperty<?>... columns) |
default Children |
select(String... columns)
String 查询
|
default Children |
selectAll(Class<?> clazz)
查询实体类全部字段
|
default Children |
selectAll(Class<?> clazz,
String prefix)
查询实体类全部字段
|
default Children |
selectAs(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias)
ignore
|
default Children |
selectAs(kotlin.reflect.KProperty<?> column,
String alias)
别名查询
|
default Children |
selectAs(String column,
kotlin.reflect.KProperty<?> alias)
String 查询
|
default Children |
selectAs(String index,
kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias)
String 查询
|
default Children |
selectAsClass(Class<?> source,
Class<?> tag)
说明:
比如我们需要查询用户表有10个字段,然而我们只需要3个就够了,用mybatis-plus提供的select
需要一个属性一个属性填入很不优雅,现在我们可以用selectAsClass(UserDO.class, UserVo.class)
即可按所需的UserVo返回,前提是UserVo.class中的属性必须是UserDO.class中存在的
|
default Children |
selectAvg(kotlin.reflect.KProperty<?> column)
MIN()
|
default Children |
selectAvg(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectAvg(kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectCount(kotlin.reflect.KProperty<?> column)
COUNT()
|
default Children |
selectCount(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectCount(kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectCount(Object column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectCount(Object column,
String alias) |
default Children |
selectFilter(Class<?> entityClass,
java.util.function.Predicate<SelectCache> predicate)
过滤查询的字段信息
例1: 只要 java 字段名以 "test" 开头的 -> select(i -> i.getProperty().startsWith("test"))
例2: 只要 java 字段属性是 CharSequence 类型的 -> select(TableFieldInfo::isCharSequence)
例3: 只要 java 字段没有填充策略的 -> select(i -> i.getFieldFill() == FieldFill.DEFAULT)
例4: 要全部字段 -> select(i -> true)
例5: 只要主键字段 -> select(i -> false)
|
default Children |
selectFunc(BaseFuncEnum funcEnum,
kotlin.reflect.KProperty<?> column) |
default Children |
selectFunc(BaseFuncEnum funcEnum,
kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectFunc(BaseFuncEnum funcEnum,
kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectFunc(BaseFuncEnum funcEnum,
Object column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectFunc(BaseFuncEnum funcEnum,
Object column,
String alias)
聚合函数查询
wrapper.selectFunc(() -> "COUNT(%s)", "t.id", "total");
lambda
wrapper.selectFunc(() -> "COUNT(%s)", UserDO::getId, UserDTO::getTotal);
|
default Children |
selectFunc(String sql,
java.util.function.Function<FuncArgs,SelectFunc.Arg[]> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectFunc(String sql,
java.util.function.Function<FuncArgs,SelectFunc.Arg[]> column,
String alias) |
default Children |
selectLen(kotlin.reflect.KProperty<?> column)
LEN()
|
default Children |
selectLen(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectLen(kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectMax(kotlin.reflect.KProperty<?> column)
MAX()
|
default Children |
selectMax(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectMax(kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectMin(kotlin.reflect.KProperty<?> column)
MIN()
|
default Children |
selectMin(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectMin(kotlin.reflect.KProperty<?> column,
String alias) |
default Children |
selectSum(kotlin.reflect.KProperty<?> column)
SUM()
|
default Children |
selectSum(kotlin.reflect.KProperty<?> column,
kotlin.reflect.KProperty<?> alias) |
default Children |
selectSum(kotlin.reflect.KProperty<?> column,
String alias) |
Children getChildren()
Integer getIndex()
boolean isHasAlias()
String getAlias()
@Deprecated default Children select(Class<?> entityClass, java.util.function.Predicate<com.baomidou.mybatisplus.core.metadata.TableFieldInfo> predicate)
predicate - 过滤方式selectFilter(Class, Predicate)default Children selectFilter(Class<?> entityClass, java.util.function.Predicate<SelectCache> predicate)
例1: 只要 java 字段名以 "test" 开头的 -> select(i -> i.getProperty().startsWith("test"))
例2: 只要 java 字段属性是 CharSequence 类型的 -> select(TableFieldInfo::isCharSequence)
例3: 只要 java 字段没有填充策略的 -> select(i -> i.getFieldFill() == FieldFill.DEFAULT)
例4: 要全部字段 -> select(i -> true)
例5: 只要主键字段 -> select(i -> false)
predicate - 过滤方式Children select(kotlin.reflect.KProperty<?>... columns)
default Children selectAs(String column, kotlin.reflect.KProperty<?> alias)
column - 列default Children selectAs(String index, kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
column - 列default Children selectAsClass(Class<?> source, Class<?> tag)
source - 数据源实体类tag - 目标类default Children selectAs(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
String getSqlSelect()
default Children selectFunc(BaseFuncEnum funcEnum, Object column, String alias)
wrapper.selectFunc(() -> "COUNT(%s)", "t.id", "total");
lambda wrapper.selectFunc(() -> "COUNT(%s)", UserDO::getId, UserDTO::getTotal);
funcEnum - 函数枚举 DefaultFuncEnumcolumn - 函数作用的字段alias - 别名default Children selectFunc(BaseFuncEnum funcEnum, kotlin.reflect.KProperty<?> column, String alias)
default Children selectFunc(BaseFuncEnum funcEnum, kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectFunc(BaseFuncEnum funcEnum, kotlin.reflect.KProperty<?> column)
default Children selectFunc(BaseFuncEnum funcEnum, Object column, kotlin.reflect.KProperty<?> alias)
default Children selectFunc(String sql, java.util.function.Function<FuncArgs,SelectFunc.Arg[]> column, String alias)
default Children selectFunc(String sql, java.util.function.Function<FuncArgs,SelectFunc.Arg[]> column, kotlin.reflect.KProperty<?> alias)
default Children selectSum(kotlin.reflect.KProperty<?> column)
default Children selectSum(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectCount(kotlin.reflect.KProperty<?> column)
default Children selectCount(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectMax(kotlin.reflect.KProperty<?> column)
default Children selectMax(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectMin(kotlin.reflect.KProperty<?> column)
default Children selectMin(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectAvg(kotlin.reflect.KProperty<?> column)
default Children selectAvg(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
default Children selectLen(kotlin.reflect.KProperty<?> column)
default Children selectLen(kotlin.reflect.KProperty<?> column, kotlin.reflect.KProperty<?> alias)
Copyright © 2023. All rights reserved.