This commit is contained in:
2026-03-09 12:46:39 +03:30
parent 9e33129902
commit b264500802
10 changed files with 248 additions and 11 deletions
+15 -3
View File
@@ -1,11 +1,23 @@
import { Injectable } from '@nestjs/common';
import { BadRequestException, Injectable } from '@nestjs/common';
import { CreateCatalogueDto } from './dto/create-catalogue.dto';
import { UpdateCatalogueDto } from './dto/update-catalogue.dto';
import { EntityManager } from '@mikro-orm/postgresql';
import { Catalogue } from './entities/catalogue.entity';
import { Business } from '../business/entities/business.entity';
@Injectable()
export class CatalogueService {
create(createCatalogueDto: CreateCatalogueDto) {
return 'This action adds a new catalogue';
constructor(
private readonly em: EntityManager,
) { }
async create(dto: CreateCatalogueDto) {
const business = await this.em.findOne(Business, {})
if (!business) {
throw new BadRequestException()
}
const catalogue = this.em.create(Catalogue, { ...dto, business })
return this.em.persistAndFlush(catalogue)
}
findAll() {