import { ApiProperty } from '@nestjs/swagger';
import {
  IsArray,
  IsNotEmpty,
  IsNumber,
  IsObject,
  IsString,
} from 'class-validator';
import { CreateDto } from 'src/common/dto/create.dto';
const baseSectionInfo = [
  {
    courseId: 1,
    name: '第一章',
    // 说明
    explain: '第一章的说明',
    // 序号
    serialNumber: 1,
    // 章节的课件信息
    courseware: [
      {
        // 课件的地址
        href: 'www.baidu.com',
        // 课件的名称
        name: '名称',
        // 课件规定的学习时长
        studyTime: 10,
        // 学习所占比重
        percentage: 10,
        // 是否可快进
        canSpeed: 0,
        // 课件在章节中的序号
        serialNumber: 1,
      },
    ],
  },
];
// 课程评价维度
const courseEvaluate = [
  {
    // 课程ID
    courseId: 1,
    // 维度名称
    dimensionality: '维度名1',
    // 0为课程评价1为学生自评
    type: 0,
  },
  {
    // 课程ID
    courseId: 1,
    // 维度名称
    dimensionality: '维度名2',
    // 0为课程评价1为学生自评
    type: 1,
  },
];
export class CreateOnlineCourseDto extends CreateDto {
  @ApiProperty({ description: '课程名称' })
  @IsNotEmpty({ message: '课程名称不能为空' })
  name: string;

  @ApiProperty({ description: '所属分类id', default: 1 })
  @IsNotEmpty({ message: '课程分类不能为空' })
  classify: number;

  @ApiProperty({ description: '章节数量' })
  @IsNotEmpty({ message: '课程章节数量不可为空' })
  sectionCount: number;

  @ApiProperty({ description: '课程难度1-2-3' })
  @IsNotEmpty({ message: '课程难度不可为空' })
  @IsNumber()
  difficulty: number;

  @ApiProperty({ description: '课程状态1为开启0为关闭' })
  @IsNotEmpty({ message: '' })
  @IsNumber()
  status: number;

  @ApiProperty({ description: '课程分值' })
  @IsNotEmpty({ message: '课程分值不可为空' })
  @IsNumber()
  grade: number;

  @ApiProperty({ description: '课程封面地址' })
  @IsString({ message: '请上传string类型数据的封面地址' })
  cover: string;

  @ApiProperty({ description: '课程简介' })
  @IsString({ message: '请上传string类型数据的课程简介' })
  explain: string;

  @ApiProperty({ description: '学习该课程的组织' })
  @IsNotEmpty({ message: '学习该课程的组织不可为空' })
  @IsNumber()
  studyOrgId: number;

  @ApiProperty({ description: '0/1章节顺序学习？' })
  @IsNotEmpty({ message: '章节是否顺序学习不可为空' })
  @IsNumber()
  sectionSortStudy: number;

  @ApiProperty({ description: '0/1课件顺序学习？' })
  @IsNotEmpty({ message: '课件是否顺序学习不可为空' })
  @IsNumber()
  coursewareSortStudy: number;

  @ApiProperty({ description: '0/1开启课程问答' })
  @IsNotEmpty({ message: '开启课程问答不可为空' })
  @IsNumber()
  openQuiz: number;

  @ApiProperty({ description: '0/1开启讨论' })
  @IsNotEmpty({ message: '开启讨论不可为空' })
  @IsNumber()
  openDiscussion: number;

  @ApiProperty({ description: '0/1开启课程评价' })
  @IsNotEmpty({ message: '开启课程评价不可为空' })
  @IsNumber()
  openEval: number;

  @ApiProperty({ description: '0/1开启学员自评' })
  @IsNotEmpty({ message: '开启学员自评不可为空' })
  @IsNumber()
  openSelfEvaluation: number;

  @ApiProperty({ description: '0/1开启文本或维度评价' })
  @IsNotEmpty({ message: '开启文本或维度评价不可为空' })
  @IsNumber()
  txtOrGradeEvealute: number;

  @ApiProperty({ description: '0/1开启学员自评' })
  @IsNotEmpty({ message: '开启学员自评不可为空' })
  @IsNumber()
  textOrGradeSelfEval: number;

  @ApiProperty({ description: '文本评价的标题' })
  @IsString()
  textEvaluateTitle: string;

  @ApiProperty({ description: '自评评价时的文本评价标题' })
  @IsString()
  selfTextEvaluateTitle: string;

  @ApiProperty({ description: '课程下的练习题信息', default: [1] })
  @IsArray()
  exercise: [object];

  @ApiProperty({ description: '章节课件内容', default: baseSectionInfo })
  @IsArray({ message: 'courseSectionContent必须为数组' })
  courseSectionContent: [];

  @ApiProperty({ description: '课件评价维度', default: courseEvaluate })
  @IsArray()
  evalDimension: [];
}
