Skip to content

Commit

Permalink
fix-ISelectAbility-传入错误的排序字段导致的报错
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Sep 27, 2024
1 parent f010e5c commit 57a0e2b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
72 changes: 72 additions & 0 deletions my-boot/src/test/java/net/ximatai/muyun/test/core/TestNaked.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package net.ximatai.muyun.test.core;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.common.mapper.TypeRef;
import jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;
import jakarta.ws.rs.Path;
import net.ximatai.muyun.ability.IDatabaseAbility;
import net.ximatai.muyun.ability.IMetadataAbility;
import net.ximatai.muyun.ability.ITableCreateAbility;
import net.ximatai.muyun.ability.curd.std.ISelectAbility;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.Column;
import net.ximatai.muyun.database.builder.TableWrapper;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;

@QuarkusTest
@QuarkusTestResource(value = PostgresTestResource.class, restrictToAnnotatedClass = true)
public class TestNaked {

@Test
void test() {
given()
.queryParam("sort", "t_create,desc")
.get("/demo/view")
.then()
.statusCode(200)
.extract()
.as(new TypeRef<>() {
});
}
}

@Path("/demo")
class Demo implements IDatabaseAbility, IMetadataAbility, ITableCreateAbility, ISelectAbility {

@Inject
IDatabaseOperations databaseOperations;

@PostConstruct
void init() {
create(getDatabaseOperations());
}

@Override
public String getSchemaName() {
return "public";
}

@Override
public String getMainTable() {
return "demo";
}

@Override
public IDatabaseOperations getDatabaseOperations() {
return databaseOperations;
}

@Override
public TableWrapper getTableWrapper() {
return TableWrapper.withName("demo")
.setSchema(getSchemaName())
.setPrimaryKey(Column.ID_POSTGRES)
.addColumn("v_name")
.addColumn("i_age");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.ximatai.muyun.ability;

import jakarta.annotation.PostConstruct;
import jakarta.transaction.Transactional;
import net.ximatai.muyun.database.IDatabaseOperations;
import net.ximatai.muyun.database.builder.TableBuilder;
Expand All @@ -14,7 +13,6 @@ default void onTableCreated(boolean isFirst) {
}

@Transactional
@PostConstruct
default void create(IDatabaseOperations db) {
TableWrapper wrapper = getTableWrapper();
if (this instanceof ICommonBusinessAbility ability) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ default PageResult view(Integer page,
if (strings.length > 1) {
order = strings[1];
}
orderColumns.add(new SortColumn(strings[0], order));
if (checkColumn(strings[0])) {
orderColumns.add(new SortColumn(strings[0], order));
}
});
}

Expand Down

0 comments on commit 57a0e2b

Please sign in to comment.