This commit is contained in:
2026-02-10 10:15:35 +03:30
parent e079527687
commit c060be3069
65 changed files with 461 additions and 461 deletions
@@ -17,18 +17,18 @@ export class ContactService {
private readonly em: EntityManager,
) { }
async create(dto: CreateContactDto, restId?: string, slug?: string): Promise<Contact> {
async create(dto: CreateContactDto, shopId?: string, slug?: string): Promise<Contact> {
let shop: Shop | null = null;
if ((restId || slug) && dto.scope === ContactScope.SHOP) {
if ((shopId || slug) && dto.scope === ContactScope.SHOP) {
shop = await this.em.findOne(Shop, {
...(restId ? { id: restId } : {})
...(shopId ? { id: shopId } : {})
, ...(slug ? { slug: slug } : {})
});
if (!shop) {
throw new NotFoundException(`Shop with ID ${restId} not found`);
throw new NotFoundException(`Shop with ID ${shopId} not found`);
}
}
@@ -41,7 +41,7 @@ export class ContactService {
return contact;
}
async findAllPaginatedAdmin(dto: FindContactsDto, restaurantId?: string): Promise<PaginatedResult<Contact>> {
async findAllPaginatedAdmin(dto: FindContactsDto, shopId?: string): Promise<PaginatedResult<Contact>> {
return this.contactRepository.findAllPaginated({
page: dto.page,
limit: dto.limit,
@@ -50,7 +50,7 @@ export class ContactService {
order: dto.order,
status: dto.status,
scope: ContactScope.SHOP,
restaurantId
shopId
});
}
async findAllPaginatedSuper(dto: FindContactsDto): Promise<PaginatedResult<Contact>> {
@@ -65,10 +65,10 @@ export class ContactService {
});
}
async findOne(id: string, restaurantId?: string): Promise<Contact> {
async findOne(id: string, shopId?: string): Promise<Contact> {
const where: any = { id };
if (restaurantId) {
where.shop = restaurantId;
if (shopId) {
where.shop = shopId;
}
const contact = await this.contactRepository.findOne(where);
@@ -78,10 +78,10 @@ export class ContactService {
return contact;
}
async updateStatus(id: string, dto: UpdateContactStatusDto, restaurantId?: string): Promise<Contact> {
async updateStatus(id: string, dto: UpdateContactStatusDto, shopId?: string): Promise<Contact> {
const where: any = { id };
if (restaurantId) {
where.shop = restaurantId;
if (shopId) {
where.shop = shopId;
}
const contact = await this.contactRepository.findOne(where);
@@ -93,10 +93,10 @@ export class ContactService {
return contact;
}
async remove(id: string, restaurantId?: string): Promise<void> {
async remove(id: string, shopId?: string): Promise<void> {
const where: any = { id };
if (restaurantId) {
where.shop = restaurantId;
if (shopId) {
where.shop = shopId;
}
const contact = await this.contactRepository.findOne(where);