1、如何实现排序
a 命名查询:
public interface ParamsRepository extends JpaRepository<CwParams, String>,JpaSpecificationExecutor<CwParams> {
List<CwParams> findAllByOrderByCodeDesc();//根据code倒序查询
}
b 基于Sort:
public ResponseResult listRecord(RecordCondition condition) {
LocalResponseResult responseResult = super.buildResponseResult(condition);
Pageable pageable = new PageRequest(condition.getPage() - 1, condition.getSize(),new Sort(Sort.Direction
.DESC,"id"));//创建分页条件和排序条件
Specification<CwStopRecord> specification = (Specification<CwStopRecord>) (root, query, cb) -> {
List<Predicate> list = new ArrayList<>();
//条件全为空则执行无条件查询
if (StringUtils.isNotBlank(condition.getType())) {