Exemplo n.º 1
0
  @RequestMapping(
      value = "/users/{id}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity getUser(@PathVariable(value = "id") Integer id) {

    return new ResponseEntity<>(userService.getUser(id), new HttpHeaders(), HttpStatus.OK);
  }
Exemplo n.º 2
0
  @RequestMapping(
      value = "/users",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity getUsers() {

    return new ResponseEntity<>(userService.getUsers(), new HttpHeaders(), HttpStatus.OK);
  }
Exemplo n.º 3
0
  @RequestMapping(
      value = "/users",
      method = RequestMethod.POST,
      consumes = MediaType.APPLICATION_JSON_VALUE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity saveUser(@RequestBody User user) {

    return new ResponseEntity<>(userService.editUser(user), new HttpHeaders(), HttpStatus.CREATED);
  }
Exemplo n.º 4
0
  @RequestMapping(
      value = "/contact/{id}",
      method = RequestMethod.POST,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity saveContact(
      @RequestBody Contact contact, @PathVariable(value = "id") Integer id) {

    return new ResponseEntity<>(
        userService.addContact(contact, id), new HttpHeaders(), HttpStatus.CREATED);
  }
Exemplo n.º 5
0
  @RequestMapping(value = "/contact/{id}", method = RequestMethod.DELETE)
  public ResponseEntity deleteContact(@PathVariable(value = "id") Integer id) {

    userService.deleteContact(id);
    return new ResponseEntity<>("OK", new HttpHeaders(), HttpStatus.OK);
  }