package com.bonus.canteen.core.order.utils;

import com.bonus.canteen.core.order.domain.OrderShoppingCart;
import com.bonus.common.core.exception.ServiceException;

public class ShoppingCartParamChecker {
    public static void listCheck(OrderShoppingCart orderShoppingCart) {
        checkOrderShoppingCart(orderShoppingCart);
        checkUserId(orderShoppingCart);
        checkCanteenId(orderShoppingCart);
        checkStallId(orderShoppingCart);
        checkOrderType(orderShoppingCart);
    }
    public static void addCheck(OrderShoppingCart orderShoppingCart) {
        checkOrderShoppingCart(orderShoppingCart);
        checkUserId(orderShoppingCart);
        checkGoodsId(orderShoppingCart);
        checkQuantity(orderShoppingCart);
        checkCanteenId(orderShoppingCart);
        checkStallId(orderShoppingCart);
        checkOrderDate(orderShoppingCart);
        checkMealtimeType(orderShoppingCart);
        checkDetailType(orderShoppingCart);
        checkMenuId(orderShoppingCart);
    }

    public static void editCheck(OrderShoppingCart orderShoppingCart) {
        checkOrderShoppingCart(orderShoppingCart);
        checkShoppingCartId(orderShoppingCart);
        checkQuantity(orderShoppingCart);
    }

    private static void checkOrderShoppingCart(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart == null) {
            throw new ServiceException("订单购物车对象为空");
        }
    }
    private static void checkShoppingCartId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getShoppingCartId() == null) {
            throw new ServiceException("购车餐品ID为空");
        }
    }

    private static void checkUserId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getUserId() == null) {
            throw new ServiceException("用户ID为空");
        }
    }

    private static void checkGoodsId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getGoodsId() == null) {
            throw new ServiceException("餐品ID为空");
        }
    }

    private static void checkQuantity(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getQuantity() == null) {
            throw new ServiceException("餐品数量为空");
        }
    }

    private static void checkCanteenId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getCanteenId() == null) {
            throw new ServiceException("食堂ID为空");
        }
    }

    private static void checkStallId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getStallId() == null) {
            throw new ServiceException("档口ID为空");
        }
    }

    private static void checkOrderDate(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getOrderDate() == null) {
            throw new ServiceException("订单日期为空");
        }
    }

    private static void checkMealtimeType(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getMealtimeType() == null) {
            throw new ServiceException("餐次类型为空");
        }
    }

    private static void checkDetailType(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getDetailType() == null) {
            throw new ServiceException("订单明细类别为空");
        }
    }

    private static void checkMenuId(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getMenuId() == null) {
            throw new ServiceException("菜谱ID为空");
        }
    }
    private static void checkOrderType(OrderShoppingCart orderShoppingCart) {
        if (orderShoppingCart.getOrderType() == null) {
            throw new ServiceException("订单类型为空");
        }
    }

}
