package com.dora.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;

/**
 * 课程更新DTO
 */
@Data
@Schema(description = "课程更新请求")
public class CourseUpdateDto {
    
    @Schema(description = "课程标题", example = "AI图像处理入门课程")
    @Size(max = 128, message = "课程标题不能超过128个字符")
    private String title;
    
    @Schema(description = "课程描述", example = "学习AI图像处理的基础知识和实践技巧")
    private String description;
    
    @Schema(description = "封面图URL", example = "https://example.com/cover1.jpg")
    private String coverUrl;
    
    @Schema(description = "详情图集（JSON格式存储多张图片URL）", 
            example = "[\"https://example.com/detail1.jpg\", \"https://example.com/detail2.jpg\"]")
    private String detailGallery;
    
    @Schema(description = "价格", example = "29.99")
    @Min(value = 0, message = "价格不能为负数")
    private BigDecimal price;
    
    @Schema(description = "访问课程所需的最低用户级别", example = "1")
    @Min(value = 0, message = "用户级别不能为负数")
    private Integer level;
    
    @Schema(description = "课程分类", example = "人工智能")
    @Size(max = 64, message = "课程分类不能超过64个字符")
    private String category;
    
    @Schema(description = "是否免费", example = "true")
    private Boolean isFree;
    
    @Schema(description = "是否提交审核", example = "false")
    private Boolean submitForAudit = false;
    
    @Schema(description = "是否删除未提交的章节和视频", example = "true")
    private Boolean deleteMissing = true;
    
    @Schema(description = "章节列表")
    private List<ChapterUpdateDto> chapters;
    
    @Data
    @Schema(description = "章节更新信息")
    public static class ChapterUpdateDto {
        
        @Schema(description = "章节ID（更新时必填，新建时不填）", example = "123")
        private Long id;
        
        @Schema(description = "章节标题", example = "第一章：基础概念")
        @Size(max = 128, message = "章节标题不能超过128个字符")
        private String title;
        
        @Schema(description = "章节描述", example = "本章介绍AI图像处理的基本概念")
        private String description;
        
        @Schema(description = "排序号", example = "1")
        @Min(value = 1, message = "排序号必须大于0")
        private Integer orderNum;
        
        @Schema(description = "视频列表")
        private List<VideoUpdateDto> videos;
    }
    
    @Data
    @Schema(description = "视频更新信息")
    public static class VideoUpdateDto {
        
        @Schema(description = "视频记录ID（数字，或容错传入VOD字符串ID）；与vodVideoId二选一", example = "789 或 vod-abc123")
        private String videoId;
        
        @Schema(description = "阿里云VOD视频ID（与videoId二选一）", example = "vod-abc123")
        private String vodVideoId;
        
        @Schema(description = "视频ID（更新小节时必填，新建时不填）", example = "456")
        private Long id;
        
        @Schema(description = "视频标题", example = "1.1 什么是AI图像处理")
        @Size(max = 128, message = "视频标题不能超过128个字符")
        private String title;
        
        @Schema(description = "排序号", example = "1")
        @Min(value = 1, message = "排序号必须大于0")
        private Integer orderNum;
        
        @Schema(description = "视频时长（秒）", example = "120")
        @Min(value = 1, message = "视频时长必须大于0")
        private Integer durationSec;
    }
} 