package com.dora.dto;

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

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 视频点播相关DTO
 */
public class VodDto {

    @Data
    @Schema(description = "获取视频上传凭证请求")
    public static class GetUploadAuthRequest {
        @NotBlank(message = "视频标题不能为空")
        @Size(max = 128, message = "视频标题长度不能超过128个字符")
        @Schema(description = "视频标题", example = "我的视频")
        private String title;

        @Schema(description = "视频描述（支持HTML格式，数据库保存完整内容，发送给阿里云时自动去除HTML标签并截断）", example = "这是一个测试视频")
        private String description;

        @Schema(description = "视频标签，多个标签用逗号分隔", example = "测试,视频,演示")
        private String tags;

        @Schema(description = "视频分类ID", example = "1000000000")
        private String cateId;

        @Schema(description = "视频封面URL", example = "https://example.com/cover.jpg")
        private String coverUrl;

        @Schema(description = "视频文件名", example = "video.mp4")
        private String fileName;

        @Schema(description = "视频文件大小（字节）", example = "10485760")
        private Long fileSize;
    }

    @Data
    @Schema(description = "视频上传凭证响应")
    public static class UploadAuthResponse {
        @Schema(description = "上传凭证")
        private String uploadAuth;

        @Schema(description = "上传地址")
        private String uploadAddress;

        @Schema(description = "视频ID")
        private String videoId;

        @Schema(description = "请求ID")
        private String requestId;
    }

