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

This commit is contained in:
2026-06-20 20:24:12 +03:30
parent 65a34b97e2
commit ef598a4c28
7 changed files with 105 additions and 7 deletions
@@ -1,6 +1,7 @@
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import { CreateRestaurantDto } from '../dto/create-restaurant.dto';
import { UpdateRestaurantDto } from '../dto/update-restaurant.dto';
import { UpdateRestaurantBgDto } from '../dto/update-restaurant-bg.dto';
import { UpgradeSubscriptionDto } from '../dto/upgrade-subscription.dto';
import { Restaurant } from '../entities/restaurant.entity';
import { EntityManager } from '@mikro-orm/postgresql';
@@ -29,6 +30,7 @@ import { SmsLog } from '../../notifications/entities/smsLogs.entity';
import { Notification } from '../../notifications/entities/notification.entity';
import { CacheService } from 'src/modules/utils/cache.service';
import { CacheKeys } from 'src/common/constants/cache-keys.constant';
import { BackgroundRepository } from '../repositories/background.repository';
@Injectable()
@@ -36,6 +38,7 @@ export class RestaurantsService {
constructor(
private readonly em: EntityManager,
private readonly restRepository: RestRepository,
private readonly backgroundRepository: BackgroundRepository,
private readonly cacheService: CacheService,
) { }
@@ -142,8 +145,8 @@ export class RestaurantsService {
}
async findOneBySubscriptionId(subscriptionId: string): Promise<Restaurant> {
const restaurant = await this.restRepository.findOne({ subscriptionId });
if (!restaurant) {
const restaurant = await this.restRepository.findOne({ subscriptionId });
if (!restaurant) {
throw new NotFoundException(RestMessage.NOT_FOUND);
}
return restaurant;
@@ -294,4 +297,21 @@ export class RestaurantsService {
});
}
findAllBackgrounds() {
return this.backgroundRepository.findAll();
}
async updateBackground(id: string, dto: UpdateRestaurantBgDto): Promise<Restaurant> {
const restaurant = await this.restRepository.findOne({ id });
if (!restaurant) {
throw new NotFoundException(RestMessage.NOT_FOUND);
}
this.restRepository.assign(restaurant, dto);
await this.em.persistAndFlush(restaurant);
await this.invalidateRestaurantCache(restaurant.slug);
return restaurant;
}
}