fix import errors
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { Product } from '../../../products/entities/product.entity';
|
||||
import { Shop } from '../../../shops/entities/shop.entity';
|
||||
import { UserAddress } from '../../../users/entities/user-address.entity';
|
||||
import { User } from '../../../users/entities/user.entity';
|
||||
import { PaymentMethod } from '../../../payments/entities/payment-method.entity';
|
||||
import { Delivery } from '../../../delivery/entities/delivery.entity';
|
||||
import { DeliveryMethodEnum } from '../../../delivery/interface/delivery';
|
||||
import { PointTransaction } from '../../../users/entities/point-transaction.entity';
|
||||
import { Order } from '../../../orders/entities/order.entity';
|
||||
import { OrderStatus } from '../../../orders/interface/order.interface';
|
||||
import { Product } from 'src/modules/products/entities/product.entity';
|
||||
import { Shop } from 'src/modules/shops/entities/shop.entity';
|
||||
import { UserAddress } from 'src/modules/users/entities/user-address.entity';
|
||||
import { User } from 'src/modules/users/entities/user.entity';
|
||||
import { PaymentMethod } from 'src/modules/payments/entities/payment-method.entity';
|
||||
import { Delivery } from 'src/modules/delivery/entities/delivery.entity';
|
||||
import { DeliveryMethodEnum } from 'src/modules/delivery/interface/delivery';
|
||||
import { PointTransaction } from 'src/modules/users/entities/point-transaction.entity';
|
||||
import { Order } from 'src/modules/orders/entities/order.entity';
|
||||
import { OrderStatus } from 'src/modules/orders/interface/order.interface';
|
||||
import { Cart } from '../interfaces/cart.interface';
|
||||
import { GeographicUtils } from '../utils/geographic.utils';
|
||||
import { CartMessage } from 'src/common/enums/message.enum';
|
||||
@@ -28,11 +28,11 @@ export class CartValidationService {
|
||||
async validateAndGetFood(foodId: string, restaurantId: string, quantity: number): Promise<Product> {
|
||||
const product = await this.em.findOne(Product, { id: foodId }, { populate: ['shop'] });
|
||||
if (!product) {
|
||||
throw new NotFoundException(CartMessage.FOOD_NOT_FOUND);
|
||||
throw new NotFoundException(CartMessage.PRODUCT_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (product.shop.id !== restaurantId) {
|
||||
throw new BadRequestException(CartMessage.FOOD_NOT_BELONGS_TO_RESTAURANT);
|
||||
throw new BadRequestException(CartMessage.PRODUCT_NOT_BELONGS_TO_SHOP);
|
||||
}
|
||||
|
||||
return product;
|
||||
@@ -67,7 +67,7 @@ export class CartValidationService {
|
||||
async getFoodOrFail(foodId: string): Promise<Product> {
|
||||
const product = await this.em.findOne(Product, { id: foodId });
|
||||
if (!product) {
|
||||
throw new NotFoundException(CartMessage.FOOD_NOT_FOUND);
|
||||
throw new NotFoundException(CartMessage.PRODUCT_NOT_FOUND);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export class CartValidationService {
|
||||
async getRestaurantOrFail(restaurantId: string): Promise<Shop> {
|
||||
const shop = await this.em.findOne(Shop, { id: restaurantId });
|
||||
if (!shop) {
|
||||
throw new NotFoundException(CartMessage.RESTAURANT_NOT_FOUND);
|
||||
throw new NotFoundException(CartMessage.SHOP_NOT_FOUND);
|
||||
}
|
||||
return shop;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ export class CartValidationService {
|
||||
});
|
||||
|
||||
if (!deliveryMethod) {
|
||||
throw new NotFoundException(CartMessage.DELIVERY_METHOD_NOT_FOUND_FOR_RESTAURANT);
|
||||
throw new NotFoundException(CartMessage.DELIVERY_METHOD_NOT_FOUND_FOR_SHOP);
|
||||
}
|
||||
|
||||
return deliveryMethod;
|
||||
@@ -269,5 +269,12 @@ export class CartValidationService {
|
||||
return new Map(products.map(f => [f.id, f]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate stock for a product
|
||||
*/
|
||||
validateStock(product: Product, quantity: number): void {
|
||||
// TODO: Implement stock validation logic
|
||||
// For now, assume unlimited stock
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user