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);
}
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");
}
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");
}
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;
}
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");
}
Aggregations