MyBatisPlus 分页page排序

背景

如何按照时间进行倒序排列,利用mapper对象进行排序见代码

@PostMapping("/list")
    @ResponseBody
    public AjaxResult mainList(PdpInterCallLogDTO pdpInterCallLogDTO) {
        QueryWrapper queryWrapper = packageWapper(pdpInterCallLogDTO);
        queryWrapper.orderByDesc("CREATE_TIME");
        if (ObjectUtil.isNull(pdpInterCallLogDTO.getPageNo())) {
            return AjaxResult.success(pdpInterCallLogService.list(queryWrapper));
        }
        return AjaxResult.success(pdpInterCallLogService.page(new Page<>(pdpInterCallLogDTO.getPageNo(), pdpInterCallLogDTO.getPageSize()), queryWrapper));
    }

在Mapper添加queryWrapper.orderByDesc("CREATE_TIME");即可解决排序问题。

参考:https://zhuanlan.zhihu.com/p/366720198

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容