change entity names

This commit is contained in:
2026-02-08 09:18:20 +03:30
parent 6be6a66079
commit 9a7010dcea
180 changed files with 2751 additions and 2513 deletions
@@ -4,7 +4,7 @@ import { Delivery } from '../entities/delivery.entity';
import { DeliveryRepository } from '../repositories/delivery.repository';
import { CreateDeliveryDto } from '../dto/create-delivery.dto';
import { UpdateDeliveryDto } from '../dto/update-delivery.dto';
import { RestRepository } from '../../restaurants/repositories/rest.repository';
import { RestRepository } from ../../..shops/repositories/rest.repository';
import { DeliveryMethodEnum } from '../interface/delivery';
import { DeliveryMessage } from 'src/common/enums/message.enum';
@@ -17,14 +17,14 @@ export class DeliveryService {
) {}
async create(restId: string, createDto: CreateDeliveryDto): Promise<Delivery> {
const restaurant = await this.restRepository.findOne({ id: restId });
if (!restaurant) {
const shop = await this.restRepository.findOne({ id: restId });
if (!shop) {
throw new NotFoundException(DeliveryMessage.RESTAURANT_NOT_FOUND);
}
// Check if the delivery method with the same name already exists for this restaurant
// Check if the delivery method with the same name already exists for this shop
const existing = await this.deliveryRepository.findOne({
restaurant: { id: restId },
shop: { id: restId },
method: createDto.method,
});
@@ -33,7 +33,7 @@ export class DeliveryService {
}
const data: RequiredEntityData<Delivery> = {
restaurant,
shop,
method: createDto.method,
deliveryFee: createDto.deliveryFee,
minOrderPrice: createDto.minOrderPrice,
@@ -51,13 +51,13 @@ export class DeliveryService {
}
async findAllForRestaurantId(restId: string): Promise<Delivery[]> {
return this.deliveryRepository.find({ restaurant: { id: restId } }, { orderBy: { order: 'asc' } });
return this.deliveryRepository.find({ shop: { id: restId } }, { orderBy: { order: 'asc' } });
}
async findOne(restId: string, deliveryId: string): Promise<Delivery> {
const delivery = await this.deliveryRepository.findOne({
id: deliveryId,
restaurant: { id: restId },
shop: { id: restId },
});
if (!delivery) {
@@ -69,7 +69,7 @@ export class DeliveryService {
async update(restId: string, deliveryId: string, updateDto: UpdateDeliveryDto): Promise<Delivery> {
const delivery = await this.deliveryRepository.findOne({
restaurant: { id: restId },
shop: { id: restId },
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({
restaurant: { id: restId },
shop: { id: restId },
method: updateDto.method,
id: { $ne: deliveryId },
});
@@ -98,7 +98,7 @@ export class DeliveryService {
async remove(restId: string, deliveryId: string): Promise<void> {
const delivery = await this.deliveryRepository.findOne({
restaurant: { id: restId },
shop: { id: restId },
id: deliveryId,
});