Closed ydq closed 2 years ago
https://github.com/mybatis-mapper/mapper/issues/33
使用示例:
// ORDER BY status = 5 DESC , FIELD(`weight`, 3, 1, 4, 2) , create_time DESC userMapper.wrapper() // 将 状态 等于5的 排序在最前面 .orderBy("status = 5 DESC") // 如果权重不为空 则将指定权重的值放前面 .orderBy(weight != null , () -> "`weight` = " + weight + " DESC") // 如果指定权重列表不为空,则按照指定的权重特顺序进行排序 .orderBy(CollectionUtils.isNotEmpty(assignWeightSort),() -> { return assignWeightSort.stream() .map(Objects::toString) .collect(Collectors.joining(",", "FIELD(`weight`,", ")")); }) // 相同权重的 按照时间倒序 .orderBy("create_time DESC"); // 等同于 .orderByDesc(User::getCreateTime);
感谢PR :+1:
https://github.com/mybatis-mapper/mapper/issues/33
使用示例: