/**
* 排序JSON格式
*/
@ApiModelProperty(value = "排序JSON格式")
private String orderBy;
@GetMapping("/page_manage")
@ApiModelProperty(value = "管理端用户管理分页", notes = "管理端用户管理分页")
public R pageManage(Page<SysUser> page, SysUserDTO dto) {
if(ObjectUtil.isNotNull(dto) && StrUtil.isNotBlank(dto.getOrderBy())){
List<OrderItem> orderItemList = new ArrayList<>();
try {
String decode = URLDecoder.decode(dto.getOrderBy(), "UTF-8");
orderItemList = JSONUtil.toList(decode,OrderItem.class);
if(CollUtil.isNotEmpty(orderItemList)){
orderItemList.forEach(entity->{
String column = entity.getColumn();
if(StrUtil.isNotBlank(column)){
//将驼峰式命名的字符串转换为下划线方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
entity.setColumn(StrUtil.toUnderlineCase(column));
}
});
}
page.setOrders(orderItemList);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return serve.pageManage(page, dto);
}
Boolean isOrder = Boolean.FALSE;
if(ObjectUtil.isNotEmpty(page)){
List<OrderItem> orderItemList = page.getOrders();
if(CollUtil.isNotEmpty(orderItemList)){
isOrder = Boolean.TRUE;
}
}
if(!isOrder){
//排序
queryWrapper.lambda().orderByAsc(xxx::getSort).orderByDesc(xxx::getCreateTime);
}