Commit 97feab8b authored by Alex Pinto's avatar Alex Pinto

fixed endpoints added dummy data

parent 90701776
......@@ -9,10 +9,17 @@ import org.springframework.data.annotation.Id;
@Setter
public class Item {
@Id
private String id;
private String name;
private int quantity;
private int price;
private int sku;
private String itemId;
private String itemName;
private int itemQuantity;
private int itemPrice;
private int itemSku;
public Item(String itemId, String itemName, int itemQuantity, int itemPrice, int itemSku) {
this.itemId = itemId;
this.itemName = itemName;
this.itemQuantity = itemQuantity;
this.itemPrice = itemPrice;
this.itemSku = itemSku;
}
}
package com.ascendfinalproject.warehouse.services;
import com.ascendfinalproject.warehouse.models.Item;
import com.ascendfinalproject.warehouse.models.WarehouseOrder;
import com.ascendfinalproject.warehouse.repositories.WarehouseOrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -7,7 +8,10 @@ import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class WarehouseOrderService {
......@@ -26,13 +30,19 @@ public class WarehouseOrderService {
public Mono<WarehouseOrder> createOrder(WarehouseOrder order) {
order.setStatus("RECEIVED");
order.setCreatedAt(new Date(System.currentTimeMillis()));
order.setModifiedAt(new Date(System.currentTimeMillis()));
List<Item> itemList = Arrays.asList(
new Item("3", "Hamburger", 3, 3, 33),
new Item("4", "Sausage", 4, 5, 66),
new Item("5", "Fries", 3, 4, 33));
order.setOrderItems(itemList);
order.setAddress("123 apple st");
return orderRepository.save(order);
}
public Mono<WarehouseOrder> updateOrder(WarehouseOrder order, String id) {
return orderRepository.findById(id)
.flatMap(existingOrder -> {
existingOrder.setOrderId(order.getOrderId());
existingOrder.setStatus(order.getStatus());
existingOrder.setModifiedAt(new Date(System.currentTimeMillis()));
return orderRepository.save(existingOrder);
......
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