コード例 #1
0
 @RequestMapping(method = RequestMethod.POST)
 public Customer addCustomer(@RequestBody Customer customer) {
   LOGGER.info(customer);
   customer.setId(null);
   Address address = null;
   if (customer.getAddress() != null) {
     address =
         addressRepository.findByStreetAndZip(
             customer.getAddress().getStreet(), customer.getAddress().getZip());
   }
   if (address != null) {
     customer.setAddress(address);
   }
   return customerRepository.saveAndFlush(customer);
 }
コード例 #2
0
 @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
 public Customer editCustomer(@RequestBody Customer customer, @PathVariable Integer id) {
   customer.setId(id);
   return customerRepository.saveAndFlush(customer);
 }