Я прилагаю код и выходные данные ниже. Любые предложения могут быть полезны.
Контроллер
Код: Выделить всё
@GetMapping("/products")
public ResponseEntity getProducts() {
return getProductService.execute(null);
}
Код: Выделить всё
public class GetProductService implements Query {
public GetProductService(ProductRepository productRepository) {
this.productRepository = productRepository;
}
private final ProductRepository productRepository;
@Override
public ResponseEntity execute(Void input) {
List products = productRepository.findAll();
return ResponseEntity.status(HttpStatus.OK).body(products);
}
}
Код: Выделить всё
public interface Query {
ResponseEntity execute(I input);
}
Код: Выделить всё
public interface ProductRepository extends JpaRepository
{
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... nd-postman