Skip to content

Commit

Permalink
feat-Column-列的数据类型改为ColumnType,并优化旧有的单元测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Nov 11, 2024
1 parent aa636eb commit c67e582
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.ximatai.muyun.base.BaseScaffold;
import net.ximatai.muyun.core.config.MuYunConfig;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.platform.controller.ModuleController;
import net.ximatai.muyun.platform.model.ModuleAction;
Expand Down Expand Up @@ -105,7 +106,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"));
.addColumn(Column.of("v_name").setType(ColumnType.VARCHAR));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.PageResult;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
Expand All @@ -23,7 +24,9 @@

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

@QuarkusTest
@QuarkusTestResource(value = PostgresTestResource.class, restrictToAnnotatedClass = true)
Expand Down Expand Up @@ -289,8 +292,8 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar")) // 字段名
.addColumn(Column.of("t_create"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR)) // 字段名
.addColumn(Column.of("t_create"))
.addColumn(Column.of("t_update"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.ximatai.muyun.ability.curd.std.ICURDAbility;
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -190,11 +191,11 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"))
.addColumn(Column.of("names").setType("varchar[]"))
.addColumn(Column.of("ints").setType("int[]"))
.addColumn(Column.of("json_test").setType("jsonb"));
.addColumn(Column.of("names").setType(ColumnType.VARCHAR_ARRAY))
.addColumn(Column.of("ints").setType(ColumnType.INT_ARRAY))
.addColumn(Column.of("json_test").setType(ColumnType.JSON));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.QueryItem;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
Expand Down Expand Up @@ -82,7 +83,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.ximatai.muyun.ability.curd.std.ICURDAbility;
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.DataChangeChannel;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
Expand Down Expand Up @@ -104,7 +105,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name2").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("v_name2"))
.addColumn(Column.of("t_create").setDefaultValue("now()"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("t_create").setDefaultValue("now()"));
}

Expand Down Expand Up @@ -347,7 +347,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("id_at_testmain"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.PageResult;
import net.ximatai.muyun.model.QueryItem;
Expand Down Expand Up @@ -283,7 +284,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.PageResult;
import net.ximatai.muyun.model.QueryItem;
Expand Down Expand Up @@ -87,7 +88,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar")) // 字段名
.addColumn(Column.of("name").setType(ColumnType.VARCHAR)) // 字段名
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.PageResult;
import net.ximatai.muyun.model.QueryItem;
Expand Down Expand Up @@ -115,8 +116,8 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("id_at_test_table_referable").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("id_at_test_table_referable").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down Expand Up @@ -159,7 +160,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn("id_at_test_table_referable2")
.addColumn(Column.of("t_create"));

Expand Down Expand Up @@ -197,7 +198,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("t_create"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_for_sign").setType("varchar"))
.addColumn(Column.of("v_for_encrypt").setType("varchar"))
.addColumn(Column.of("pid").setType("varchar"))
.addColumn(Column.of("v_for_sign"))
.addColumn(Column.of("v_for_encrypt"))
.addColumn(Column.of("pid"))
.addColumn(Column.of("t_create").setDefaultValue("now()"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.ximatai.muyun.ability.curd.std.ICURDAbility;
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.DataType;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -80,9 +80,9 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType(DataType.VARCHAR))
.addColumn(Column.of("age").setType(DataType.INT))
.addColumn(Column.of("creat_time").setType(DataType.DATE))
.addColumn(Column.of("update_time").setType(DataType.TIMESTAMP)); // 字段名
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("age").setType(ColumnType.INT))
.addColumn(Column.of("creat_time").setType(ColumnType.DATE))
.addColumn(Column.of("update_time").setType(ColumnType.TIMESTAMP)); // 字段名
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.ximatai.muyun.core.Scaffold;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.ColumnType;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.model.PageResult;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
Expand Down Expand Up @@ -100,7 +101,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("name").setType("varchar"))
.addColumn(Column.of("name").setType(ColumnType.VARCHAR))
.addColumn(Column.of("t_create").setDefaultValue("now()"));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("t_create").setDefaultValue("now()"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ public String getMainTable() {
public void fitOut(TableWrapper wrapper) {
wrapper
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn(Column.of("v_name").setType("varchar"))
.addColumn(Column.of("pid").setType("varchar"))
.addColumn(Column.of("v_name"))
.addColumn(Column.of("pid"))
.addColumn(Column.of("t_create").setDefaultValue("now()"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void testTableBuilder() {
.setSchema("test")
.setComment("a demo")
.setPrimaryKey(ID_POSTGRES)
.addColumn(Column.of("v_test").setType("varchar"))
.addColumn(Column.of("v_test2").setType("varchar"))
.addColumn(Column.of("v_test"))
.addColumn(Column.of("v_test2"))
.addColumn(Column.of("b_test").setDefaultValue(true))
.addIndex("v_test")
.addIndex("v_test2", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.ximatai.muyun.core.security.AbstractEncryptor;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.DataType;
import net.ximatai.muyun.database.builder.ColumnType;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -35,7 +35,7 @@ default List<Column> getSignColumns() {
return getColumnsForSigning().stream()
.map(this::column2SignColumn)
.map(Column::of)
.map(c -> c.setType(DataType.VARCHAR))
.map(c -> c.setType(ColumnType.VARCHAR))
.toList();
}

Expand Down
Loading

0 comments on commit c67e582

Please sign in to comment.