background pattern
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-04 15:43:13 +03:30
parent fc4740f1c1
commit f8f3fa528e
8 changed files with 130 additions and 1 deletions
@@ -2,7 +2,9 @@ import { BadRequestException, Injectable, NotFoundException } from '@nestjs/comm
import { CreateRestaurantDto } from '../dto/create-shop.dto';
import { UpdateRestaurantDto } from '../dto/update-shop.dto';
import { UpdateSubscriptionDto } from '../dto/update-subscription.dto';
import { UpdateShopBackgroundDto } from '../dto/update-shop-background.dto';
import { Shop } from '../entities/shop.entity';
import { Background } from '../entities/background.entity';
import { EntityManager } from '@mikro-orm/postgresql';
import { ShopRepository } from '../repositories/rest.repository';
import { ShopMessage } from 'src/common/enums/message.enum';
@@ -147,6 +149,23 @@ export class ShopService {
return shop;
}
async findAllBackgrounds(): Promise<Background[]> {
return this.em.find(Background, {}, { orderBy: { createdAt: 'asc' } });
}
async updateBackground(id: string, dto: UpdateShopBackgroundDto): Promise<Shop> {
const shop = await this.shopRepository.findOne({ id });
if (!shop) {
throw new NotFoundException(ShopMessage.NOT_FOUND);
}
this.shopRepository.assign(shop, dto);
await this.em.flush();
return shop;
}
async update(id: string, dto: UpdateRestaurantDto): Promise<Shop> {
const shop = await this.shopRepository.findOne({ id: id });