/** POST /platforms -> Create a new platform. */ @RequestMapping( value = "/platforms", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<PlatformDTO> create(@Valid @RequestBody PlatformDTO platformDTO) throws URISyntaxException { log.debug("REST request to save Platform : {}", platformDTO); Platform platform = platformMapper.platformDTOToPlatform(platformDTO); Platform result = platformRepository.save(platform); return ResponseEntity.created(new URI("/api/platforms/" + result.getName())) .headers(HeaderUtil.createEntityCreationAlert("platform", result.getName().toString())) .body(platformMapper.platformToPlatformDTO(result)); }
/** PUT /platforms -> Updates an existing platform. */ @RequestMapping( value = "/platforms", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<PlatformDTO> update(@Valid @RequestBody PlatformDTO platformDTO) throws URISyntaxException { log.debug("REST request to update Platform : {}", platformDTO); if (platformDTO.getName() == null) { return create(platformDTO); } Platform platform = platformMapper.platformDTOToPlatform(platformDTO); Platform result = platformRepository.save(platform); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("platform", platformDTO.getName().toString())) .body(platformMapper.platformToPlatformDTO(result)); }