import { IsString, IsNotEmpty, IsOptional, IsNumber, Min, IsDateString, IsEnum, IsArray, ValidateNested, } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { AppointmentStatus } from '../../../common/enums'; export class CreateAppointmentDto { @ApiProperty({ description: '小组ID' }) @IsString() @IsNotEmpty({ message: '小组ID不能为空' }) groupId: string; @ApiProperty({ description: '游戏ID' }) @IsString() @IsNotEmpty({ message: '游戏ID不能为空' }) gameId: string; @ApiProperty({ description: '预约标题' }) @IsString() @IsNotEmpty({ message: '预约标题不能为空' }) title: string; @ApiProperty({ description: '预约描述', required: false }) @IsString() @IsOptional() description?: string; @ApiProperty({ description: '预约开始时间' }) @IsDateString() startTime: Date; @ApiProperty({ description: '预约结束时间', required: false }) @IsDateString() @IsOptional() endTime?: Date; @ApiProperty({ description: '最大参与人数', example: 5 }) @IsNumber() @Min(1) @Type(() => Number) maxParticipants: number; } export class UpdateAppointmentDto { @ApiProperty({ description: '预约标题', required: false }) @IsString() @IsOptional() title?: string; @ApiProperty({ description: '预约描述', required: false }) @IsString() @IsOptional() description?: string; @ApiProperty({ description: '预约开始时间', required: false }) @IsDateString() @IsOptional() startTime?: Date; @ApiProperty({ description: '预约结束时间', required: false }) @IsDateString() @IsOptional() endTime?: Date; @ApiProperty({ description: '最大参与人数', required: false }) @IsNumber() @Min(1) @IsOptional() @Type(() => Number) maxParticipants?: number; @ApiProperty({ description: '状态', enum: AppointmentStatus, required: false }) @IsEnum(AppointmentStatus) @IsOptional() status?: AppointmentStatus; } export class JoinAppointmentDto { @ApiProperty({ description: '预约ID' }) @IsString() @IsNotEmpty({ message: '预约ID不能为空' }) appointmentId: string; } export class QueryAppointmentsDto { @ApiProperty({ description: '小组ID', required: false }) @IsString() @IsOptional() groupId?: string; @ApiProperty({ description: '游戏ID', required: false }) @IsString() @IsOptional() gameId?: string; @ApiProperty({ description: '状态', enum: AppointmentStatus, required: false }) @IsEnum(AppointmentStatus) @IsOptional() status?: AppointmentStatus; @ApiProperty({ description: '开始时间', required: false }) @IsDateString() @IsOptional() startTime?: Date; @ApiProperty({ description: '结束时间', required: false }) @IsDateString() @IsOptional() endTime?: Date; @ApiProperty({ description: '页码', example: 1, required: false }) @IsNumber() @Min(1) @IsOptional() @Type(() => Number) page?: number; @ApiProperty({ description: '每页数量', example: 10, required: false }) @IsNumber() @Min(1) @IsOptional() @Type(() => Number) limit?: number; } export class PollOptionDto { @ApiProperty({ description: '选项时间' }) @IsDateString() time: Date; @ApiProperty({ description: '选项描述', required: false }) @IsString() @IsOptional() description?: string; } export class CreatePollDto { @ApiProperty({ description: '小组ID' }) @IsString() @IsNotEmpty({ message: '小组ID不能为空' }) groupId: string; @ApiProperty({ description: '游戏ID' }) @IsString() @IsNotEmpty({ message: '游戏ID不能为空' }) gameId: string; @ApiProperty({ description: '投票标题' }) @IsString() @IsNotEmpty({ message: '投票标题不能为空' }) title: string; @ApiProperty({ description: '投票描述', required: false }) @IsString() @IsOptional() description?: string; @ApiProperty({ description: '投票选项', type: [PollOptionDto] }) @IsArray() @ValidateNested({ each: true }) @Type(() => PollOptionDto) options: PollOptionDto[]; @ApiProperty({ description: '投票截止时间' }) @IsDateString() deadline: Date; } export class VoteDto { @ApiProperty({ description: '投票ID' }) @IsString() @IsNotEmpty({ message: '投票ID不能为空' }) pollId: string; @ApiProperty({ description: '选项索引' }) @IsNumber() @Min(0) @Type(() => Number) optionIndex: number; }