package com.dora.dto;

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

import java.util.List;
import java.util.Map;

/**
 * AI模型相关DTO
 */
public class AiModelDto {

    /**
     * 模型信息响应
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "AI模型信息")
    public static class ModelInfoResponse {
        @Schema(description = "模型ID", example = "1")
        private Long id;

        @Schema(description = "模型名称", example = "sora_image")
        private String modelName;

        @Schema(description = "模型显示名称", example = "Sora图片生成")
        private String displayName;

        @Schema(description = "模型描述", example = "Sora高质量图片生成")
        private String description;

        @Schema(description = "积分消耗", example = "11")
        private Integer pointsCost;

        @Schema(description = "服务提供商", example = "openai")
        private String providerType;

        @Schema(description = "任务类型", example = "image")
        private String taskType;

        @Schema(description = "是否启用", example = "true")
        private Boolean isEnabled;

        @Schema(description = "扩展配置（如支持的尺寸、时长等）")
        private Map<String, Object> extendedConfig;
    }

    /**
     * 按类型分组的模型列表响应
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "按类型分组的模型列表")
    public static class ModelsByTypeResponse {
        @Schema(description = "任务类型", example = "image")
        private String taskType;

        @Schema(description = "类型显示名称", example = "图片生成")
        private String taskTypeName;

        @Schema(description = "该类型下的模型列表")
        private List<ModelInfoResponse> models;

        @Schema(description = "模型数量", example = "2")
        private Integer count;
    }

    /**
     * 按厂商分组的模型列表响应
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "按厂商分组的模型列表")
    public static class ModelsByProviderResponse {
        @Schema(description = "服务提供商", example = "openai")
        private String providerType;

        @Schema(description = "提供商显示名称", example = "OpenAI")
        private String providerName;

        @Schema(description = "该厂商下的模型列表")
        private List<ModelInfoResponse> models;

        @Schema(description = "模型数量", example = "5")
        private Integer count;
    }

    /**
     * 模型列表查询请求
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "模型列表查询条件")
    public static class QueryModelsRequest {
        @Schema(description = "任务类型（可选：image-图片生成/video-视频生成）", example = "image")
        private String taskType;

        @Schema(description = "服务提供商（可选：openai/runninghub）", example = "openai")
        private String providerType;

        @Schema(description = "分组方式（可选：type-按类型/provider-按厂商/none-不分组）", example = "type")
        private String groupBy;

        @Schema(description = "是否只返回已启用的模型", example = "true")
        private Boolean enabledOnly;
    }

    /**
     * 模型统计响应
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "模型统计信息")
    public static class ModelStatsResponse {
        @Schema(description = "总模型数", example = "10")
        private Integer totalModels;

        @Schema(description = "已启用模型数", example = "8")
        private Integer enabledModels;

        @Schema(description = "按类型统计")
        private Map<String, Integer> countByType;

        @Schema(description = "按厂商统计")
        private Map<String, Integer> countByProvider;
    }
}
