Search in sources :

Example 1 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor in project solon by noear.

the class MybatisPlusInterceptorTest method setProperties.

@Test
void setProperties() {
    Properties properties = new Properties();
    properties.setProperty("@page", "com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor");
    properties.setProperty("page:maxLimit", "10");
    properties.setProperty("page:dbType", "h2");
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.setProperties(properties);
    List<InnerInterceptor> interceptors = interceptor.getInterceptors();
    assertThat(interceptors).isNotEmpty();
    assertThat(interceptors.size()).isEqualTo(1);
    InnerInterceptor page = interceptors.get(0);
    assertThat(page).isInstanceOf(PaginationInnerInterceptor.class);
    PaginationInnerInterceptor pii = (PaginationInnerInterceptor) page;
    assertThat(pii.getMaxLimit()).isEqualTo(10);
    assertThat(pii.getDbType()).isEqualTo(DbType.H2);
}
Also used : PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) Properties(java.util.Properties) PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) InnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.InnerInterceptor) Test(org.junit.jupiter.api.Test)

Example 2 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor in project solon by noear.

the class SelectBodyToPlainSelectTest method testPaginationInterceptorConcatOrderByFixWithWhere.

@Test
void testPaginationInterceptorConcatOrderByFixWithWhere() {
    String actualSqlWhere = new PaginationInnerInterceptor().concatOrderBy("select * from test where 1 = 1 union select * from test2 where 1 = 1", ITEMS);
    assertThat(actualSqlWhere).isEqualTo("SELECT * FROM test WHERE 1 = 1 UNION SELECT * FROM test2 WHERE 1 = 1 ORDER BY column ASC");
    String actualSqlUnionAll = new PaginationInnerInterceptor().concatOrderBy("select * from test where 1 = 1 union all select * from test2 where 1 = 1 ", ITEMS);
    assertThat(actualSqlUnionAll).isEqualTo("SELECT * FROM test WHERE 1 = 1 UNION ALL SELECT * FROM test2 WHERE 1 = 1 ORDER BY column ASC");
}
Also used : PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) Test(org.junit.jupiter.api.Test)

Example 3 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor in project solon by noear.

the class SelectBodyToPlainSelectTest method testPaginationInterceptorConcatOrderByBefore.

@Test
void testPaginationInterceptorConcatOrderByBefore() {
    String actualSql = new PaginationInnerInterceptor().concatOrderBy("select * from test", ITEMS);
    assertThat(actualSql).isEqualTo("SELECT * FROM test ORDER BY column ASC");
    String actualSqlWhere = new PaginationInnerInterceptor().concatOrderBy("select * from test where 1 = 1", ITEMS);
    assertThat(actualSqlWhere).isEqualTo("SELECT * FROM test WHERE 1 = 1 ORDER BY column ASC");
}
Also used : PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) Test(org.junit.jupiter.api.Test)

Example 4 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor in project solon by noear.

the class Config method plusInterceptor.

@Bean
public Interceptor plusInterceptor() {
    MybatisPlusInterceptor plusInterceptor = new MybatisPlusInterceptor();
    plusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    return plusInterceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.solon.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) Bean(org.noear.solon.annotation.Bean)

Example 5 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor in project solon by noear.

the class SelectBodyToPlainSelectTest method testPaginationInterceptorConcatOrderByFix.

@Test
void testPaginationInterceptorConcatOrderByFix() {
    List<OrderItem> orderList = new ArrayList<>();
    orderList.add(OrderItem.asc("column"));
    String actualSql = new PaginationInnerInterceptor().concatOrderBy("select * from test union select * from test2", orderList);
    assertThat(actualSql).isEqualTo("SELECT * FROM test UNION SELECT * FROM test2 ORDER BY column ASC");
    String actualSqlUnionAll = new PaginationInnerInterceptor().concatOrderBy("select * from test union all select * from test2", orderList);
    assertThat(actualSqlUnionAll).isEqualTo("SELECT * FROM test UNION ALL SELECT * FROM test2 ORDER BY column ASC");
}
Also used : OrderItem(com.baomidou.mybatisplus.core.metadata.OrderItem) ArrayList(java.util.ArrayList) PaginationInnerInterceptor(com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor) Test(org.junit.jupiter.api.Test)

Aggregations

PaginationInnerInterceptor (com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor)7 Test (org.junit.jupiter.api.Test)5 MybatisPlusInterceptor (com.baomidou.mybatisplus.solon.plugins.MybatisPlusInterceptor)2 Bean (org.noear.solon.annotation.Bean)2 OrderItem (com.baomidou.mybatisplus.core.metadata.OrderItem)1 InnerInterceptor (com.baomidou.mybatisplus.solon.plugins.inner.InnerInterceptor)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1