package com.usky.ai.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class EdgeAppFetchResponseDTO {
    @JsonProperty("BoardId")
    private String boardId;

    @JsonProperty("BoardIp")
    private String boardIp;

    @JsonProperty("Content")
    private List<MediaContent> content;

    @JsonProperty("Event")
    private String event = "/alg_media_fetch"; // 固定值

    @JsonProperty("Result")
    private Result result;

    private long time = System.currentTimeMillis();

    public boolean isSuccess() {
        return result != null && Integer.valueOf(0).equals(result.getCode());
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Result {
        @JsonProperty("Code")
        private Integer code;

        @JsonProperty("Desc")
        private String desc;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class MediaContent {
        @JsonProperty("MediaName")
        private String mediaName;

        @JsonProperty("MediaDesc")
        private String mediaDesc;

        @JsonProperty("MediaUrl")
        private String mediaUrl;

        @JsonProperty("RtspTransport")
        private Boolean rtspTransport;

        @JsonProperty("GBTransport")
        private Boolean gbTransport;

        @JsonProperty("SubId")
        private String subId;

        @JsonProperty("MediaStatus")
        private MediaStatus mediaStatus;

        @JsonProperty("Params")
        private List<Param> params;

        @JsonProperty("ProtocolType")
        private Integer protocolType;

        @JsonProperty("SipBChannelId")
        private String sipBChannelId;

        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class Param {
            @JsonProperty("Key")
            private String key;
            @JsonProperty("Name")
            private String name;
            @JsonProperty("Type")
            private String type;

            // 既能是 String 也能是 List<String>
            @JsonProperty("Value")
            private Object value;
        }

        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class MediaStatus {
            @JsonProperty("type")
            private Integer type;

            @JsonProperty("style")
            private String style;

            @JsonProperty("label")
            private String label;

            @JsonProperty("size")
            private Size size;

            @Data
            public static class Size {
                @JsonProperty("width")
                private Integer width;

                @JsonProperty("height")
                private Integer height;
            }
        }
    }
}