Files
gongxue-base/apps/server/src/schedules/dto/schedule.dto.ts

189 lines
2.8 KiB
TypeScript

import {
IsOptional,
IsString,
IsNotEmpty,
IsInt,
IsISO8601,
IsMilitaryTime,
Matches,
Min,
Max,
MaxLength,
IsIn,
} from 'class-validator';
import { Type } from 'class-transformer';
export class CreateScheduleDto {
@IsInt()
@IsNotEmpty()
classId: number;
@IsInt()
@IsNotEmpty()
classroomId: number;
@IsInt()
@Min(1)
@Max(7)
@IsNotEmpty()
weekDay: number;
@IsMilitaryTime()
@IsNotEmpty()
startTime: string;
@IsMilitaryTime()
@IsNotEmpty()
endTime: string;
@IsOptional()
@IsInt()
@Min(0)
@Max(1440)
attendanceAdvanceMinutes?: number;
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
@IsNotEmpty()
startDate: string;
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
@IsNotEmpty()
endDate: string;
@IsString()
@IsNotEmpty()
subject: string;
@IsOptional()
@IsInt()
teacherId?: number;
@IsOptional()
@IsString()
scheduleType?: string;
@IsOptional()
@IsInt()
rentalId?: number;
@IsOptional()
@IsString()
@MaxLength(500)
notes?: string;
}
export class UpdateScheduleDto {
@IsOptional()
@IsInt()
classId?: number;
@IsOptional()
@IsInt()
classroomId?: number;
@IsOptional()
@IsInt()
@Min(1)
@Max(7)
weekDay?: number;
@IsOptional()
@IsMilitaryTime()
startTime?: string;
@IsOptional()
@IsMilitaryTime()
endTime?: string;
@IsOptional()
@IsInt()
@Min(0)
@Max(1440)
attendanceAdvanceMinutes?: number;
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
startDate?: string;
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
endDate?: string;
@IsOptional()
@IsString()
subject?: string;
@IsOptional()
@IsInt()
teacherId?: number;
@IsOptional()
@IsString()
scheduleType?: string;
@IsOptional()
@IsInt()
rentalId?: number;
@IsOptional()
@IsString()
@MaxLength(500)
notes?: string;
@IsOptional()
@IsString()
@IsIn(['active', 'inactive', 'cancelled'])
status?: string;
}
export class QueryScheduleDto {
@IsOptional()
@Type(() => Number)
@IsInt()
classroomId?: number;
@IsOptional()
@Type(() => Number)
@IsInt()
classId?: number;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(7)
weekDay?: number;
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
startDate?: string;
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
endDate?: string;
}
export class WeeklyViewQueryDto {
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
startDate?: string;
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsISO8601({ strict: true })
endDate?: string;
@IsOptional()
@Type(() => Number)
@IsInt()
classroomId?: number;
}