import { typeParser } from '@lib/utils/type-parser';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Expose, Transform } from 'class-transformer';
import { IsIn, IsInt, IsOptional, IsString } from 'class-validator';

export class CoursesVideosProgress {
  @Expose()
  @ApiProperty({ description: '강의영상 진행도 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  crvpId!: number;

  @Expose()
  @ApiProperty({ description: '강의영상 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  crvId!: number;

  @Expose()
  @ApiProperty({ description: '회원 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  memId!: number;

  @Expose()
  @ApiProperty({ description: '강의 마지막 시청 위치 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  crvpLastWatchedSeconds!: number;

  @Expose()
  @ApiProperty({
    description: '강의 영상 완료 여부(1: 완료 | 0: 미완료, default: 0)',
  })
  @Transform(({ value }) => typeParser.int(value))
  @IsIn([0, 1])
  crvpIsCompleted!: number;

  @Expose()
  @ApiPropertyOptional({ description: '강의 영상 진행도 수정일시' })
  @IsString()
  @IsOptional()
  crvpCompletedAt?: string;

  @Expose()
  @ApiPropertyOptional({ description: '강의 영상 진행도 수정일시' })
  @IsString()
  @IsOptional()
  crvpUpdatedAt?: string;

  @Expose()
  @ApiProperty({ description: '강의 영상 진행도 생성일시' })
  @IsString()
  crvpCreatedAt!: string;
}