    @Data
    @Schema(description = "刷新视频上传凭证请求")
    public static class RefreshUploadAuthRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;
    }

    @Data
    @Schema(description = "获取视频播放凭证请求")
    public static class GetPlayAuthRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;

        @Schema(description = "播放凭证过期时间（秒）", example = "3600")
        private Long authInfoTimeout = 3600L;

        @Schema(description = "播放域名", example = "play.example.com")
        private String playDomain;
    }

    @Data
    @Schema(description = "视频播放凭证响应")
    public static class PlayAuthResponse {
        @Schema(description = "播放凭证")
        private String playAuth;

        @Schema(description = "视频元信息")
        private VideoMeta videoMeta;

        @Schema(description = "请求ID")
        private String requestId;
    }

    @Data
    @Schema(description = "视频元信息")
    public static class VideoMeta {
        @Schema(description = "视频ID")
        private String videoId;

        @Schema(description = "视频标题")
        private String title;

        @Schema(description = "视频描述")
        private String description;

        @Schema(description = "视频时长（秒）")
        private Float duration;

        @Schema(description = "视频封面URL")
        private String coverURL;

        @Schema(description = "视频状态")
        private String status;

        @Schema(description = "视频大小（字节）")
        private Long size;

        @Schema(description = "视频格式")
        private String format;

        @Schema(description = "视频分辨率")
        private String resolution;

        @Schema(description = "视频帧率")
        private String fps;

        @Schema(description = "视频比特率")
        private String bitrate;
    }

    @Data
    @Schema(description = "获取视频信息请求")
    public static class GetVideoInfoRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;
    }

    @Data
    @Schema(description = "视频信息响应")
    public static class VideoInfoResponse {
        @Schema(description = "视频ID")
        private String videoId;

        @Schema(description = "视频标题")
        private String title;

        @Schema(description = "视频描述")
        private String description;

        @Schema(description = "视频时长（秒）")
        private Float duration;

        @Schema(description = "视频封面URL")
        private String coverURL;

        @Schema(description = "视频状态")
        private String status;

        @Schema(description = "视频大小（字节）")
        private Long size;

        @Schema(description = "视频格式")
        private String format;

        @Schema(description = "视频分辨率")
        private String resolution;

        @Schema(description = "视频帧率")
        private String fps;

        @Schema(description = "视频比特率")
        private String bitrate;

        @Schema(description = "创建时间")
        private String createTime;

        @Schema(description = "修改时间")
        private String modifyTime;

        @Schema(description = "视频分类ID")
        private String cateId;

        @Schema(description = "视频分类名称")
        private String cateName;

        @Schema(description = "视频标签")
        private String tags;
    }

    @Data
    @Schema(description = "获取音视频播放地址请求")
    public static class GetPlayInfoRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;

        @Schema(description = "课程ID（如果是课程视频）", example = "1")
        private Long courseId;

        @Schema(description = "章节ID（如果是课程视频）", example = "1")
        private Long chapterId;

        @Schema(description = "播放格式", example = "mp4")
        private String format = "mp4";

        @Schema(description = "播放质量", example = "HD")
        private String definition = "HD";
    }

    @Data
    @Schema(description = "音视频播放地址响应")
    public static class PlayInfoResponse {
        @Schema(description = "视频ID")
        private String videoId;

        @Schema(description = "播放地址列表")
        private PlayInfoList playInfoList;

        @Schema(description = "请求ID")
        private String requestId;
    }

    @Data
    @Schema(description = "播放地址列表")
    public static class PlayInfoList {
        @Schema(description = "播放地址列表")
        private java.util.List<PlayInfo> playInfo;
    }

    @Data
    @Schema(description = "播放地址信息")
    public static class PlayInfo {
        @Schema(description = "播放地址")
        private String playURL;

        @Schema(description = "播放格式")
        private String format;

        @Schema(description = "播放质量")
        private String definition;

        @Schema(description = "播放时长")
        private String duration;

        @Schema(description = "文件大小")
        private String size;

        @Schema(description = "宽度")
        private String width;

        @Schema(description = "高度")
        private String height;

        @Schema(description = "比特率")
        private String bitrate;

        @Schema(description = "帧率")
        private String fps;
    }

    @Data
    @Schema(description = "获取音视频播放凭证请求")
    public static class GetVideoPlayAuthRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;

        @Schema(description = "课程ID（如果是课程视频）", example = "1")
        private Long courseId;

        @Schema(description = "章节ID（如果是课程视频）", example = "1")
        private Long chapterId;

        @Schema(description = "播放凭证过期时间（秒）", example = "3600")
        private Long authInfoTimeout = 3600L;

        @Schema(description = "播放域名", example = "play.example.com")
        private String playDomain;
    }

    @Data
    @Schema(description = "音视频播放凭证响应")
    public static class VideoPlayAuthResponse {
        @Schema(description = "播放凭证")
        private String playAuth;

        @Schema(description = "视频元信息")
        private VideoMeta videoMeta;

        @Schema(description = "请求ID")
        private String requestId;
    }

    @Data
    @Schema(description = "获取视频播放凭证并增加播放次数请求")
    public static class GetPlayAuthWithViewCountRequest {
        @NotBlank(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "video123456")
        private String videoId;

        @Schema(description = "课程ID（如果是课程视频）", example = "1")
        private Long courseId;

        @Schema(description = "章节ID（如果是课程视频）", example = "1")
        private Long chapterId;

        @Schema(description = "播放凭证过期时间（秒）", example = "3600")
        private Long authInfoTimeout = 3600L;

        @Schema(description = "播放域名", example = "play.example.com")
        private String playDomain;
    }

    @Data
    @Schema(description = "视频播放凭证并增加播放次数响应")
    public static class PlayAuthWithViewCountResponse {
        @Schema(description = "播放凭证")
        private String playAuth;

        @Schema(description = "视频元信息")
        private VideoMeta videoMeta;

        @Schema(description = "请求ID")
        private String requestId;

        @Schema(description = "播放次数更新信息")
        private ViewCountUpdateInfo viewCountInfo;
    }

    @Data
    @Schema(description = "播放次数更新信息")
    public static class ViewCountUpdateInfo {
        @Schema(description = "视频ID")
        private Long videoId;

        @Schema(description = "更新前的播放次数")
        private Integer previousViewCount;

        @Schema(description = "更新后的播放次数")
        private Integer currentViewCount;

        @Schema(description = "观看统计记录ID")
        private Long viewStatId;

        @Schema(description = "更新时间")
        private java.time.LocalDateTime updateTime;
    }
} 