review
This commit is contained in:
@@ -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 { Type } from 'class-transformer';
|
||||
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
|
||||
|
||||
export class CreateReviewDto {
|
||||
@IsNotEmpty()
|
||||
@@ -28,22 +29,24 @@ export class CreateReviewDto {
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsEnum(PositivePoint, { each: true })
|
||||
@ApiPropertyOptional({
|
||||
description: 'Positive points about the food',
|
||||
example: ['Great taste', 'Fast delivery'],
|
||||
type: [String]
|
||||
example: [PositivePoint.GREAT_TASTE, PositivePoint.FAST_DELIVERY],
|
||||
enum: PositivePoint,
|
||||
isArray: true
|
||||
})
|
||||
positivePoints?: string[];
|
||||
positivePoints?: PositivePoint[];
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsEnum(NegativePoint, { each: true })
|
||||
@ApiPropertyOptional({
|
||||
description: 'Negative points about the food',
|
||||
example: ['Too spicy', 'Small portion'],
|
||||
type: [String]
|
||||
example: [NegativePoint.TOO_SPICY, NegativePoint.SMALL_PORTION],
|
||||
enum: NegativePoint,
|
||||
isArray: true
|
||||
})
|
||||
negativePoints?: string[];
|
||||
negativePoints?: NegativePoint[];
|
||||
}
|
||||
|
||||
|
||||
@@ -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 { Type } from 'class-transformer';
|
||||
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
|
||||
|
||||
export class UpdateReviewDto {
|
||||
@IsOptional()
|
||||
@@ -18,21 +19,23 @@ export class UpdateReviewDto {
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsEnum(PositivePoint, { each: true })
|
||||
@ApiPropertyOptional({
|
||||
description: 'Positive points about the food',
|
||||
type: [String]
|
||||
enum: PositivePoint,
|
||||
isArray: true
|
||||
})
|
||||
positivePoints?: string[];
|
||||
positivePoints?: PositivePoint[];
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsEnum(NegativePoint, { each: true })
|
||||
@ApiPropertyOptional({
|
||||
description: 'Negative points about the food',
|
||||
type: [String]
|
||||
enum: NegativePoint,
|
||||
isArray: true
|
||||
})
|
||||
negativePoints?: string[];
|
||||
negativePoints?: NegativePoint[];
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Food } from '../../foods/entities/food.entity';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { Order } from 'src/modules/orders/entities/order.entity';
|
||||
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
|
||||
|
||||
@Entity({ tableName: 'food_comments' })
|
||||
@Unique({ properties: ['order', 'food', 'user'] })
|
||||
@@ -23,10 +24,10 @@ export class Review extends BaseEntity {
|
||||
rating: number = 0;
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
positivePoints?: string[];
|
||||
positivePoints?: PositivePoint[];
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
negativePoints?: string[];
|
||||
negativePoints?: NegativePoint[];
|
||||
|
||||
@Property({ type: 'boolean', default: 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',
|
||||
}
|
||||
Reference in New Issue
Block a user