package com.dora.dto;

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

import jakarta.validation.constraints.NotNull;

/**
 * 课程视频播放相关DTO
 */
public class CourseVideoPlayDto {

    @Data
    @Schema(description = "获取课程视频播放凭证请求")
    public static class GetPlayAuthRequest {
        @NotNull(message = "课程ID不能为空")
        @Schema(description = "课程ID", example = "1")
        private Long courseId;

        @NotNull(message = "章节ID不能为空")
        @Schema(description = "章节ID", example = "1")
        private Long chapterId;

        @NotNull(message = "视频ID不能为空")
        @Schema(description = "视频ID", example = "1")
        private Long videoId;

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

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

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

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

        @Schema(description = "用户权限信息")
        private UserPermissionInfo userPermission;
    }

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

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

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

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

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

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

    @Data
    @Schema(description = "用户权限信息")
    public static class UserPermissionInfo {
        @Schema(description = "用户角色")
        private Integer userRole;

        @Schema(description = "用户角色名称")
        private String userRoleName;

        @Schema(description = "课程要求级别")
        private Integer requiredLevel;

        @Schema(description = "是否有权限")
        private Boolean hasPermission;

        @Schema(description = "权限检查时间")
        private java.time.LocalDateTime checkTime;
    }

    @Data
    @Schema(description = "权限验证失败响应")
    public static class PermissionDeniedResponse {
        @Schema(description = "错误代码")
        private String errorCode;

        @Schema(description = "错误信息")
        private String errorMessage;

        @Schema(description = "用户当前角色")
        private Integer userRole;

        @Schema(description = "用户角色名称")
        private String userRoleName;

        @Schema(description = "所需角色")
        private Integer requiredRole;

        @Schema(description = "所需角色名称")
        private String requiredRoleName;

        @Schema(description = "升级建议")
        private String upgradeAdvice;
    }
}