/** PUT /teams -> Updates an existing team. */ @RequestMapping( value = "/teams", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Team> updateTeam(@Valid @RequestBody Team team) throws URISyntaxException { log.debug("REST request to update Team : {}", team); if (team.getId() == null) { return createTeam(team); } Team result = teamRepository.save(team); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("team", team.getId().toString())) .body(result); }
/** POST /teams -> Create a new team. */ @RequestMapping( value = "/teams", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Team> createTeam(@Valid @RequestBody Team team) throws URISyntaxException { log.debug("REST request to save Team : {}", team); if (team.getId() != null) { return ResponseEntity.badRequest() .header("Failure", "A new team cannot already have an ID") .body(null); } Team result = teamRepository.save(team); return ResponseEntity.created(new URI("/api/teams/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("team", result.getId().toString())) .body(result); }