/** * 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); }
/** * To set a partner as customer * * @param partner * @return */ @RequestMapping( value = PartnerResourcePathConfig.PARTNERS_SERVICE_PATH, method = RequestMethod.POST) public ResponseEntity<Partner> createPartner(@RequestBody Partner partner) { Partner saveEntity = partnerRepository.save(partner); return new ResponseEntity<Partner>(saveEntity, HttpStatus.CREATED); }
/** * 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); }