This commit is contained in:
2025-12-08 10:35:11 +03:30
parent a1255f173d
commit aededf6da9
4 changed files with 40 additions and 18 deletions
+12 -9
View File
@@ -1,6 +1,7 @@
import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, IsArray } from 'class-validator'; import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, IsArray, IsEnum } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
export class CreateReviewDto { export class CreateReviewDto {
@IsNotEmpty() @IsNotEmpty()
@@ -28,22 +29,24 @@ export class CreateReviewDto {
@IsOptional() @IsOptional()
@IsArray() @IsArray()
@IsString({ each: true }) @IsEnum(PositivePoint, { each: true })
@ApiPropertyOptional({ @ApiPropertyOptional({
description: 'Positive points about the food', description: 'Positive points about the food',
example: ['Great taste', 'Fast delivery'], example: [PositivePoint.GREAT_TASTE, PositivePoint.FAST_DELIVERY],
type: [String] enum: PositivePoint,
isArray: true
}) })
positivePoints?: string[]; positivePoints?: PositivePoint[];
@IsOptional() @IsOptional()
@IsArray() @IsArray()
@IsString({ each: true }) @IsEnum(NegativePoint, { each: true })
@ApiPropertyOptional({ @ApiPropertyOptional({
description: 'Negative points about the food', description: 'Negative points about the food',
example: ['Too spicy', 'Small portion'], example: [NegativePoint.TOO_SPICY, NegativePoint.SMALL_PORTION],
type: [String] enum: NegativePoint,
isArray: true
}) })
negativePoints?: string[]; negativePoints?: NegativePoint[];
} }
+10 -7
View File
@@ -1,6 +1,7 @@
import { IsBoolean, IsNumber, IsOptional, IsString, Max, Min, IsArray } from 'class-validator'; import { IsBoolean, IsNumber, IsOptional, IsString, Max, Min, IsArray, IsEnum } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger'; import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
export class UpdateReviewDto { export class UpdateReviewDto {
@IsOptional() @IsOptional()
@@ -18,21 +19,23 @@ export class UpdateReviewDto {
@IsOptional() @IsOptional()
@IsArray() @IsArray()
@IsString({ each: true }) @IsEnum(PositivePoint, { each: true })
@ApiPropertyOptional({ @ApiPropertyOptional({
description: 'Positive points about the food', description: 'Positive points about the food',
type: [String] enum: PositivePoint,
isArray: true
}) })
positivePoints?: string[]; positivePoints?: PositivePoint[];
@IsOptional() @IsOptional()
@IsArray() @IsArray()
@IsString({ each: true }) @IsEnum(NegativePoint, { each: true })
@ApiPropertyOptional({ @ApiPropertyOptional({
description: 'Negative points about the food', description: 'Negative points about the food',
type: [String] enum: NegativePoint,
isArray: true
}) })
negativePoints?: string[]; negativePoints?: NegativePoint[];
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
+3 -2
View File
@@ -3,6 +3,7 @@ import { BaseEntity } from '../../../common/entities/base.entity';
import { Food } from '../../foods/entities/food.entity'; import { Food } from '../../foods/entities/food.entity';
import { User } from '../../users/entities/user.entity'; import { User } from '../../users/entities/user.entity';
import { Order } from 'src/modules/orders/entities/order.entity'; import { Order } from 'src/modules/orders/entities/order.entity';
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
@Entity({ tableName: 'food_comments' }) @Entity({ tableName: 'food_comments' })
@Unique({ properties: ['order', 'food', 'user'] }) @Unique({ properties: ['order', 'food', 'user'] })
@@ -23,10 +24,10 @@ export class Review extends BaseEntity {
rating: number = 0; rating: number = 0;
@Property({ type: 'json', nullable: true }) @Property({ type: 'json', nullable: true })
positivePoints?: string[]; positivePoints?: PositivePoint[];
@Property({ type: 'json', nullable: true }) @Property({ type: 'json', nullable: true })
negativePoints?: string[]; negativePoints?: NegativePoint[];
@Property({ type: 'boolean', default: false }) @Property({ type: 'boolean', default: false })
isApproved: boolean = false; isApproved: boolean = false;
@@ -0,0 +1,15 @@
export enum PositivePoint {
GREAT_TASTE = 'great_taste',
FAST_DELIVERY = 'fast_delivery',
GOOD_QUALITY = 'good_quality',
GOOD_PORTION_SIZE = 'good_portion_size',
FRIENDLY_SERVICE = 'friendly_service',
}
export enum NegativePoint {
SMALL_PORTION = 'small_portion',
SLOW_DELIVERY = 'slow_delivery',
POOR_QUALITY = 'poor_quality',
OVERPRICED = 'overpriced',
UNFRIENDLY_SERVICE = 'unfriendly_service',
}