Commit e56062a6 authored by Alex Pinto's avatar Alex Pinto

fixed merge conflicts

parents 916ec9fe e2ed61e6
......@@ -4,6 +4,13 @@ import com.ascendfinalproject.warehouse.models.WarehouseOrderRequest;
import com.ascendfinalproject.warehouse.models.WarehouseOrderResponse;
import com.ascendfinalproject.warehouse.services.WarehouseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
<<<<<<< HEAD
=======
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
>>>>>>> master
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
......@@ -25,8 +32,11 @@ public class WarehouseController {
@CrossOrigin
@GetMapping("/orders/{id}")
public Mono<WarehouseOrderResponse> findOrder(@PathVariable String id){
return orderService.findOrderById(id);
public Mono<ResponseEntity> getById(@PathVariable String id) {
return orderService.getById(id)
.map(order -> (ResponseEntity.status(HttpStatus.OK).body(order)))
.cast(ResponseEntity.class)
.defaultIfEmpty(ResponseEntity.status(HttpStatus.NOT_FOUND).body(null));
}
@CrossOrigin
......
......@@ -19,9 +19,8 @@ public class WarehouseOrderService {
@Autowired
WarehouseOrderRepository orderRepository;
public Mono<WarehouseOrderResponse> findOrderById(String id) {
public Mono<WarehouseOrderResponse> getById(String id) {
return orderRepository.findById(id);
// .switchIfEmpty(ServerResponse.notFound().build());
}
public Flux<WarehouseOrderResponse> getOrders() {
......
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