This commit is contained in:
@@ -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 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user