rebuild: 标记 TableDef 为废弃类。

This commit is contained in:
Suomm 2024-03-11 20:15:45 +08:00
parent fa2639537f
commit 22fd37f004
4 changed files with 62 additions and 5 deletions

View File

@ -4,7 +4,7 @@
package #(packageConfig.tableDefPackage); package #(packageConfig.tableDefPackage);
import com.mybatisflex.core.query.QueryColumn; import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryTable; import com.mybatisflex.core.table.TableDef;
#if(jdkVersion >= 14) #if(jdkVersion >= 14)
import java.io.Serial; import java.io.Serial;
@ -16,7 +16,7 @@ import java.io.Serial;
* @author #(javadocConfig.getAuthor()) * @author #(javadocConfig.getAuthor())
* @since #(javadocConfig.getSince()) * @since #(javadocConfig.getSince())
*/ */
public class #(tableDefClassName) extends QueryTable { public class #(tableDefClassName) extends TableDef {
#if(jdkVersion >= 14) #if(jdkVersion >= 14)
@Serial @Serial

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mybatisflex.core.table;
import com.mybatisflex.core.query.QueryTable;
/**
* 表定义内包含字段
*
* @author 王帅
* @since 2024-03-11
*/
@Deprecated
public abstract class TableDef extends QueryTable {
protected TableDef(String schema, String tableName) {
super(schema, tableName);
}
protected TableDef(String schema, String tableName, String alias) {
super(schema, tableName, alias);
}
/**
* 使用 {@link #getName()} 替代
*
* @return 表名
*/
@Deprecated
public String getTableName() {
return name;
}
}

View File

@ -54,7 +54,16 @@ public class AccountSqlTester {
.from(ar) .from(ar)
.leftJoin(a1).on(a1.ID.eq(ar.ACCOUNT_ID)) .leftJoin(a1).on(a1.ID.eq(ar.ACCOUNT_ID))
.leftJoin(a2).on(a2.ID.eq(ar.ACCOUNT_ID)); .leftJoin(a2).on(a2.ID.eq(ar.ACCOUNT_ID));
System.out.println(SqlFormatter.format(queryWrapper.toSQL())); String sql = SqlFormatter.format(queryWrapper.toSQL());
Assert.assertEquals("SELECT\n" +
" ` ar `.` content `,\n" +
" ` a1 `.` id `,\n" +
" ` a2 `.` age `\n" +
"FROM\n" +
" ` tb_article ` AS ` ar `\n" +
" LEFT JOIN ` tb_account ` AS ` a1 ` ON ` a1 `.` id ` = ` ar `.` account_id `\n" +
" LEFT JOIN ` tb_account ` AS ` a2 ` ON ` a2 `.` id ` = ` ar `.` account_id `", sql);
System.out.println(sql);
} }
@Test @Test

View File

@ -66,9 +66,9 @@ public class ContentBuilder {
StringBuilder content = new StringBuilder("package "); StringBuilder content = new StringBuilder("package ");
content.append(tableDefPackage).append(";\n\n"); content.append(tableDefPackage).append(";\n\n");
content.append("import com.mybatisflex.core.query.QueryColumn;\n"); content.append("import com.mybatisflex.core.query.QueryColumn;\n");
content.append("import com.mybatisflex.core.query.QueryTable;\n\n"); content.append("import com.mybatisflex.core.table.TableDef;\n\n");
content.append("// Auto generate by mybatis-flex, do not modify it.\n"); content.append("// Auto generate by mybatis-flex, do not modify it.\n");
content.append("public class ").append(tableDefClassName).append(" extends QueryTable {\n\n"); content.append("public class ").append(tableDefClassName).append(" extends TableDef {\n\n");
//TableDef 类的属性名称 //TableDef 类的属性名称
String tableDefPropertyName = null; String tableDefPropertyName = null;