Commit 67b24376 authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

[AFP-55] Start work on findAll controller [@kliew]

parent 1270fc1d
File added
File added
package controller;
import dto.ProductDto;
import model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import service.ProductService;
@RestController
@RequestMapping("/products")
public class ProductController {
@Autowired
ProductService productService;
@GetMapping()
public Flux<Product> findAll() {
Flux<Product> prods = productService.findAll();
return prods;
}
}
package service;
import dto.ProductDto;
import model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
......@@ -16,4 +17,8 @@ public class ProductService {
.map(ProductDto::generateDtoFromProduct)
.flatMap(Flux::just);
}
public Flux<Product> findAll(){
return productRepository.findAll();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment