コード例 #1
0
  /**
   * Get a partner
   *
   * @param id
   * @return
   */
  @RequestMapping(
      value = PartnerResourcePathConfig.PARTNER_SERVICE_PATH,
      method = RequestMethod.GET)
  public ResponseEntity<PartnerResource> getInfo(@PathVariable("id") String id) {

    PartnerResource resource = partnerResourceAssembler.toResource(partnerRepository.findOne(id));
    return new ResponseEntity<PartnerResource>(resource, HttpStatus.OK);
  }
コード例 #2
0
  /**
   * Get all partners by pages
   *
   * @param page
   * @return pages of partners
   */
  @RequestMapping(
      value = PartnerResourcePathConfig.PARTNERS_SERVICE_PATH,
      method = RequestMethod.GET)
  public ResponseEntity<Page<PartnerResource>> ListPartners(Pageable page) {

    Page<Partner> pagedResource = partnerRepository.findAll(page);
    List<PartnerResource> resources =
        partnerResourceAssembler.toResources(pagedResource.getContent());

    Page<PartnerResource> resultPage =
        new PageImpl<PartnerResource>(resources, page, pagedResource.getTotalElements());

    return ResponseEntity.ok(resultPage);
  }