use of com.mendmix.common.model.OrderBy in project jeesuite-libs by vakinge.
the class SqlRewriteHandler method handleTableOrderBy.
private void handleTableOrderBy(PlainSelect selectBody, Table table, InvocationVals invocation) {
PageParams pageParam = invocation.getPageParam();
if (pageParam == null || pageParam.getOrderBys() == null || pageParam.getOrderBys().isEmpty()) {
return;
}
List<OrderByElement> orderByElements = new ArrayList<>(pageParam.getOrderBys().size());
OrderByElement orderByElement;
for (OrderBy orderBy : pageParam.getOrderBys()) {
if (orderBy == null)
continue;
MapperMetadata mapperMeta = MybatisMapperParser.getMapperMetadata(invocation.getMapperNameSpace());
String columnName = mapperMeta.getEntityMetadata().getProp2ColumnMappings().get(orderBy.getField());
if (columnName == null)
columnName = orderBy.getField();
orderByElement = new OrderByElement();
orderByElement.setAsc(OrderType.ASC.name().equals(orderBy.getSortType()));
orderByElement.setExpression(new Column(table, columnName));
orderByElements.add(orderByElement);
}
selectBody.setOrderByElements(orderByElements);
}
use of com.mendmix.common.model.OrderBy in project jeesuite-libs by vakinge.
the class BaseMybatisTest method testPage.
@Test
public void testPage() {
Page<UserEntity> pageInfo;
UserEntity example = new UserEntity();
example.setType((short) 1);
PageParams pageParams = new PageParams(1, 10, new OrderBy("name"));
pageInfo = PageExecutor.pagination(pageParams, new PageDataLoader<UserEntity>() {
@Override
public List<UserEntity> load() {
return userMapper.selectByExample(example);
}
});
System.out.println(pageInfo);
}
Aggregations