mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
selectAs重载
This commit is contained in:
parent
693a18e5b9
commit
7744f7c3a0
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.github.yulichang.toolkit.LambdaUtils;
|
||||
import com.github.yulichang.toolkit.MPJReflectionKit;
|
||||
@ -71,6 +72,28 @@ public interface Query<Children> extends Serializable {
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* String 查询
|
||||
*
|
||||
* @param column 列
|
||||
*/
|
||||
default <E> Children select(String column, SFunction<E, ?> alias) {
|
||||
getSelectColum().add(new SelectString(column + Constants.AS + LambdaUtils.getName(alias)));
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* String 查询
|
||||
*
|
||||
* @param column 列
|
||||
*/
|
||||
default <E> Children select(String index, SFunction<E, ?> column, SFunction<E, ?> alias) {
|
||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(LambdaUtils.getEntityClass(column));
|
||||
SelectCache cache = cacheMap.get(LambdaUtils.getName(column));
|
||||
getSelectColum().add(new SelectString(index + Constants.DOT + cache.getColumn() + Constants.AS + LambdaUtils.getName(alias)));
|
||||
return getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* 说明:
|
||||
* 比如我们需要查询用户表有10个字段,然而我们只需要3个就够了,用mybatis-plus提供的select<p />
|
||||
|
Loading…
x
Reference in New Issue
Block a user