title: Springboot How to Return a response after a POST
body: <p>I would like to create a new customer and return a customer number once the customer is created. The customer number has to be an auto incremented unique number from 50000.</p>
  
  <p>Thus far i have managed to created a customer but i am not sure how i should go about generating the customer number, save it to the database and show it to the user as a success message when a POST is triggered.</p>
  
  <p>Below json is the desired response; </p>
  
  <pre><code>{
      "customerNumber": "50002",
      "statusMessage": "Customer Created Successfully",
  } 
  </code></pre>
  
  <p>And the following snippet from controller and service;</p>
  
  <p><strong>UserService.java</strong></p>
  
  <pre><code>public void createUser(User user) {
      if (user == null || user.getId() == null) {
          throw new ResourceNotFoundException("Empty", "Missing Data Exception");
      } else {
          userRepository.save(user);
      }
  }
  </code></pre>
  
  <p><strong>RegistrationController.java</strong></p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, value = "/users")
  public void createUser(@RequestBody User user) {
      userService.createUser(user);
  }
  </code></pre>