
@Service public class ProductService { private final ProductRepository productRepository; private final ProductDocumentRepository productDocumentRepository; public ProductService(ProductRepository productRepository, ProductDocumentRepository productDocumentRepository) { this.productRepository = productRepository; this.productDocumentRepository = productDocumentRepository; }
public Product createProduct(CreateProductRequestDto createProductRequestDto) { Product product = new Product( createProductRequestDto.getName(), createProductRequestDto.getDescription(), createProductRequestDto.getPrice(), createProductRequestDto.getRating(), createProductRequestDto.getCategory() ); Product savedProduct = productRepository.save(product); ProductDocument productDocument = new ProductDocument( savedProduct.getId().toString(), savedProduct.getName(), savedProduct.getDescription(), savedProduct.getPrice(), savedProduct.getRating(), savedProduct.getCategory() ); productDocumentRepository.save(productDocument); return savedProduct; }
public void deleteProduct(Long id) { productRepository.deleteById(id); productDocumentRepository.deleteById(id.toString()); }

DELETE /products
{ "name": "삼성 갤럭시 S25", "description": "<h2>최신 스마트폰</h2><p>AI 기능과 강력한 배터리를 갖춘 프리미엄 스마트폰입니다.</p>", "price": 1290000, "rating": 4.8, "category": "ELECTRONICS" }





