I also made a service logic to delete and modify it separately, but it doesn't work with Postman. (Return Code X). Is the reason why deletion and modification are not related to elasticsearch technology?
@김승범-n2d Жыл бұрын
The service logic is as follows. @PatchMapping("/products/{id}") public ResponseEntity updateProduct(@RequestBody @Valid final ProductUpdateRequestDto productUpdateRequestDto, @PathVariable final int id) { return ResponseEntity.status(200).body(productService.updateProduct(productUpdateRequestDto, id)); } @DeleteMapping("/products/{id}") public ResponseEntity deleteProduct(@PathVariable final int id) { productService.deleteProduct(id); return ResponseEntity.status(204).build(); } The service logic is as follows. In the case of modification, we implemented it to receive dto in the parameter from the domain and process it.
@enggadda Жыл бұрын
I don't think so , give me sometime will check and let you know
@김승범-n2d Жыл бұрын
@@enggadda The service logic for deletion and modification is as follows. public ProductResponseDto updateProduct(final ProductUpdateRequestDto productUpdateRequestDto, final int id) { Product product = productRepository.findById(id); checkFindProductIsEmpty(product); product.updateProduct(productUpdateRequestDto); productRepository.save(product); return ProductResponseDto.toDto(product); } public void deleteProduct(final int id) { Product product = productRepository.findById(id); checkFindProductIsEmpty(product); productRepository.delete(product); } private void checkFindProductIsEmpty(final Product product) { if(product == null) { throw new ProductNotFoundException(PRODUCT_NOT_FOUND_MESSAGE); } } private void checkFindProductListIsEmpty(final List products) { if(products.isEmpty()) { throw new ProductNotFoundException(PRODUCT_NOT_FOUND_MESSAGE); } } p.s Is there a reason why you didn't add @Transactional annotation to the service??
@김승범-n2d Жыл бұрын
@@enggadda Just in case, I tried to change the HTTP method to Put instead of Patch, but it was not updated.
@tusharpathade7670 Жыл бұрын
why 7.17.9 version and not latest one?
@enggadda Жыл бұрын
It was working for me latest one was not working so choose this version