This commit is contained in:
2025-12-06 23:51:50 +03:30
parent 7567e00f8a
commit eb48187ad0
5 changed files with 31 additions and 6 deletions
+10 -5
View File
@@ -5,28 +5,33 @@ import { Type } from 'class-transformer';
export class CreateFoodDto { export class CreateFoodDto {
@IsNotEmpty() @IsNotEmpty()
@IsString() @IsString()
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' }) @ApiProperty()
categoryId: string; categoryId: string;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ApiPropertyOptional({ example: false }) @ApiPropertyOptional({ example: false })
@Type(() => Boolean) @Type(() => Boolean)
breakfast?: boolean; breakfast?: boolean;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ApiPropertyOptional({ example: false }) @ApiPropertyOptional({ example: false })
@Type(() => Boolean) @Type(() => Boolean)
tue?: boolean; tue?: boolean;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ApiPropertyOptional({ example: false }) @ApiPropertyOptional({ example: false })
@Type(() => Boolean) @Type(() => Boolean)
wed?: boolean; wed?: boolean;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ApiPropertyOptional({ example: false }) @ApiPropertyOptional({ example: false })
@Type(() => Boolean) @Type(() => Boolean)
thu?: boolean; thu?: boolean;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ApiPropertyOptional({ example: false }) @ApiPropertyOptional({ example: false })
@@ -140,8 +145,8 @@ export class CreateFoodDto {
discount?: number; discount?: number;
@IsOptional() @IsOptional()
@IsArray() @IsBoolean()
@IsString({ each: true }) @ApiPropertyOptional({ example: false })
@ApiPropertyOptional({ type: [String] }) @Type(() => Boolean)
categoryIds?: string[]; isSpecialOffer?: boolean;
} }
@@ -73,4 +73,7 @@ export class Food extends BaseEntity {
@Property({ type: 'float', default: 0 }) @Property({ type: 'float', default: 0 })
discount: number = 0; discount: number = 0;
@Property({ type: 'boolean', default: false })
isSpecialOffer: boolean = false;
} }
@@ -46,6 +46,7 @@ export class FoodService {
inPlaceServe: rest.inPlaceServe ?? false, inPlaceServe: rest.inPlaceServe ?? false,
pickupServe: rest.pickupServe ?? false, pickupServe: rest.pickupServe ?? false,
discount: rest.discount ?? 0, discount: rest.discount ?? 0,
isSpecialOffer: rest.isSpecialOffer ?? false,
// map single-title/content DTO to localized fields // map single-title/content DTO to localized fields
title: rest.title, title: rest.title,
content: rest.content, content: rest.content,
@@ -103,6 +104,10 @@ export class FoodService {
this.em.assign(food, { category: category }); this.em.assign(food, { category: category });
} }
// assign other fields from DTO
const { categoryId, ...rest } = dto;
this.em.assign(food, rest);
await this.em.persistAndFlush(food); await this.em.persistAndFlush(food);
return food; return food;
} }
@@ -40,7 +40,18 @@ export class CreateRestaurantDto {
longitude?: number; longitude?: number;
@ApiPropertyOptional({ @ApiPropertyOptional({
example: { type: 'Polygon', coordinates: [[[51.389, 35.6892], [51.390, 35.6892], [51.390, 35.6902], [51.389, 35.6902], [51.389, 35.6892]]] }, example: {
type: 'Polygon',
coordinates: [
[
[51.389, 35.6892],
[51.39, 35.6892],
[51.39, 35.6902],
[51.389, 35.6902],
[51.389, 35.6892],
],
],
},
description: 'محدوده سرویس‌دهی به صورت GeoJSON Polygon', description: 'محدوده سرویس‌دهی به صورت GeoJSON Polygon',
}) })
@IsOptional() @IsOptional()
+1
View File
@@ -42,6 +42,7 @@ export class FoodsSeeder {
inPlaceServe: false, inPlaceServe: false,
pickupServe: false, pickupServe: false,
images: foodData.images, images: foodData.images,
isSpecialOffer: false,
}); });
em.persist(food); em.persist(food);