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

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

本文整理了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

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

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

@GetMapping("/zones/{zoneId}")
public Mono<Rendering> displayZone(@PathVariable String zoneId) {
  PageRequest pageRequest = PageRequest.of(0, this.historySize,
      Sort.by("timestamp").descending());
  Flux<PowerGridSample> latestSamples = this.powerGridSampleRepository
      .findAllByZoneId(zoneId, pageRequest);
  return this.zoneDescriptorRepository.findById(zoneId)
      .switchIfEmpty(Mono.error(new MissingDataException(zoneId)))
      .map(zoneDescriptor -> Rendering
          .view("zone")
          .modelAttribute("zone", zoneDescriptor)
          .modelAttribute("samples", latestSamples)
          .build());
}

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

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

相关文章