change entity names
This commit is contained in:
@@ -8,7 +8,7 @@ import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
||||
import { ContactStatusEnum } from '../interface/interface';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { ContactScope } from '../interface/interface';
|
||||
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
|
||||
import { Shop } from ../../..shops/entities/shop.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ContactService {
|
||||
@@ -20,22 +20,22 @@ export class ContactService {
|
||||
async create(dto: CreateContactDto, restId?: string, slug?: string): Promise<Contact> {
|
||||
|
||||
|
||||
let restaurant: Restaurant | null = null;
|
||||
let shop: Shop | null = null;
|
||||
|
||||
if ((restId || slug) && dto.scope === ContactScope.RESTAURANT) {
|
||||
restaurant = await this.em.findOne(Restaurant, {
|
||||
shop = await this.em.findOne(Shop, {
|
||||
...(restId ? { id: restId } : {})
|
||||
, ...(slug ? { slug: slug } : {})
|
||||
});
|
||||
if (!restaurant) {
|
||||
throw new NotFoundException(`Restaurant with ID ${restId} not found`);
|
||||
if (!shop) {
|
||||
throw new NotFoundException(`Shop with ID ${restId} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
const contact = this.contactRepository.create({
|
||||
...dto,
|
||||
status: ContactStatusEnum.New,
|
||||
restaurant,
|
||||
shop,
|
||||
});
|
||||
await this.em.persistAndFlush(contact);
|
||||
return contact;
|
||||
@@ -68,7 +68,7 @@ export class ContactService {
|
||||
async findOne(id: string, restaurantId?: string): Promise<Contact> {
|
||||
const where: any = { id };
|
||||
if (restaurantId) {
|
||||
where.restaurant = restaurantId;
|
||||
where.shop = restaurantId;
|
||||
}
|
||||
|
||||
const contact = await this.contactRepository.findOne(where);
|
||||
@@ -81,7 +81,7 @@ export class ContactService {
|
||||
async updateStatus(id: string, dto: UpdateContactStatusDto, restaurantId?: string): Promise<Contact> {
|
||||
const where: any = { id };
|
||||
if (restaurantId) {
|
||||
where.restaurant = restaurantId;
|
||||
where.shop = restaurantId;
|
||||
}
|
||||
|
||||
const contact = await this.contactRepository.findOne(where);
|
||||
@@ -96,7 +96,7 @@ export class ContactService {
|
||||
async remove(id: string, restaurantId?: string): Promise<void> {
|
||||
const where: any = { id };
|
||||
if (restaurantId) {
|
||||
where.restaurant = restaurantId;
|
||||
where.shop = restaurantId;
|
||||
}
|
||||
|
||||
const contact = await this.contactRepository.findOne(where);
|
||||
|
||||
Reference in New Issue
Block a user