@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_USERS_USER_CUSTOMERS_CUSTOMER) HttpEntity<Resource<Customer>> loadSingleUserCustomer( @PathVariable Long user, @PathVariable Long customer) { Resource<Customer> customerResource = customerResourceAssembler.toResource(this.crmService.findCustomerById(customer)); return new ResponseEntity<Resource<Customer>>(customerResource, HttpStatus.OK); }
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_USERS_USER_CUSTOMERS) HttpEntity<Resources<Resource<Customer>>> loadUserCustomers(@PathVariable Long user) { Collection<Resource<Customer>> customerResourceCollection = new ArrayList<Resource<Customer>>(); for (Customer c : this.crmService.loadCustomerAccounts(user)) { customerResourceCollection.add(customerResourceAssembler.toResource(c)); } Resources<Resource<Customer>> customerResources = new Resources<Resource<Customer>>(customerResourceCollection); customerResources.add( linkTo(methodOn(UserController.class).loadUserCustomers(user)).withSelfRel()); return new ResponseEntity<Resources<Resource<Customer>>>(customerResources, HttpStatus.OK); }