Created
May 23, 2021 13:16
-
-
Save alexandre-jacquot-ptl/e0374d3fdfb71886969d830de2b12aa2 to your computer and use it in GitHub Desktop.
r2dbc ItemController patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping(value = "/items") | |
public class ItemController { | |
private final ItemService itemService; | |
private final ItemMapper itemMapper; | |
... | |
@ApiOperation("Patch an existing item following the patch merge RCF (https://tools.ietf.org/html/rfc7396)") | |
@PatchMapping(value = "/{id}") | |
public Mono<ResponseEntity<Void>> patch(@PathVariable @NotNull final Long id, | |
@RequestHeader(value = HttpHeaders.IF_MATCH) final Long version, | |
@Valid @RequestBody final ItemPatchResource patch) { | |
return itemService.findById(id, version, true) | |
.map(item -> itemMapper.patch(patch, item)) | |
.flatMap(itemService::update) | |
.map(itemId -> noContent().build()); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment