feat(products): include ownerId in product creation and enforce its requirement
This commit is contained in:
@@ -116,7 +116,7 @@ export class ProductsService {
|
||||
return product;
|
||||
}
|
||||
|
||||
async create(data: CreateProductDto) {
|
||||
async create(data: CreateProductDto, ownerId?: number) {
|
||||
const name = data.name.trim();
|
||||
const normalizedName = normalizeName(name);
|
||||
|
||||
@@ -140,8 +140,13 @@ export class ProductsService {
|
||||
return existing;
|
||||
}
|
||||
|
||||
if (!ownerId) {
|
||||
throw new Error('ownerId är obligatorisk för att skapa en produkt');
|
||||
}
|
||||
|
||||
return this.prisma.product.create({
|
||||
data: {
|
||||
ownerId,
|
||||
name,
|
||||
normalizedName,
|
||||
canonicalName: name,
|
||||
|
||||
Reference in New Issue
Block a user