Add dock category seed helper and product tag/prep fields.

Ensures chocolate and baklava exist for the website categories dock, and supports tag-filtered product lists for home carousels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-23 15:44:59 +03:30
co-authored by Cursor
parent d09eca8702
commit 5d1f8991f9
8 changed files with 89 additions and 18 deletions
+9
View File
@@ -8,6 +8,7 @@ import {
IsString,
Min,
MinLength,
ValidateIf,
ValidateNested,
} from 'class-validator';
@@ -61,6 +62,14 @@ export class CreateProductDto {
@IsString()
description?: string;
/** null = ready immediately (no prep time) */
@IsOptional()
@ValidateIf((_, value) => value !== null && value !== undefined)
@Type(() => Number)
@IsInt()
@Min(1)
preparationHours?: number | null;
@IsOptional()
@IsArray()
@IsString({ each: true })
@@ -14,6 +14,10 @@ export class ListProductsQueryDto {
@IsString()
categorySlug?: string;
@IsOptional()
@IsString()
tag?: string;
@IsOptional()
@Type(() => Number)
@IsInt()
+9
View File
@@ -8,6 +8,7 @@ import {
IsString,
Min,
MinLength,
ValidateIf,
ValidateNested,
} from 'class-validator';
import {
@@ -47,6 +48,14 @@ export class UpdateProductDto {
@IsString()
description?: string;
/** null = ready immediately (no prep time) */
@IsOptional()
@ValidateIf((_, value) => value !== null && value !== undefined)
@Type(() => Number)
@IsInt()
@Min(1)
preparationHours?: number | null;
@IsOptional()
@IsArray()
@IsString({ each: true })
+7
View File
@@ -35,6 +35,9 @@ export class ProductsService {
const where = {
...(categoryIds ? { categoryId: { in: categoryIds } } : {}),
...(query.tag?.trim()
? { tags: { has: query.tag.trim() } }
: {}),
...(query.minPrice !== undefined || query.maxPrice !== undefined
? {
price: {
@@ -100,6 +103,7 @@ export class ProductsService {
sellUnit: dto.sellUnit,
intro: dto.intro ?? '',
description: dto.description ?? '',
preparationHours: dto.preparationHours ?? null,
tags: dto.tags ?? [],
mainImageUrl: dto.mainImageUrl,
mainImageKey: dto.mainImageKey,
@@ -178,6 +182,9 @@ export class ProductsService {
...(dto.sellUnit !== undefined ? { sellUnit: dto.sellUnit } : {}),
...(dto.intro !== undefined ? { intro: dto.intro } : {}),
...(dto.description !== undefined ? { description: dto.description } : {}),
...(dto.preparationHours !== undefined
? { preparationHours: dto.preparationHours }
: {}),
...(dto.tags !== undefined ? { tags: dto.tags } : {}),
...(dto.mainImageUrl !== undefined
? { mainImageUrl: dto.mainImageUrl }