feat: 增加主表,以增加快速查询
This commit is contained in:
parent
9c16ca2a8d
commit
8329fd17a9
@ -41,6 +41,9 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
|
||||
// 调试标识
|
||||
private final boolean debug = false;
|
||||
|
||||
// 主表class,默认是第一个from的表为主表
|
||||
private Class<?> primaryClass;
|
||||
|
||||
/**
|
||||
* 绑定实现类
|
||||
*
|
||||
@ -105,6 +108,7 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
|
||||
*/
|
||||
@Override
|
||||
public HandleSqlChain from(Class<?> type, String alias) {
|
||||
this.primaryClass = type;
|
||||
String mapped = AliasComposite.add(type, alias);
|
||||
return concat("FROM")
|
||||
.concat(() -> EntityNameUtils.getTableName(type))
|
||||
@ -176,6 +180,11 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T one() {
|
||||
return one(SqlNameUtils.cast(primaryClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行并获取结果
|
||||
*
|
||||
@ -186,6 +195,11 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
|
||||
return SHARED_OPERATIONS.selectOne(entity(), clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> list() {
|
||||
return list(SqlNameUtils.cast(primaryClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行并获取多条结果
|
||||
*
|
||||
|
@ -11,6 +11,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface AfterOrderSqlChain extends ExecutableSql {
|
||||
|
||||
/**
|
||||
* 执行并获取结果
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @return 单一结果值
|
||||
*/
|
||||
<T> T one();
|
||||
|
||||
/**
|
||||
* 执行并获取结果
|
||||
*
|
||||
@ -20,6 +28,14 @@ public interface AfterOrderSqlChain extends ExecutableSql {
|
||||
*/
|
||||
<T> T one(Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 执行并获取多条结果,以主表class为结果
|
||||
*
|
||||
* @param <T> 结果泛型
|
||||
* @return 结果列表
|
||||
*/
|
||||
<T> List<T> list();
|
||||
|
||||
/**
|
||||
* 执行并获取多条结果
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user