diff --git a/src/modules/foods/dto/create-category.dto.ts b/src/modules/foods/dto/create-category.dto.ts index 91d7966..8646850 100644 --- a/src/modules/foods/dto/create-category.dto.ts +++ b/src/modules/foods/dto/create-category.dto.ts @@ -1,4 +1,4 @@ -import { IsString, IsOptional, IsBoolean } from 'class-validator'; +import { IsString, IsOptional, IsBoolean, IsInt, Min } from 'class-validator'; import { ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; @@ -17,4 +17,11 @@ export class CreateCategoryDto { @IsString() @ApiPropertyOptional({ example: 'https://cdn.example.com/avatar.png' }) avatarUrl?: string; + + @IsOptional() + @IsInt() + @Min(0) + @Type(() => Number) + @ApiPropertyOptional({ example: 1 }) + order?: number; } diff --git a/src/modules/foods/dto/create-food.dto.ts b/src/modules/foods/dto/create-food.dto.ts index d19cb39..988ee06 100644 --- a/src/modules/foods/dto/create-food.dto.ts +++ b/src/modules/foods/dto/create-food.dto.ts @@ -111,4 +111,12 @@ export class CreateFoodDto { @ApiPropertyOptional({ example: false }) @Type(() => Boolean) isSpecialOffer?: boolean; + + @IsOptional() + @IsInt() + @Min(0) + @Type(() => Number) + @ApiPropertyOptional({ example: 1 }) + order?: number; + } diff --git a/src/modules/foods/entities/category.entity.ts b/src/modules/foods/entities/category.entity.ts index 58c2516..a2c679f 100644 --- a/src/modules/foods/entities/category.entity.ts +++ b/src/modules/foods/entities/category.entity.ts @@ -21,4 +21,7 @@ export class Category extends BaseEntity { @Property({ nullable: true }) avatarUrl?: string; + + @Property({ type: 'int', nullable: true }) + order?: number; } diff --git a/src/modules/foods/providers/food.service.ts b/src/modules/foods/providers/food.service.ts index 9d5d328..9aa4334 100644 --- a/src/modules/foods/providers/food.service.ts +++ b/src/modules/foods/providers/food.service.ts @@ -46,6 +46,7 @@ export class FoodService { pickupServe: rest.pickupServe ?? false, discount: rest.discount ?? 0, isSpecialOffer: rest.isSpecialOffer ?? false, + order: rest.order ?? null, // map single-title/content DTO to localized fields title: rest.title, content: rest.content,