org.springframework.data.domain.Sort.descending()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中org.springframework.data.domain.Sort.descending()方法的一些代码示例,展示了Sort.descending()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sort.descending()方法的具体详情如下:
包路径:org.springframework.data.domain.Sort
类名称:Sort
方法名:descending

Sort.descending介绍

[英]Returns a new Sort with the current setup but descending order direction.
[中]

代码示例

代码示例来源:origin: habuma/spring-in-action-5-samples

  1. @GetMapping("/recent")
  2. public Iterable<Taco> recentTacos() { //<3>
  3. PageRequest page = PageRequest.of(
  4. 0, 12, Sort.by("createdAt").descending());
  5. return tacoRepo.findAll(page).getContent();
  6. }
  7. //end::recents[]

代码示例来源:origin: snicoll-demos/smart-meter

  1. @GetMapping("/zones/{zoneId}")
  2. public Mono<Rendering> displayZone(@PathVariable String zoneId) {
  3. PageRequest pageRequest = PageRequest.of(0, this.historySize,
  4. Sort.by("timestamp").descending());
  5. Flux<PowerGridSample> latestSamples = this.powerGridSampleRepository
  6. .findAllByZoneId(zoneId, pageRequest);
  7. return this.zoneDescriptorRepository.findById(zoneId)
  8. .switchIfEmpty(Mono.error(new MissingDataException(zoneId)))
  9. .map(zoneDescriptor -> Rendering
  10. .view("zone")
  11. .modelAttribute("zone", zoneDescriptor)
  12. .modelAttribute("samples", latestSamples)
  13. .build());
  14. }

代码示例来源:origin: habuma/spring-in-action-5-samples

  1. @GetMapping(path="/tacos/recent", produces="application/hal+json")
  2. public ResponseEntity<Resources<TacoResource>> recentTacos() {
  3. PageRequest page = PageRequest.of(
  4. 0, 12, Sort.by("createdAt").descending());
  5. List<Taco> tacos = tacoRepo.findAll(page).getContent();
  6. List<TacoResource> tacoResources =
  7. new TacoResourceAssembler().toResources(tacos);
  8. Resources<TacoResource> recentResources =
  9. new Resources<TacoResource>(tacoResources);
  10. recentResources.add(
  11. linkTo(methodOn(RecentTacosController.class).recentTacos())
  12. .withRel("recents"));
  13. return new ResponseEntity<>(recentResources, HttpStatus.OK);
  14. }

相关文章