mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed 53f6bcd from https://gitee.com/Suomm/mybatis-flex/pulls/261
feat: 自动添加 SQL FROM 语句,提供 as() 方法设置表别名。
This commit is contained in:
parent
9889889087
commit
35bc85aa58
@ -44,11 +44,20 @@ public abstract class QueryModel<T extends QueryModel<T>> {
|
|||||||
|
|
||||||
protected QueryWrapper queryWrapper() {
|
protected QueryWrapper queryWrapper() {
|
||||||
if (queryWrapper == null) {
|
if (queryWrapper == null) {
|
||||||
queryWrapper = QueryWrapper.create();
|
TableInfo tableInfo = TableInfoFactory.ofEntityClass(getClass());
|
||||||
|
QueryTable queryTable = new QueryTable();
|
||||||
|
queryTable.setSchema(tableInfo.getSchema());
|
||||||
|
queryTable.setName(tableInfo.getTableName());
|
||||||
|
queryWrapper = QueryWrapper.create().from(queryTable);
|
||||||
}
|
}
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T as(String alias) {
|
||||||
|
queryWrapper().as(alias);
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
|
||||||
public T select() {
|
public T select() {
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user