first commit
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { PrizeStatus, PrizeType, StockType } from '@prisma/client';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsDate,
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Matches,
|
||||
Min,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreatePrizeDto {
|
||||
@ApiProperty({ example: 'آیفون ۱۵ پرو ۲۵۶ گیگابایت', description: 'عنوان جایزه' })
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: 'عنوان جایزه الزامی است' })
|
||||
title: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'تحویل حضوری با ارائه کارت شناسایی' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'تحویل حضوری با ارائه کارت شناسایی' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
subtitle?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'http://localhost:3000/uploads/iphone.png' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
image?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'http://localhost:3000/uploads/iphone.png' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
iconUrl?: string;
|
||||
|
||||
@ApiProperty({ enum: PrizeType, example: PrizeType.PHYSICAL, description: 'نوع جایزه' })
|
||||
@IsOptional()
|
||||
type?: PrizeType;
|
||||
|
||||
@ApiPropertyOptional({ description: 'نام مستعار نوع جایزه' })
|
||||
@IsOptional()
|
||||
prizeType?: string;
|
||||
|
||||
@ApiProperty({ enum: StockType, example: StockType.LIMITED, description: 'نوع موجودی (محدود / نامحدود)' })
|
||||
@IsEnum(StockType)
|
||||
@IsNotEmpty()
|
||||
stockType: StockType;
|
||||
|
||||
@ApiPropertyOptional({ example: 5, description: 'موجودی اولیه (در صورت محدود بودن)' })
|
||||
@ValidateIf((o) => o.stockType === StockType.LIMITED)
|
||||
@Type(() => Number)
|
||||
@IsInt({ message: 'موجودی اولیه باید عدد صحیح باشد' })
|
||||
@Min(1, { message: 'موجودی اولیه باید حداقل ۱ باشد' })
|
||||
initialStock?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 5, description: 'موجودی باقیمانده فعلی' })
|
||||
@Type(() => Number)
|
||||
@IsInt({ message: 'موجودی باقیمانده باید عدد صحیح باشد' })
|
||||
@Min(0, { message: 'موجودی باقیمانده نمیتواند منفی باشد' })
|
||||
@IsOptional()
|
||||
remainingStock?: number;
|
||||
|
||||
@ApiProperty({ example: 10, description: 'وزن برد (عددی مثبت و بزرگتر از صفر)' })
|
||||
@Type(() => Number)
|
||||
@IsInt({ message: 'وزن برد باید عدد صحیح باشد' })
|
||||
@Min(1, { message: 'وزن برد باید حداقل ۱ باشد' })
|
||||
weight: number;
|
||||
|
||||
@ApiPropertyOptional({ enum: PrizeStatus, default: PrizeStatus.ACTIVE })
|
||||
@IsEnum(PrizeStatus)
|
||||
@IsOptional()
|
||||
status?: PrizeStatus = PrizeStatus.ACTIVE;
|
||||
|
||||
@ApiPropertyOptional({ description: 'وضعیت فعال بودن' })
|
||||
@IsOptional()
|
||||
isActive?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ example: 1, default: 0, description: 'ترتیب سگمنت روی گردونه' })
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
sortOrder?: number = 0;
|
||||
|
||||
@ApiPropertyOptional({ example: '#FF5733', description: 'کد رنگ سگمنت در گردونه (فرمت هگز)' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
segmentColor?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '#FF5733', description: 'کد رنگ (نام مستعار)' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
color?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '#FFFFFF' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
textColor?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '2026-12-31T23:59:59.000Z', description: 'تاریخ انقضای کد یا جایزه' })
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
expiresAt?: Date;
|
||||
|
||||
@ApiPropertyOptional({ example: 'تبریک! شما برنده {prize} شدید. کد جایزه: {code}' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
smsTemplate?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user