rename
This commit is contained in:
@@ -16,15 +16,15 @@ export class DeliveryService {
|
||||
private readonly em: EntityManager,
|
||||
) { }
|
||||
|
||||
async create(restId: string, createDto: CreateDeliveryDto): Promise<Delivery> {
|
||||
const shop = await this.shopRepository.findOne({ id: restId });
|
||||
async create(shopId: string, createDto: CreateDeliveryDto): Promise<Delivery> {
|
||||
const shop = await this.shopRepository.findOne({ id: shopId });
|
||||
if (!shop) {
|
||||
throw new NotFoundException(DeliveryMessage.SHOP_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Check if the delivery method with the same name already exists for this shop
|
||||
const existing = await this.deliveryRepository.findOne({
|
||||
shop: { id: restId },
|
||||
shop: { id: shopId },
|
||||
method: createDto.method,
|
||||
});
|
||||
|
||||
@@ -50,14 +50,14 @@ export class DeliveryService {
|
||||
return delivery;
|
||||
}
|
||||
|
||||
async findAllForRestaurantId(restId: string): Promise<Delivery[]> {
|
||||
return this.deliveryRepository.find({ shop: { id: restId } }, { orderBy: { order: 'asc' } });
|
||||
async findAllForRestaurantId(shopId: string): Promise<Delivery[]> {
|
||||
return this.deliveryRepository.find({ shop: { id: shopId } }, { orderBy: { order: 'asc' } });
|
||||
}
|
||||
|
||||
async findOrFail(restId: string, deliveryId: string): Promise<Delivery> {
|
||||
async findOrFail(shopId: string, deliveryId: string): Promise<Delivery> {
|
||||
const delivery = await this.deliveryRepository.findOne({
|
||||
id: deliveryId,
|
||||
shop: { id: restId },
|
||||
shop: { id: shopId },
|
||||
});
|
||||
|
||||
if (!delivery) {
|
||||
@@ -67,9 +67,9 @@ export class DeliveryService {
|
||||
return delivery;
|
||||
}
|
||||
|
||||
async update(restId: string, deliveryId: string, updateDto: UpdateDeliveryDto): Promise<Delivery> {
|
||||
async update(shopId: string, deliveryId: string, updateDto: UpdateDeliveryDto): Promise<Delivery> {
|
||||
const delivery = await this.deliveryRepository.findOne({
|
||||
shop: { id: restId },
|
||||
shop: { id: shopId },
|
||||
id: deliveryId,
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ export class DeliveryService {
|
||||
// If method is being updated, check for conflicts
|
||||
if (updateDto.method !== undefined && updateDto.method !== delivery.method) {
|
||||
const existing = await this.deliveryRepository.findOne({
|
||||
shop: { id: restId },
|
||||
shop: { id: shopId },
|
||||
method: updateDto.method,
|
||||
id: { $ne: deliveryId },
|
||||
});
|
||||
@@ -96,9 +96,9 @@ export class DeliveryService {
|
||||
return delivery;
|
||||
}
|
||||
|
||||
async remove(restId: string, deliveryId: string): Promise<void> {
|
||||
async remove(shopId: string, deliveryId: string): Promise<void> {
|
||||
const delivery = await this.deliveryRepository.findOne({
|
||||
shop: { id: restId },
|
||||
shop: { id: shopId },
|
||||
id: deliveryId,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user