use of com.baomidou.mybatisplus.core.metadata.OrderItem in project yshopmall by guchengwuyue.
the class BaseServiceImpl method setPageParam.
protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) {
Page page = new Page();
// 设置当前页码
page.setCurrent(queryParam.getPage());
// 设置页大小
page.setSize(queryParam.getLimit());
/**
* 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序
* 否则使用默认排序
*/
if (queryParam instanceof OrderQueryParam) {
OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam;
List<OrderItem> orderItems = orderQueryParam.getOrders();
if (CollectionUtil.isEmpty(orderItems)) {
page.setOrders(Arrays.asList(defaultOrder));
} else {
page.setOrders(orderItems);
}
} else {
page.setOrders(Arrays.asList(defaultOrder));
}
return page;
}
use of com.baomidou.mybatisplus.core.metadata.OrderItem in project video-spider by zc-libre.
the class VideoServiceImpl method getOrders.
private List<Sort.Order> getOrders(PageDTO<Video> page) {
List<Sort.Order> orders = Lists.newArrayList();
List<OrderItem> orderItems = page.getOrders();
if (CollectionUtil.isEmpty(orderItems)) {
Sort.Order createTime = Order.by("publishTime").with(Sort.Direction.DESC);
Sort.Order lookNum = Order.by("lookNum").with(Sort.Direction.DESC);
orders.add(createTime);
orders.add(lookNum);
}
for (OrderItem orderItem : orderItems) {
String column = orderItem.getColumn();
boolean asc = orderItem.isAsc();
Sort.Order order = Order.by(column);
if (!asc) {
order.with(Sort.Direction.DESC);
}
orders.add(order);
}
return orders;
}
use of com.baomidou.mybatisplus.core.metadata.OrderItem in project PornTube by PuZhiweizuishuai.
the class ArticleServiceImpl method queryPage.
@Override
public PageUtils queryPage(Map<String, Object> params) {
QueryWrapper<ArticleEntity> wrapper = new QueryWrapper<>();
wrapper.eq("status", ArticleStatusEnum.NORMAL.getCode());
wrapper.eq("examine_status", ExamineTypeEnum.SUCCESS.getCode());
wrapper.orderByDesc("create_time");
IPage<ArticleEntity> page = this.page(new Query<ArticleEntity>().getPage(params), wrapper);
Set<Long> userIdList = page.getRecords().stream().map(ArticleEntity::getUserId).collect(Collectors.toSet());
if (userIdList.size() == 0) {
return null;
}
Map<Long, UserEntity> userEntityMap = userService.userMapList(userIdList);
List<ArticleViewData> articleViewData = new ArrayList<>();
page.getRecords().forEach(a -> {
ArticleViewData viewData = new ArticleViewData();
UserEntity userEntity = userEntityMap.get(a.getUserId());
BeanUtils.copyProperties(a, viewData);
viewData.setUsername(userEntity.getUsername());
viewData.setAvatarUrl(userEntity.getAvatarUrl());
articleViewData.add(viewData);
});
IPage<ArticleViewData> viewDataIPage = new IPage<ArticleViewData>() {
@Override
public List<OrderItem> orders() {
return null;
}
@Override
public List<ArticleViewData> getRecords() {
return articleViewData;
}
@Override
public IPage<ArticleViewData> setRecords(List<ArticleViewData> records) {
return null;
}
@Override
public long getTotal() {
return page.getTotal();
}
@Override
public IPage<ArticleViewData> setTotal(long total) {
return null;
}
@Override
public long getSize() {
return page.getSize();
}
@Override
public IPage<ArticleViewData> setSize(long size) {
return null;
}
@Override
public long getCurrent() {
return page.getCurrent();
}
@Override
public IPage<ArticleViewData> setCurrent(long current) {
return null;
}
};
return new PageUtils(viewDataIPage);
}
Aggregations